Custom lcd color

This commit is contained in:
Willy-JL
2023-08-15 01:51:04 +02:00
parent 6a618b6e19
commit cee43d5b79
5 changed files with 70 additions and 0 deletions

View File

@@ -16,5 +16,6 @@ ADD_SCENE(xtreme_app, protocols_freqs_add, ProtocolsFreqsAdd)
ADD_SCENE(xtreme_app, protocols_gpio, ProtocolsGpio)
ADD_SCENE(xtreme_app, misc, Misc)
ADD_SCENE(xtreme_app, misc_screen, MiscScreen)
ADD_SCENE(xtreme_app, misc_screen_color, MiscScreenColor)
ADD_SCENE(xtreme_app, misc_dolphin, MiscDolphin)
ADD_SCENE(xtreme_app, misc_rename, MiscRename)

View File

@@ -248,6 +248,9 @@ bool xtreme_app_scene_misc_screen_on_event(void* context, SceneManagerEvent even
}
break;
}
case VarItemListIndexLcdColor:
scene_manager_next_scene(app->scene_manager, XtremeAppSceneMiscScreenColor);
break;
default:
break;
}

View File

@@ -0,0 +1,56 @@
#include "../xtreme_app.h"
enum ByteInputResult {
ByteInputResultOk,
};
void xtreme_app_scene_misc_screen_color_byte_input_callback(void* context) {
XtremeApp* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, ByteInputResultOk);
}
void xtreme_app_scene_misc_screen_color_on_enter(void* context) {
XtremeApp* app = context;
ByteInput* byte_input = app->byte_input;
byte_input_set_header_text(byte_input, "Set LCD Color (#RRGGBB)");
app->lcd_color = rgb_backlight_get_color();
byte_input_set_result_callback(
byte_input,
xtreme_app_scene_misc_screen_color_byte_input_callback,
NULL,
app,
(void*)&app->lcd_color,
sizeof(app->lcd_color));
view_dispatcher_switch_to_view(app->view_dispatcher, XtremeAppViewByteInput);
}
bool xtreme_app_scene_misc_screen_color_on_event(void* context, SceneManagerEvent event) {
XtremeApp* app = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
consumed = true;
switch(event.event) {
case ByteInputResultOk:
rgb_backlight_set_color(app->lcd_color);
app->save_backlight = true;
scene_manager_previous_scene(app->scene_manager);
break;
default:
break;
}
}
return consumed;
}
void xtreme_app_scene_misc_screen_color_on_exit(void* context) {
XtremeApp* app = context;
byte_input_set_result_callback(app->byte_input, NULL, NULL, NULL, NULL, 0);
byte_input_set_header_text(app->byte_input, "");
}