diff options
Diffstat (limited to 'bootloader/x1000')
-rw-r--r-- | bootloader/x1000/gui.c | 113 | ||||
-rw-r--r-- | bootloader/x1000/x1000bootloader.h | 15 |
2 files changed, 128 insertions, 0 deletions
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__ */ |