1- #include "settings .h"
1+ #include "menu_settings .h"
22#include "bsp/display.h"
33#include "bsp/input.h"
4- #include "chakrapetchmedium.h"
54#include "common/display.h"
5+ #include "common/theme.h"
6+ #include "firmware_update.h"
67#include "freertos/idf_additions.h"
7- #include "gui_element_footer.h"
88#include "gui_menu.h"
99#include "gui_style.h"
1010#include "icons.h"
1111#include "menu/about.h"
1212#include "menu/menu_power_information.h"
1313#include "menu/message_dialog.h"
1414#include "menu/wifi.h"
15+ #include "menu_device_information.h"
16+ #include "menu_filebrowser.h"
1517#include "pax_gfx.h"
1618#include "pax_matrix.h"
1719#include "pax_types.h"
18- // #include "shapes/pax_misc.h"
19- #include "firmware_update.h"
20- #include "menu_device_information.h"
2120#include "radio_update.h"
2221#include "settings_clock.h"
2322
@@ -33,6 +32,15 @@ typedef enum {
3332 ACTION_POWER_INFORMATION ,
3433} menu_home_action_t ;
3534
35+ static void radio_update_v2 (void ) {
36+ char filename [260 ] = "" ;
37+ bool result =
38+ menu_filebrowser ("/sd" , (const char * []){"trf" }, 1 , filename , sizeof (filename ), "Select radio firmware" );
39+ if (result ) {
40+ radio_install (filename );
41+ }
42+ }
43+
3644static void execute_action (pax_buf_t * fb , menu_home_action_t action , gui_theme_t * theme ) {
3745 switch (action ) {
3846 case ACTION_WIFI :
@@ -47,11 +55,12 @@ static void execute_action(pax_buf_t* fb, menu_home_action_t action, gui_theme_t
4755 case ACTION_DEVICE_INFO :
4856 menu_device_information (fb , theme );
4957 break ;
50- case ACTION_ABOUT :
58+ case ACTION_ABOUT : {
5159 menu_about (fb , theme );
5260 break ;
61+ }
5362 case ACTION_RADIO_UPDATE :
54- radio_update ( fb , theme , "/sd/firmware/radio/esp-hosted.zz" , true, 1093760 );
63+ radio_update_v2 ( );
5564 break ;
5665 case ACTION_POWER_INFORMATION :
5766 menu_power_information ();
@@ -61,7 +70,10 @@ static void execute_action(pax_buf_t* fb, menu_home_action_t action, gui_theme_t
6170 }
6271}
6372
64- static void render (pax_buf_t * buffer , gui_theme_t * theme , menu_t * menu , pax_vec2_t position , bool partial , bool icons ) {
73+ static void render (menu_t * menu , pax_vec2_t position , bool partial , bool icons ) {
74+ pax_buf_t * buffer = display_get_buffer ();
75+ gui_theme_t * theme = get_theme ();
76+
6577 if (!partial || icons ) {
6678 render_base_screen_statusbar (
6779 buffer , theme , !partial , !partial || icons , !partial ,
@@ -73,7 +85,7 @@ static void render(pax_buf_t* buffer, gui_theme_t* theme, menu_t* menu, pax_vec2
7385 display_blit_buffer (buffer );
7486}
7587
76- void menu_settings (pax_buf_t * buffer , gui_theme_t * theme ) {
88+ void menu_settings (void ) {
7789 QueueHandle_t input_event_queue = NULL ;
7890 ESP_ERROR_CHECK (bsp_input_get_queue (& input_event_queue ));
7991
@@ -87,11 +99,14 @@ void menu_settings(pax_buf_t* buffer, gui_theme_t* theme) {
8799 menu_insert_item_icon (& menu , "Power information" , NULL , (void * )ACTION_POWER_INFORMATION , -1 ,
88100 get_icon (ICON_BATTERY_UNKNOWN ));
89101 menu_insert_item_icon (& menu , "About" , NULL , (void * )ACTION_ABOUT , -1 , get_icon (ICON_INFO ));
90- /*#if defined(CONFIG_BSP_TARGET_TANMATSU) || defined(CONFIG_BSP_TARGET_KONSOOL) || \
91- defined(CONFIG_BSP_TARGET_HACKERHOTEL_2026)
92- menu_insert_item_icon(&menu, "Update radio from SD card", NULL, (void*)ACTION_RADIO_UPDATE, -1,
93- get_icon(ICON_RELEASE_ALERT));
94- #endif*/
102+ #if defined(CONFIG_BSP_TARGET_TANMATSU ) || defined(CONFIG_BSP_TARGET_KONSOOL ) || \
103+ defined(CONFIG_BSP_TARGET_HACKERHOTEL_2026 )
104+ menu_insert_item_icon (& menu , "Install radio firmware from SD card" , NULL , (void * )ACTION_RADIO_UPDATE , -1 ,
105+ get_icon (ICON_RELEASE_ALERT ));
106+ #endif
107+
108+ pax_buf_t * buffer = display_get_buffer ();
109+ gui_theme_t * theme = get_theme ();
95110
96111 int header_height = theme -> header .height + (theme -> header .vertical_margin * 2 );
97112 int footer_height = theme -> footer .height + (theme -> footer .vertical_margin * 2 );
@@ -103,7 +118,7 @@ void menu_settings(pax_buf_t* buffer, gui_theme_t* theme) {
103118 .y1 = pax_buf_get_height (buffer ) - footer_height - theme -> menu .vertical_margin - theme -> menu .vertical_padding ,
104119 };
105120
106- render (buffer , theme , & menu , position , false, true);
121+ render (& menu , position , false, true);
107122 while (1 ) {
108123 bsp_input_event_t event ;
109124 if (xQueueReceive (input_event_queue , & event , pdMS_TO_TICKS (1000 )) == pdTRUE ) {
@@ -118,18 +133,18 @@ void menu_settings(pax_buf_t* buffer, gui_theme_t* theme) {
118133 return ;
119134 case BSP_INPUT_NAVIGATION_KEY_UP :
120135 menu_navigate_previous (& menu );
121- render (buffer , theme , & menu , position , true, false);
136+ render (& menu , position , true, false);
122137 break ;
123138 case BSP_INPUT_NAVIGATION_KEY_DOWN :
124139 menu_navigate_next (& menu );
125- render (buffer , theme , & menu , position , true, false);
140+ render (& menu , position , true, false);
126141 break ;
127142 case BSP_INPUT_NAVIGATION_KEY_RETURN :
128143 case BSP_INPUT_NAVIGATION_KEY_GAMEPAD_A :
129144 case BSP_INPUT_NAVIGATION_KEY_JOYSTICK_PRESS : {
130145 void * arg = menu_get_callback_args (& menu , menu_get_position (& menu ));
131146 execute_action (buffer , (menu_home_action_t )arg , theme );
132- render (buffer , theme , & menu , position , false, true);
147+ render (& menu , position , false, true);
133148 break ;
134149 }
135150 default :
@@ -142,7 +157,7 @@ void menu_settings(pax_buf_t* buffer, gui_theme_t* theme) {
142157 break ;
143158 }
144159 } else {
145- render (buffer , theme , & menu , position , true, true);
160+ render (& menu , position , true, true);
146161 }
147162 }
148163}
0 commit comments