summaryrefslogtreecommitdiff
path: root/bootloader/x1000/gui.c
diff options
context:
space:
mode:
Diffstat (limited to 'bootloader/x1000/gui.c')
-rw-r--r--bootloader/x1000/gui.c113
1 files changed, 113 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
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}