Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
Custom lcd color
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy-JL committed Aug 14, 2023
1 parent 6a618b6 commit cee43d5
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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, "");
}
6 changes: 6 additions & 0 deletions applications/main/xtreme_app/xtreme_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ XtremeApp* xtreme_app_alloc() {
view_dispatcher_add_view(
app->view_dispatcher, XtremeAppViewTextInput, text_input_get_view(app->text_input));

app->byte_input = byte_input_alloc();
view_dispatcher_add_view(
app->view_dispatcher, XtremeAppViewByteInput, byte_input_get_view(app->byte_input));

app->popup = popup_alloc();
view_dispatcher_add_view(app->view_dispatcher, XtremeAppViewPopup, popup_get_view(app->popup));

Expand Down Expand Up @@ -315,6 +319,8 @@ void xtreme_app_free(XtremeApp* app) {
submenu_free(app->submenu);
view_dispatcher_remove_view(app->view_dispatcher, XtremeAppViewTextInput);
text_input_free(app->text_input);
view_dispatcher_remove_view(app->view_dispatcher, XtremeAppViewByteInput);
byte_input_free(app->byte_input);
view_dispatcher_remove_view(app->view_dispatcher, XtremeAppViewPopup);
popup_free(app->popup);
view_dispatcher_remove_view(app->view_dispatcher, XtremeAppViewDialogEx);
Expand Down
4 changes: 4 additions & 0 deletions applications/main/xtreme_app/xtreme_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <gui/modules/variable_item_list.h>
#include <gui/modules/submenu.h>
#include <gui/modules/text_input.h>
#include <gui/modules/byte_input.h>
#include <gui/modules/popup.h>
#include <lib/toolbox/value_index.h>
#include <toolbox/stream/file_stream.h>
Expand Down Expand Up @@ -42,6 +43,7 @@ typedef struct {
VariableItemList* var_item_list;
Submenu* submenu;
TextInput* text_input;
ByteInput* byte_input;
Popup* popup;
DialogEx* dialog_ex;

Expand All @@ -57,6 +59,7 @@ typedef struct {
uint8_t subghz_hopper_index;
char subghz_freq_buffer[XTREME_SUBGHZ_FREQ_BUFFER_SIZE];
bool subghz_extend;
RgbColor lcd_color;
char device_name[FURI_HAL_VERSION_ARRAY_NAME_LENGTH];
int32_t dolphin_level;
int32_t dolphin_angry;
Expand All @@ -79,6 +82,7 @@ typedef enum {
XtremeAppViewVarItemList,
XtremeAppViewSubmenu,
XtremeAppViewTextInput,
XtremeAppViewByteInput,
XtremeAppViewPopup,
XtremeAppViewDialogEx,
} XtremeAppView;
Expand Down

0 comments on commit cee43d5

Please sign in to comment.