summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-03-04 18:48:51 +0000
committerAidan MacDonald <amachronic@protonmail.com>2022-03-12 18:25:10 +0000
commit6fb1b8b3421cd73657ac2a84b0b13b975926746f (patch)
tree4fed68c7ae76579d4f3a42a479c090de549c5768
parent8558255f45bb9d256bcd7bfb5b71e7bb382912a7 (diff)
downloadrockbox-6fb1b8b342.tar.gz
rockbox-6fb1b8b342.zip
x1000: bootloader: split off GUI code
Change-Id: If716cfd117c48da2cff221b8854630022bb0fe48
-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
show_logo.c
#elif defined(FIIO_M3K) || defined(SHANLING_Q1) || defined(EROS_QN)
x1000.c
+x1000/gui.c
#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 {
void(*action)(void);
};
-void clearscreen(void);
-void putversion(void);
-void putcenter_y(int y, const char* msg);
-void putcenter_line(int line, const char* msg);
-void splash2(long delay, const char* msg, const char* msg2);
-void splash(long delay, const char* msg);
-
void init_lcd(void);
void init_usb(void);
int init_disk(void);
@@ -102,7 +95,6 @@ const struct menuitem recovery_items[] = {
};
/* Flags to indicate if hardware was already initialized */
-bool lcd_inited = false;
bool usb_inited = false;
bool disk_inited = false;
@@ -110,77 +102,6 @@ bool disk_inited = false;
* Set to false if a SYS_USB_DISCONNECTED event is seen */
bool is_usb_connected = false;
-void clearscreen(void)
-{
- init_lcd();
- lcd_clear_display();
- putversion();
-}
-
-void putversion(void)
-{
- int x = (LCD_WIDTH - SYSFONT_WIDTH*strlen(rbversion)) / 2;
- int y = LCD_HEIGHT - SYSFONT_HEIGHT;
- lcd_putsxy(x, y, rbversion);
-}
-
-void putcenter_y(int y, const char* msg)
-{
- int x = (LCD_WIDTH - SYSFONT_WIDTH*strlen(msg)) / 2;
- lcd_putsxy(x, y, msg);
-}
-
-void putcenter_line(int line, const char* msg)
-{
- int y = LCD_HEIGHT/2 + (line - 1)*SYSFONT_HEIGHT;
- putcenter_y(y, msg);
-}
-
-void splash2(long delay, const char* msg, const char* msg2)
-{
- clearscreen();
- putcenter_line(0, msg);
- if(msg2)
- putcenter_line(1, msg2);
- lcd_update();
- sleep(delay);
-}
-
-void splash(long delay, const char* msg)
-{
- splash2(delay, msg, NULL);
-}
-
-int get_button(int timeout)
-{
- int btn = button_get_w_tmo(timeout);
- if(btn == SYS_USB_CONNECTED)
- is_usb_connected = true;
- else if(btn == SYS_USB_DISCONNECTED)
- is_usb_connected = false;
-
- return btn;
-}
-
-void init_lcd(void)
-{
- if(lcd_inited)
- return;
-
- lcd_init();
- font_init();
- lcd_setfont(FONT_SYSFIXED);
-
- /* Clear screen before turning backlight on, otherwise we might
- * display random garbage on the screen */
- lcd_clear_display();
- lcd_update();
-
- backlight_init();
-
- lcd_inited = true;
-}
-
void init_usb(void)
{
if(usb_inited)
@@ -314,8 +235,7 @@ void boot_rockbox(void)
return;
}
- if(lcd_inited)
- backlight_hw_off();
+ gui_shutdown();
x1000_boot_rockbox(loadbuffer, rc);
}
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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2021-2022 Aidan MacDonald
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "x1000bootloader.h"
+#include "system.h"
+#include "kernel.h"
+#include "lcd.h"
+#include "backlight.h"
+#include "backlight-target.h"
+#include "font.h"
+#include "button.h"
+#include "version.h"
+#include <string.h>
+
+static bool lcd_inited = false;
+extern bool is_usb_connected;
+
+void clearscreen(void)
+{
+ init_lcd();
+ lcd_clear_display();
+ putversion();
+}
+
+void putversion(void)
+{
+ int x = (LCD_WIDTH - SYSFONT_WIDTH*strlen(rbversion)) / 2;
+ int y = LCD_HEIGHT - SYSFONT_HEIGHT;
+ lcd_putsxy(x, y, rbversion);
+}
+
+void putcenter_y(int y, const char* msg)
+{
+ int x = (LCD_WIDTH - SYSFONT_WIDTH*strlen(msg)) / 2;
+ lcd_putsxy(x, y, msg);
+}
+
+void putcenter_line(int line, const char* msg)
+{
+ int y = LCD_HEIGHT/2 + (line - 1)*SYSFONT_HEIGHT;
+ putcenter_y(y, msg);
+}
+
+void splash2(long delay, const char* msg, const char* msg2)
+{
+ clearscreen();
+ putcenter_line(0, msg);
+ if(msg2)
+ putcenter_line(1, msg2);
+ lcd_update();
+ sleep(delay);
+}
+
+void splash(long delay, const char* msg)
+{
+ splash2(delay, msg, NULL);
+}
+
+int get_button(int timeout)
+{
+ int btn = button_get_w_tmo(timeout);
+ if(btn == SYS_USB_CONNECTED)
+ is_usb_connected = true;
+ else if(btn == SYS_USB_DISCONNECTED)
+ is_usb_connected = false;
+
+ return btn;
+}
+
+void init_lcd(void)
+{
+ if(lcd_inited)
+ return;
+
+ lcd_init();
+ font_init();
+ lcd_setfont(FONT_SYSFIXED);
+
+ /* Clear screen before turning backlight on, otherwise we might
+ * display random garbage on the screen */
+ lcd_clear_display();
+ lcd_update();
+
+ backlight_init();
+
+ lcd_inited = true;
+}
+
+void gui_shutdown(void)
+{
+ if(!lcd_inited)
+ return;
+
+ backlight_hw_off();
+}
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 @@
# error "Missing keymap!"
#endif
+/*
+ * GUI stuff
+ */
+
+void clearscreen(void);
+void putversion(void);
+void putcenter_y(int y, const char* msg);
+void putcenter_line(int line, const char* msg);
+void splash2(long delay, const char* msg, const char* msg2);
+void splash(long delay, const char* msg);
+int get_button(int timeout);
+void init_lcd(void);
+
+void gui_shutdown(void);
+
#endif /* __X1000BOOTLOADER_H__ */