diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2022-03-04 18:48:51 +0000 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2022-03-12 18:25:10 +0000 |
commit | 6fb1b8b3421cd73657ac2a84b0b13b975926746f (patch) | |
tree | 4fed68c7ae76579d4f3a42a479c090de549c5768 /bootloader | |
parent | 8558255f45bb9d256bcd7bfb5b71e7bb382912a7 (diff) | |
download | rockbox-6fb1b8b3421cd73657ac2a84b0b13b975926746f.tar.gz rockbox-6fb1b8b3421cd73657ac2a84b0b13b975926746f.zip |
x1000: bootloader: split off GUI code
Change-Id: If716cfd117c48da2cff221b8854630022bb0fe48
Diffstat (limited to 'bootloader')
-rw-r--r-- | bootloader/SOURCES | 1 | ||||
-rw-r--r-- | bootloader/x1000.c | 82 | ||||
-rw-r--r-- | bootloader/x1000/gui.c | 113 | ||||
-rw-r--r-- | bootloader/x1000/x1000bootloader.h | 15 |
4 files changed, 130 insertions, 81 deletions
diff --git a/bootloader/SOURCES b/bootloader/SOURCES index b721b12ce1..39b46b0b8d 100644 --- a/bootloader/SOURCES +++ b/bootloader/SOURCES | |||
@@ -89,4 +89,5 @@ sansaconnect.c | |||
89 | show_logo.c | 89 | show_logo.c |
90 | #elif defined(FIIO_M3K) || defined(SHANLING_Q1) || defined(EROS_QN) | 90 | #elif defined(FIIO_M3K) || defined(SHANLING_Q1) || defined(EROS_QN) |
91 | x1000.c | 91 | x1000.c |
92 | x1000/gui.c | ||
92 | #endif | 93 | #endif |
diff --git a/bootloader/x1000.c b/bootloader/x1000.c index 78b74452d9..a079c478d5 100644 --- a/bootloader/x1000.c +++ b/bootloader/x1000.c | |||
@@ -67,13 +67,6 @@ struct menuitem { | |||
67 | void(*action)(void); | 67 | void(*action)(void); |
68 | }; | 68 | }; |
69 | 69 | ||
70 | void clearscreen(void); | ||
71 | void putversion(void); | ||
72 | void putcenter_y(int y, const char* msg); | ||
73 | void putcenter_line(int line, const char* msg); | ||
74 | void splash2(long delay, const char* msg, const char* msg2); | ||
75 | void splash(long delay, const char* msg); | ||
76 | |||
77 | void init_lcd(void); | 70 | void init_lcd(void); |
78 | void init_usb(void); | 71 | void init_usb(void); |
79 | int init_disk(void); | 72 | int init_disk(void); |
@@ -102,7 +95,6 @@ const struct menuitem recovery_items[] = { | |||
102 | }; | 95 | }; |
103 | 96 | ||
104 | /* Flags to indicate if hardware was already initialized */ | 97 | /* Flags to indicate if hardware was already initialized */ |
105 | bool lcd_inited = false; | ||
106 | bool usb_inited = false; | 98 | bool usb_inited = false; |
107 | bool disk_inited = false; | 99 | bool disk_inited = false; |
108 | 100 | ||
@@ -110,77 +102,6 @@ bool disk_inited = false; | |||
110 | * Set to false if a SYS_USB_DISCONNECTED event is seen */ | 102 | * Set to false if a SYS_USB_DISCONNECTED event is seen */ |
111 | bool is_usb_connected = false; | 103 | bool is_usb_connected = false; |
112 | 104 | ||
113 | void clearscreen(void) | ||
114 | { | ||
115 | init_lcd(); | ||
116 | lcd_clear_display(); | ||
117 | putversion(); | ||
118 | } | ||
119 | |||
120 | void putversion(void) | ||
121 | { | ||
122 | int x = (LCD_WIDTH - SYSFONT_WIDTH*strlen(rbversion)) / 2; | ||
123 | int y = LCD_HEIGHT - SYSFONT_HEIGHT; | ||
124 | lcd_putsxy(x, y, rbversion); | ||
125 | } | ||
126 | |||
127 | void putcenter_y(int y, const char* msg) | ||
128 | { | ||
129 | int x = (LCD_WIDTH - SYSFONT_WIDTH*strlen(msg)) / 2; | ||
130 | lcd_putsxy(x, y, msg); | ||
131 | } | ||
132 | |||
133 | void putcenter_line(int line, const char* msg) | ||
134 | { | ||
135 | int y = LCD_HEIGHT/2 + (line - 1)*SYSFONT_HEIGHT; | ||
136 | putcenter_y(y, msg); | ||
137 | } | ||
138 | |||
139 | void splash2(long delay, const char* msg, const char* msg2) | ||
140 | { | ||
141 | clearscreen(); | ||
142 | putcenter_line(0, msg); | ||
143 | if(msg2) | ||
144 | putcenter_line(1, msg2); | ||
145 | lcd_update(); | ||
146 | sleep(delay); | ||
147 | } | ||
148 | |||
149 | void splash(long delay, const char* msg) | ||
150 | { | ||
151 | splash2(delay, msg, NULL); | ||
152 | } | ||
153 | |||
154 | int get_button(int timeout) | ||
155 | { | ||
156 | int btn = button_get_w_tmo(timeout); | ||
157 | if(btn == SYS_USB_CONNECTED) | ||
158 | is_usb_connected = true; | ||
159 | else if(btn == SYS_USB_DISCONNECTED) | ||
160 | is_usb_connected = false; | ||
161 | |||
162 | return btn; | ||
163 | } | ||
164 | |||
165 | void init_lcd(void) | ||
166 | { | ||
167 | if(lcd_inited) | ||
168 | return; | ||
169 | |||
170 | lcd_init(); | ||
171 | font_init(); | ||
172 | lcd_setfont(FONT_SYSFIXED); | ||
173 | |||
174 | /* Clear screen before turning backlight on, otherwise we might | ||
175 | * display random garbage on the screen */ | ||
176 | lcd_clear_display(); | ||
177 | lcd_update(); | ||
178 | |||
179 | backlight_init(); | ||
180 | |||
181 | lcd_inited = true; | ||
182 | } | ||
183 | |||
184 | void init_usb(void) | 105 | void init_usb(void) |
185 | { | 106 | { |
186 | if(usb_inited) | 107 | if(usb_inited) |
@@ -314,8 +235,7 @@ void boot_rockbox(void) | |||
314 | return; | 235 | return; |
315 | } | 236 | } |
316 | 237 | ||
317 | if(lcd_inited) | 238 | gui_shutdown(); |
318 | backlight_hw_off(); | ||
319 | 239 | ||
320 | x1000_boot_rockbox(loadbuffer, rc); | 240 | x1000_boot_rockbox(loadbuffer, rc); |
321 | } | 241 | } |
diff --git a/bootloader/x1000/gui.c b/bootloader/x1000/gui.c new file mode 100644 index 0000000000..da20a9b128 --- /dev/null +++ b/bootloader/x1000/gui.c | |||
@@ -0,0 +1,113 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2021-2022 Aidan MacDonald | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "x1000bootloader.h" | ||
23 | #include "system.h" | ||
24 | #include "kernel.h" | ||
25 | #include "lcd.h" | ||
26 | #include "backlight.h" | ||
27 | #include "backlight-target.h" | ||
28 | #include "font.h" | ||
29 | #include "button.h" | ||
30 | #include "version.h" | ||
31 | #include <string.h> | ||
32 | |||
33 | static bool lcd_inited = false; | ||
34 | extern bool is_usb_connected; | ||
35 | |||
36 | void clearscreen(void) | ||
37 | { | ||
38 | init_lcd(); | ||
39 | lcd_clear_display(); | ||
40 | putversion(); | ||
41 | } | ||
42 | |||
43 | void putversion(void) | ||
44 | { | ||
45 | int x = (LCD_WIDTH - SYSFONT_WIDTH*strlen(rbversion)) / 2; | ||
46 | int y = LCD_HEIGHT - SYSFONT_HEIGHT; | ||
47 | lcd_putsxy(x, y, rbversion); | ||
48 | } | ||
49 | |||
50 | void putcenter_y(int y, const char* msg) | ||
51 | { | ||
52 | int x = (LCD_WIDTH - SYSFONT_WIDTH*strlen(msg)) / 2; | ||
53 | lcd_putsxy(x, y, msg); | ||
54 | } | ||
55 | |||
56 | void putcenter_line(int line, const char* msg) | ||
57 | { | ||
58 | int y = LCD_HEIGHT/2 + (line - 1)*SYSFONT_HEIGHT; | ||
59 | putcenter_y(y, msg); | ||
60 | } | ||
61 | |||
62 | void splash2(long delay, const char* msg, const char* msg2) | ||
63 | { | ||
64 | clearscreen(); | ||
65 | putcenter_line(0, msg); | ||
66 | if(msg2) | ||
67 | putcenter_line(1, msg2); | ||
68 | lcd_update(); | ||
69 | sleep(delay); | ||
70 | } | ||
71 | |||
72 | void splash(long delay, const char* msg) | ||
73 | { | ||
74 | splash2(delay, msg, NULL); | ||
75 | } | ||
76 | |||
77 | int get_button(int timeout) | ||
78 | { | ||
79 | int btn = button_get_w_tmo(timeout); | ||
80 | if(btn == SYS_USB_CONNECTED) | ||
81 | is_usb_connected = true; | ||
82 | else if(btn == SYS_USB_DISCONNECTED) | ||
83 | is_usb_connected = false; | ||
84 | |||
85 | return btn; | ||
86 | } | ||
87 | |||
88 | void init_lcd(void) | ||
89 | { | ||
90 | if(lcd_inited) | ||
91 | return; | ||
92 | |||
93 | lcd_init(); | ||
94 | font_init(); | ||
95 | lcd_setfont(FONT_SYSFIXED); | ||
96 | |||
97 | /* Clear screen before turning backlight on, otherwise we might | ||
98 | * display random garbage on the screen */ | ||
99 | lcd_clear_display(); | ||
100 | lcd_update(); | ||
101 | |||
102 | backlight_init(); | ||
103 | |||
104 | lcd_inited = true; | ||
105 | } | ||
106 | |||
107 | void gui_shutdown(void) | ||
108 | { | ||
109 | if(!lcd_inited) | ||
110 | return; | ||
111 | |||
112 | backlight_hw_off(); | ||
113 | } | ||
diff --git a/bootloader/x1000/x1000bootloader.h b/bootloader/x1000/x1000bootloader.h index 75303c3717..df891e54bb 100644 --- a/bootloader/x1000/x1000bootloader.h +++ b/bootloader/x1000/x1000bootloader.h | |||
@@ -61,4 +61,19 @@ | |||
61 | # error "Missing keymap!" | 61 | # error "Missing keymap!" |
62 | #endif | 62 | #endif |
63 | 63 | ||
64 | /* | ||
65 | * GUI stuff | ||
66 | */ | ||
67 | |||
68 | void clearscreen(void); | ||
69 | void putversion(void); | ||
70 | void putcenter_y(int y, const char* msg); | ||
71 | void putcenter_line(int line, const char* msg); | ||
72 | void splash2(long delay, const char* msg, const char* msg2); | ||
73 | void splash(long delay, const char* msg); | ||
74 | int get_button(int timeout); | ||
75 | void init_lcd(void); | ||
76 | |||
77 | void gui_shutdown(void); | ||
78 | |||
64 | #endif /* __X1000BOOTLOADER_H__ */ | 79 | #endif /* __X1000BOOTLOADER_H__ */ |