summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bootloader/SOURCES1
-rw-r--r--bootloader/x1000.c82
-rw-r--r--bootloader/x1000/gui.c113
-rw-r--r--bootloader/x1000/x1000bootloader.h15
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
89show_logo.c 89show_logo.c
90#elif defined(FIIO_M3K) || defined(SHANLING_Q1) || defined(EROS_QN) 90#elif defined(FIIO_M3K) || defined(SHANLING_Q1) || defined(EROS_QN)
91x1000.c 91x1000.c
92x1000/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
70void clearscreen(void);
71void putversion(void);
72void putcenter_y(int y, const char* msg);
73void putcenter_line(int line, const char* msg);
74void splash2(long delay, const char* msg, const char* msg2);
75void splash(long delay, const char* msg);
76
77void init_lcd(void); 70void init_lcd(void);
78void init_usb(void); 71void init_usb(void);
79int init_disk(void); 72int 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 */
105bool lcd_inited = false;
106bool usb_inited = false; 98bool usb_inited = false;
107bool disk_inited = false; 99bool 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 */
111bool is_usb_connected = false; 103bool is_usb_connected = false;
112 104
113void clearscreen(void)
114{
115 init_lcd();
116 lcd_clear_display();
117 putversion();
118}
119
120void 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
127void 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
133void 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
139void 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
149void splash(long delay, const char* msg)
150{
151 splash2(delay, msg, NULL);
152}
153
154int 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
165void 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
184void init_usb(void) 105void 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
33static bool lcd_inited = false;
34extern bool is_usb_connected;
35
36void clearscreen(void)
37{
38 init_lcd();
39 lcd_clear_display();
40 putversion();
41}
42
43void 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
50void 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
56void 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
62void 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
72void splash(long delay, const char* msg)
73{
74 splash2(delay, msg, NULL);
75}
76
77int 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
88void 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
107void 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
68void clearscreen(void);
69void putversion(void);
70void putcenter_y(int y, const char* msg);
71void putcenter_line(int line, const char* msg);
72void splash2(long delay, const char* msg, const char* msg2);
73void splash(long delay, const char* msg);
74int get_button(int timeout);
75void init_lcd(void);
76
77void gui_shutdown(void);
78
64#endif /* __X1000BOOTLOADER_H__ */ 79#endif /* __X1000BOOTLOADER_H__ */