diff --git a/.gitmodules b/.gitmodules index cf41ef5ccd..9fc603c93e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,10 @@ [submodule "applications/external"] path = applications/external url = https://github.com/Next-Flip/Momentum-Apps.git +[submodule "assets/protobuf"] + path = assets/protobuf + url = https://github.com/Next-Flip/flipperzero-protobuf.git + shallow = false [submodule "lib/mlib"] path = lib/mlib url = https://github.com/P-p-H-d/mlib.git @@ -10,10 +14,6 @@ [submodule "lib/nanopb"] path = lib/nanopb url = https://github.com/nanopb/nanopb.git -[submodule "assets/protobuf"] - path = assets/protobuf - url = https://github.com/flipperdevices/flipperzero-protobuf.git - shallow = false [submodule "lib/libusb_stm32"] path = lib/libusb_stm32 url = https://github.com/flipperdevices/libusb_stm32.git diff --git a/ChangeLog.md b/ChangeLog.md index 8319336ec0..4557fa46fe 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,7 @@ - +### Breaking Changes: +- VGM: Reworked color customization functionality over RPC (by @HaxSam & @Willy-JL) + - Better rainbow support, more responsive config, custom fore/back-ground + - If you used this, need to reflash your VGM and reconfigure the colors ### Added: - Sub-GHz: New Legrand doorbell protocol (by @user890104) @@ -7,6 +9,7 @@ ### Updated: - Apps: + - VGM Tool: Add new RGB VGM firmware to support Flipper FW changes (by @HaxSam) - Picopass: Add acknowledgements page (by @bettse) - Authenticator: Fix URL format (by @akopachov) - Many apps updated for new message queue (by @Willy-JL) @@ -17,5 +20,5 @@ - FBT: Consistent version/branch info, fix gitorigin (by @Willy-JL) - OFW: Accessor: disable expansion service on start (by @skotopes) - +### Removed: +- API: Removed `Rgb565Color` and `rgb565cmp()` since VGM colors use normal RGB colors now diff --git a/applications/external b/applications/external index d2432a5949..51063afd56 160000 --- a/applications/external +++ b/applications/external @@ -1 +1 @@ -Subproject commit d2432a594969755d51038254c6cc312dba783e77 +Subproject commit 51063afd5679030b7c0d967459b1c007cc79cfff diff --git a/applications/main/momentum_app/momentum_app.h b/applications/main/momentum_app/momentum_app.h index 905bea3299..8e5196f037 100644 --- a/applications/main/momentum_app/momentum_app.h +++ b/applications/main/momentum_app/momentum_app.h @@ -61,7 +61,7 @@ typedef struct { bool subghz_extend; bool subghz_bypass; RgbColor lcd_color; - Rgb565Color vgm_color; + RgbColor vgm_color; char device_name[FURI_HAL_VERSION_ARRAY_NAME_LENGTH]; int32_t dolphin_level; int32_t dolphin_angry; diff --git a/applications/main/momentum_app/scenes/momentum_app_scene_misc_screen.c b/applications/main/momentum_app/scenes/momentum_app_scene_misc_screen.c index 5ba8248be5..0f2e7def34 100644 --- a/applications/main/momentum_app/scenes/momentum_app_scene_misc_screen.c +++ b/applications/main/momentum_app/scenes/momentum_app_scene_misc_screen.c @@ -46,25 +46,25 @@ static const struct { RgbColor color; } lcd_colors[] = { // clang-format off - {"Off", {0, 0, 0}}, - {"Orange", {255, 69, 0}}, - {"Red", {255, 0, 0}}, - {"Maroon", {128, 0, 0}}, - {"Yellow", {255, 255, 0}}, - {"Olive", {128, 128, 0}}, - {"Lime", {0, 255, 0}}, - {"Green", {0, 128, 0}}, - {"Aqua", {0, 255, 127}}, - {"Cyan", {0, 210, 210}}, - {"Azure", {0, 127, 255}}, - {"Teal", {0, 128, 128}}, - {"Blue", {0, 0, 255}}, - {"Navy", {0, 0, 128}}, - {"Purple", {128, 0, 128}}, - {"Fuchsia", {255, 0, 255}}, - {"Pink", {173, 31, 173}}, - {"Brown", {165, 42, 42}}, - {"White", {255, 192, 203}}, + {"Off", {{0, 0, 0}}}, + {"Orange", {{255, 69, 0}}}, + {"Red", {{255, 0, 0}}}, + {"Maroon", {{128, 0, 0}}}, + {"Yellow", {{255, 255, 0}}}, + {"Olive", {{128, 128, 0}}}, + {"Lime", {{0, 255, 0}}}, + {"Green", {{0, 128, 0}}}, + {"Aqua", {{0, 255, 127}}}, + {"Cyan", {{0, 210, 210}}}, + {"Azure", {{0, 127, 255}}}, + {"Teal", {{0, 128, 128}}}, + {"Blue", {{0, 0, 255}}}, + {"Navy", {{0, 0, 128}}}, + {"Purple", {{128, 0, 128}}}, + {"Fuchsia", {{255, 0, 255}}}, + {"Pink", {{173, 31, 173}}}, + {"Brown", {{165, 42, 42}}}, + {"White", {{255, 192, 203}}}, // clang-format on }; static const size_t lcd_sz = COUNT_OF(lcd_colors); @@ -74,10 +74,6 @@ static void momentum_app_scene_misc_screen_lcd_color_changed(VariableItem* item, variable_item_set_current_value_text(item, lcd_colors[index].name); rgb_backlight_set_color(led, &lcd_colors[index].color); app->save_backlight = true; - if(momentum_settings.vgm_color_mode == VgmColorModeRgbBacklight) { - expansion_disable(app->expansion); - expansion_enable(app->expansion); - } } static void momentum_app_scene_misc_screen_lcd_color_0_changed(VariableItem* item) { momentum_app_scene_misc_screen_lcd_color_changed(item, 0); diff --git a/applications/main/momentum_app/scenes/momentum_app_scene_misc_screen_color.c b/applications/main/momentum_app/scenes/momentum_app_scene_misc_screen_color.c index bf78402756..a62dfa8884 100644 --- a/applications/main/momentum_app/scenes/momentum_app_scene_misc_screen_color.c +++ b/applications/main/momentum_app/scenes/momentum_app_scene_misc_screen_color.c @@ -43,10 +43,6 @@ bool momentum_app_scene_misc_screen_color_on_event(void* context, SceneManagerEv scene_manager_get_scene_state(app->scene_manager, MomentumAppSceneMiscScreenColor), &app->lcd_color); app->save_backlight = true; - if(momentum_settings.vgm_color_mode == VgmColorModeRgbBacklight) { - expansion_disable(app->expansion); - expansion_enable(app->expansion); - } scene_manager_previous_scene(app->scene_manager); break; default: diff --git a/applications/main/momentum_app/scenes/momentum_app_scene_misc_vgm.c b/applications/main/momentum_app/scenes/momentum_app_scene_misc_vgm.c index 4caf8247ae..7c41258b74 100644 --- a/applications/main/momentum_app/scenes/momentum_app_scene_misc_vgm.c +++ b/applications/main/momentum_app/scenes/momentum_app_scene_misc_vgm.c @@ -1,7 +1,6 @@ #include "../momentum_app.h" enum VarItemListIndex { - VarItemListIndexColors, VarItemListIndexForeground, VarItemListIndexBackground, }; @@ -11,78 +10,74 @@ void momentum_app_scene_misc_vgm_var_item_list_callback(void* context, uint32_t view_dispatcher_send_custom_event(app->view_dispatcher, index); } -const char* const colors_names[VgmColorModeCount] = { - "Default", - "Custom", - "Rainbow", - "RGB Backlight", -}; -static void momentum_app_scene_misc_vgm_colors_changed(VariableItem* item) { - MomentumApp* app = variable_item_get_context(item); - uint8_t index = variable_item_get_current_value_index(item); - variable_item_set_current_value_text(item, colors_names[index]); - momentum_settings.vgm_color_mode = index; - app->save_settings = true; - variable_item_set_locked( - variable_item_list_get(app->var_item_list, VarItemListIndexForeground), - index != VgmColorModeCustom, - NULL); - variable_item_set_locked( - variable_item_list_get(app->var_item_list, VarItemListIndexBackground), - index != VgmColorModeCustom, - NULL); - expansion_disable(app->expansion); - expansion_enable(app->expansion); -} - static const struct { char* name; - Rgb565Color color; + RgbColor color; } vgm_colors[] = { // clang-format off - {"Orange", {0xFC00}}, - {"Black", {0x0000}}, - {"Red", {0xF800}}, - {"Maroon", {0x8000}}, - {"Yellow", {0xFFE0}}, - {"Olive", {0x8400}}, - {"Lime", {0x07E0}}, - {"Green", {0x0400}}, - {"Aqua", {0x07EF}}, - {"Cyan", {0x069A}}, - {"Azure", {0x03FF}}, - {"Teal", {0x0410}}, - {"Blue", {0x001F}}, - {"Navy", {0x0010}}, - {"Purple", {0x8010}}, - {"Fuchsia", {0xF81F}}, - {"Pink", {0xA8F5}}, - {"Brown", {0xA145}}, - {"White", {0xFFFF}}, + {"Default", {{0, 0, 0}}}, + {"Rainbow", {{0, 0, 0}}}, + {"RgbMod", {{0, 0, 0}}}, + {"Black", {{0, 0, 0}}}, + {"Orange", {{255, 130, 0}}}, + {"Red", {{255, 0, 0}}}, + {"Maroon", {{128, 0, 0}}}, + {"Yellow", {{255, 255, 0}}}, + {"Olive", {{128, 128, 0}}}, + {"Lime", {{0, 255, 0}}}, + {"Green", {{0, 128, 0}}}, + {"Aqua", {{0, 255, 127}}}, + {"Cyan", {{0, 210, 210}}}, + {"Azure", {{0, 127, 255}}}, + {"Teal", {{0, 128, 128}}}, + {"Blue", {{0, 0, 255}}}, + {"Navy", {{0, 0, 128}}}, + {"Purple", {{128, 0, 128}}}, + {"Fuchsia", {{255, 0, 255}}}, + {"Pink", {{173, 31, 173}}}, + {"Brown", {{165, 42, 42}}}, + {"White", {{255, 192, 203}}}, // clang-format on }; + static const size_t vgm_colors_count = COUNT_OF(vgm_colors); + static void momentum_app_scene_misc_vgm_foreground_changed(VariableItem* item) { MomentumApp* app = variable_item_get_context(item); uint8_t index = variable_item_get_current_value_index(item); variable_item_set_current_value_text(item, vgm_colors[index].name); - momentum_settings.vgm_color_fg = vgm_colors[index].color; - app->save_settings = true; - if(momentum_settings.vgm_color_mode == VgmColorModeCustom) { - expansion_disable(app->expansion); - expansion_enable(app->expansion); + momentum_settings.rpc_color_fg.rgb = vgm_colors[index].color; + + if(strcmp("Default", vgm_colors[index].name) == 0) { + momentum_settings.rpc_color_fg.mode = ScreenColorModeDefault; + } else if(strcmp("Rainbow", vgm_colors[index].name) == 0) { + momentum_settings.rpc_color_fg.mode = ScreenColorModeRainbow; + } else if(strcmp("RgbMod", vgm_colors[index].name) == 0) { + momentum_settings.rpc_color_fg.mode = ScreenColorModeRgbBacklight; + } else { + momentum_settings.rpc_color_fg.mode = ScreenColorModeCustom; } + + app->save_settings = true; } + static void momentum_app_scene_misc_vgm_background_changed(VariableItem* item) { MomentumApp* app = variable_item_get_context(item); uint8_t index = variable_item_get_current_value_index(item); variable_item_set_current_value_text(item, vgm_colors[index].name); - momentum_settings.vgm_color_bg = vgm_colors[index].color; - app->save_settings = true; - if(momentum_settings.vgm_color_mode == VgmColorModeCustom) { - expansion_disable(app->expansion); - expansion_enable(app->expansion); + momentum_settings.rpc_color_bg.rgb = vgm_colors[index].color; + + if(strcmp("Default", vgm_colors[index].name) == 0) { + momentum_settings.rpc_color_bg.mode = ScreenColorModeDefault; + } else if(strcmp("Rainbow", vgm_colors[index].name) == 0) { + momentum_settings.rpc_color_bg.mode = ScreenColorModeRainbow; + } else if(strcmp("RgbMod", vgm_colors[index].name) == 0) { + momentum_settings.rpc_color_bg.mode = ScreenColorModeRgbBacklight; + } else { + momentum_settings.rpc_color_bg.mode = ScreenColorModeCustom; } + + app->save_settings = true; } void momentum_app_scene_misc_vgm_on_enter(void* context) { @@ -91,40 +86,38 @@ void momentum_app_scene_misc_vgm_on_enter(void* context) { VariableItem* item; uint8_t value_index; - item = variable_item_list_add( - var_item_list, - "VGM Colors", - VgmColorModeCount, - momentum_app_scene_misc_vgm_colors_changed, - app); - value_index = momentum_settings.vgm_color_mode; - variable_item_set_current_value_index(item, value_index); - variable_item_set_current_value_text(item, colors_names[value_index]); - item = variable_item_list_add( var_item_list, "Foreground", vgm_colors_count, momentum_app_scene_misc_vgm_foreground_changed, app); - Rgb565Color color = momentum_settings.vgm_color_fg; - bool found = false; - for(size_t i = 0; i < vgm_colors_count; i++) { - if(rgb565cmp(&color, &vgm_colors[i].color) != 0) continue; - value_index = i; - found = true; - break; + ScreenFrameColor color = momentum_settings.rpc_color_fg; + bool found = true; + if(color.mode == ScreenColorModeRainbow) { + value_index = 1; + } else if(color.mode == ScreenColorModeRgbBacklight) { + value_index = 2; + } else if(color.mode == ScreenColorModeCustom) { + found = false; + for(size_t i = 3; i < vgm_colors_count; i++) { + if(rgbcmp(&color.rgb, &vgm_colors[i].color) != 0) continue; + value_index = i; + found = true; + break; + } + } else { + value_index = 0; } - variable_item_set_current_value_index(item, found ? value_index : vgm_colors_count); + + variable_item_set_current_value_index(item, found ? value_index : 0); if(found) { variable_item_set_current_value_text(item, vgm_colors[value_index].name); } else { - char str[5]; - snprintf(str, sizeof(str), "%04X", color.value); + char str[7]; + snprintf(str, sizeof(str), "%02X%02X%02X", color.rgb.r, color.rgb.g, color.rgb.b); variable_item_set_current_value_text(item, str); } - variable_item_set_locked( - item, momentum_settings.vgm_color_mode != VgmColorModeCustom, "Need Custom\nColors!"); item = variable_item_list_add( var_item_list, @@ -132,24 +125,32 @@ void momentum_app_scene_misc_vgm_on_enter(void* context) { vgm_colors_count, momentum_app_scene_misc_vgm_background_changed, app); - color = momentum_settings.vgm_color_bg; - found = false; - for(size_t i = 0; i < vgm_colors_count; i++) { - if(rgb565cmp(&color, &vgm_colors[i].color) != 0) continue; - value_index = i; - found = true; - break; + color = momentum_settings.rpc_color_bg; + found = true; + if(color.mode == ScreenColorModeRainbow) { + value_index = 1; + } else if(color.mode == ScreenColorModeRgbBacklight) { + value_index = 2; + } else if(color.mode == ScreenColorModeCustom) { + found = false; + for(size_t i = 3; i < vgm_colors_count; i++) { + if(rgbcmp(&color.rgb, &vgm_colors[i].color) != 0) continue; + value_index = i; + found = true; + break; + } + } else { + value_index = 0; } - variable_item_set_current_value_index(item, found ? value_index : vgm_colors_count); + + variable_item_set_current_value_index(item, found ? value_index : 0); if(found) { variable_item_set_current_value_text(item, vgm_colors[value_index].name); } else { - char str[5]; - snprintf(str, sizeof(str), "%04X", color.value); + char str[7]; + snprintf(str, sizeof(str), "%02X%02X%02X", color.rgb.r, color.rgb.g, color.rgb.b); variable_item_set_current_value_text(item, str); } - variable_item_set_locked( - item, momentum_settings.vgm_color_mode != VgmColorModeCustom, "Need Custom\nColors!"); variable_item_list_set_enter_callback( var_item_list, momentum_app_scene_misc_vgm_var_item_list_callback, app); @@ -167,6 +168,7 @@ bool momentum_app_scene_misc_vgm_on_event(void* context, SceneManagerEvent event if(event.type == SceneManagerEventTypeCustom) { scene_manager_set_scene_state(app->scene_manager, MomentumAppSceneMiscVgm, event.event); consumed = true; + switch(event.event) { case VarItemListIndexForeground: case VarItemListIndexBackground: diff --git a/applications/main/momentum_app/scenes/momentum_app_scene_misc_vgm_color.c b/applications/main/momentum_app/scenes/momentum_app_scene_misc_vgm_color.c index 98ef4cf3ed..6ca50a7c63 100644 --- a/applications/main/momentum_app/scenes/momentum_app_scene_misc_vgm_color.c +++ b/applications/main/momentum_app/scenes/momentum_app_scene_misc_vgm_color.c @@ -14,14 +14,13 @@ void momentum_app_scene_misc_vgm_color_on_enter(void* context) { MomentumApp* app = context; ByteInput* byte_input = app->byte_input; - byte_input_set_header_text(byte_input, "Set VGM Color (RGB565)"); + byte_input_set_header_text(byte_input, "Set VGM Color (#RRGGBB)"); if(scene_manager_get_scene_state(app->scene_manager, MomentumAppSceneMiscVgmColor)) { - app->vgm_color = momentum_settings.vgm_color_bg; + app->vgm_color = momentum_settings.rpc_color_bg.rgb; } else { - app->vgm_color = momentum_settings.vgm_color_fg; + app->vgm_color = momentum_settings.rpc_color_fg.rgb; } - app->vgm_color.value = __REVSH(app->vgm_color.value); byte_input_set_result_callback( byte_input, @@ -42,17 +41,12 @@ bool momentum_app_scene_misc_vgm_color_on_event(void* context, SceneManagerEvent consumed = true; switch(event.event) { case ByteInputResultOk: - app->vgm_color.value = __REVSH(app->vgm_color.value); if(scene_manager_get_scene_state(app->scene_manager, MomentumAppSceneMiscVgmColor)) { - momentum_settings.vgm_color_bg = app->vgm_color; + momentum_settings.rpc_color_bg.rgb = app->vgm_color; } else { - momentum_settings.vgm_color_fg = app->vgm_color; + momentum_settings.rpc_color_fg.rgb = app->vgm_color; } app->save_settings = true; - if(momentum_settings.vgm_color_mode == VgmColorModeCustom) { - expansion_disable(app->expansion); - expansion_enable(app->expansion); - } scene_manager_previous_scene(app->scene_manager); break; default: diff --git a/applications/services/rpc/rpc_gui.c b/applications/services/rpc/rpc_gui.c index ee35265902..319abefe39 100644 --- a/applications/services/rpc/rpc_gui.c +++ b/applications/services/rpc/rpc_gui.c @@ -1,6 +1,8 @@ #include "rpc_i.h" #include #include +#include +#include #include #include @@ -97,6 +99,34 @@ static void rpc_system_gui_screen_stream_frame_callback( rpc_gui->transmit_frame->content.gui_screen_frame.orientation = rpc_system_gui_screen_orientation_map[orientation]; + if(momentum_settings.rpc_color_fg.mode == ScreenColorModeRgbBacklight) { + ScreenFrameColor fg_color; + if(rgb_backlight_get_rainbow_mode() == RGBBacklightRainbowModeOff) { + fg_color.mode = ScreenColorModeCustom; + rgb_backlight_get_color(0, &fg_color.rgb); + } else { + fg_color.mode = ScreenColorModeRainbow; + } + rpc_gui->transmit_frame->content.gui_screen_frame.fg_color = fg_color.value; + } else { + rpc_gui->transmit_frame->content.gui_screen_frame.fg_color = + momentum_settings.rpc_color_fg.value; + } + + if(momentum_settings.rpc_color_bg.mode == ScreenColorModeRgbBacklight) { + ScreenFrameColor bg_color; + if(rgb_backlight_get_rainbow_mode() == RGBBacklightRainbowModeOff) { + bg_color.mode = ScreenColorModeCustom; + rgb_backlight_get_color(0, &bg_color.rgb); + } else { + bg_color.mode = ScreenColorModeRainbow; + } + rpc_gui->transmit_frame->content.gui_screen_frame.bg_color = bg_color.value; + } else { + rpc_gui->transmit_frame->content.gui_screen_frame.bg_color = + momentum_settings.rpc_color_bg.value; + } + furi_thread_flags_set(furi_thread_get_id(rpc_gui->transmit_thread), RpcGuiWorkerFlagTransmit); } diff --git a/assets/protobuf b/assets/protobuf index 1956b83bba..fae8e0e9b9 160000 --- a/assets/protobuf +++ b/assets/protobuf @@ -1 +1 @@ -Subproject commit 1956b83bba99313ee8d8386e5d35d0549341ca26 +Subproject commit fae8e0e9b95895f10e97679fac779066794f197c diff --git a/lib/drivers/rgb_backlight.c b/lib/drivers/rgb_backlight.c index 56ccb5f33e..d57d2df0fc 100644 --- a/lib/drivers/rgb_backlight.c +++ b/lib/drivers/rgb_backlight.c @@ -35,9 +35,9 @@ static struct { } rgb_settings = { .colors = { - {255, 69, 0}, - {255, 69, 0}, - {255, 69, 0}, + {{255, 69, 0}}, + {{255, 69, 0}}, + {{255, 69, 0}}, }, .rainbow_mode = RGBBacklightRainbowModeOff, .rainbow_speed = 5, @@ -58,7 +58,7 @@ static struct { .enabled = false, .last_brightness = 0, .rainbow_timer = NULL, - .rainbow_hsv = {0, 255, 255}, + .rainbow_hsv = {{0, 255, 255}}, }; void rgb_backlight_load_settings(bool enabled) { diff --git a/lib/momentum/momentum.h b/lib/momentum/momentum.h index ea2c86cc46..ba87fb7503 100644 --- a/lib/momentum/momentum.h +++ b/lib/momentum/momentum.h @@ -46,12 +46,20 @@ typedef enum { } SpiHandle; typedef enum { - VgmColorModeDefault, - VgmColorModeCustom, - VgmColorModeRainbow, - VgmColorModeRgbBacklight, - VgmColorModeCount, -} VgmColorMode; + ScreenColorModeDefault, + ScreenColorModeCustom, + ScreenColorModeRainbow, + ScreenColorModeRgbBacklight, + ScreenColorModeCount, +} ScreenColorMode; + +typedef union __attribute__((packed)) { + struct { + ScreenColorMode mode; + RgbColor rgb; + }; + uint32_t value; +} ScreenFrameColor; typedef struct { char asset_pack[ASSET_PACKS_NAME_LEN]; @@ -87,10 +95,9 @@ typedef struct { FuriHalSerialId uart_esp_channel; FuriHalSerialId uart_nmea_channel; bool file_naming_prefix_after; - VgmColorMode vgm_color_mode; - Rgb565Color vgm_color_fg; - Rgb565Color vgm_color_bg; FuriHalVersionColor spoof_color; + ScreenFrameColor rpc_color_fg; + ScreenFrameColor rpc_color_bg; } MomentumSettings; typedef struct { diff --git a/lib/momentum/settings.c b/lib/momentum/settings.c index 0294a796f2..c8b6540c04 100644 --- a/lib/momentum/settings.c +++ b/lib/momentum/settings.c @@ -39,10 +39,9 @@ MomentumSettings momentum_settings = { .uart_esp_channel = FuriHalSerialIdUsart, // pin 13,14 .uart_nmea_channel = FuriHalSerialIdUsart, // pin 13,14 .file_naming_prefix_after = false, // Before - .vgm_color_mode = VgmColorModeDefault, // Default - .vgm_color_fg.value = 0x0000, // Default Black - .vgm_color_bg.value = 0xFC00, // Default Orange .spoof_color = FuriHalVersionColorUnknown, // Real + .rpc_color_fg = {{ScreenColorModeDefault, {.value = 0x000000}}}, // Default Black + .rpc_color_bg = {{ScreenColorModeDefault, {.value = 0xFF8200}}}, // Default Orange }; typedef enum { @@ -110,10 +109,9 @@ static const struct { {setting_enum(uart_esp_channel, FuriHalSerialIdMax)}, {setting_enum(uart_nmea_channel, FuriHalSerialIdMax)}, {setting_bool(file_naming_prefix_after)}, - {setting_enum(vgm_color_mode, VgmColorModeCount)}, - {setting_uint(vgm_color_fg, 0x0000, 0xFFFF)}, - {setting_uint(vgm_color_bg, 0x0000, 0xFFFF)}, {setting_enum(spoof_color, FuriHalVersionColorCount)}, + {setting_uint(rpc_color_fg, 0x000000, 0xFFFFFF)}, + {setting_uint(rpc_color_bg, 0x000000, 0xFFFFFF)}, }; void momentum_settings_load(void) { diff --git a/lib/toolbox/colors.c b/lib/toolbox/colors.c index d40cf89897..22f06ac681 100644 --- a/lib/toolbox/colors.c +++ b/lib/toolbox/colors.c @@ -86,7 +86,3 @@ void rgb2hsv(const RgbColor* rgb, HsvColor* hsv) { hsv->h = 171 + 43 * (rgb->r - rgb->g) / (rgbMax - rgbMin); } } - -inline int rgb565cmp(const Rgb565Color* a, const Rgb565Color* b) { - return memcmp(a, b, sizeof(Rgb565Color)); -} diff --git a/lib/toolbox/colors.h b/lib/toolbox/colors.h index c76af31baa..6369858c06 100644 --- a/lib/toolbox/colors.h +++ b/lib/toolbox/colors.h @@ -7,35 +7,33 @@ extern "C" { #endif -typedef struct { - uint8_t r; - uint8_t g; - uint8_t b; +typedef union __attribute__((packed)) { + struct { + uint8_t r; + uint8_t g; + uint8_t b; + }; + uint32_t value : 24; } RgbColor; -typedef struct { - uint8_t h; - uint8_t s; - uint8_t v; +typedef union __attribute__((packed)) { + struct { + uint8_t h; + uint8_t s; + uint8_t v; + }; + uint32_t value : 24; } HsvColor; +_Static_assert(sizeof(RgbColor) == 3, "RGB color must be 24-bit"); +_Static_assert(sizeof(HsvColor) == 3, "HSV color must be 24-bit"); + int rgbcmp(const RgbColor* a, const RgbColor* b); int hsvcmp(const HsvColor* a, const HsvColor* b); void hsv2rgb(const HsvColor* hsv, RgbColor* rgb); void rgb2hsv(const RgbColor* rgb, HsvColor* hsv); -typedef union { - uint16_t value; - struct { - uint16_t r : 5; - uint16_t g : 6; - uint16_t b : 5; - } FURI_PACKED; -} Rgb565Color; - -int rgb565cmp(const Rgb565Color* a, const Rgb565Color* b); - #ifdef __cplusplus } #endif diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index 806a1d9b67..e411729114 100644 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -3024,7 +3024,6 @@ Function,-,rename,int,"const char*, const char*" Function,-,renameat,int,"int, const char*, int, const char*" Function,-,rewind,void,FILE* Function,+,rgb2hsv,void,"const RgbColor*, HsvColor*" -Function,+,rgb565cmp,int,"const Rgb565Color*, const Rgb565Color*" Function,+,rgb_backlight_get_color,void,"uint8_t, RgbColor*" Function,+,rgb_backlight_get_rainbow_interval,uint32_t, Function,+,rgb_backlight_get_rainbow_mode,RGBBacklightRainbowMode, diff --git a/targets/f7/furi_hal/furi_hal_info.c b/targets/f7/furi_hal/furi_hal_info.c index 9b9298b78e..0548013e74 100644 --- a/targets/f7/furi_hal/furi_hal_info.c +++ b/targets/f7/furi_hal/furi_hal_info.c @@ -70,57 +70,6 @@ void furi_hal_info_get(PropertyValueCallback out, char sep, void* context) { property_value_out( &property_context, "%d", 2, "hardware", "color", furi_hal_version_get_hw_color()); - // RGB Settings - property_value_out( - &property_context, - "%d", - 4, - "hardware", - "screen", - "rgb", - "enabled", - momentum_settings.rgb_backlight); - for(int i = 0; i < SK6805_get_led_count(); i++) { - RgbColor rgb; - rgb_backlight_get_color(i, &rgb); - - uint32_t led_value = 0; - memcpy(((void*)&led_value) + 1, &rgb, sizeof(RgbColor)); - - char led_string[5] = {'l', 'e', 'd', '0' + i, '\0'}; - property_value_out( - &property_context, "%06X", 4, "hardware", "screen", "rgb", led_string, __REV(led_value)); - } - - // VGM Settings - property_value_out( - &property_context, - "%d", - 4, - "hardware", - "vgm", - "color", - "mode", - momentum_settings.vgm_color_mode); - property_value_out( - &property_context, - "%04X", - 4, - "hardware", - "vgm", - "color", - "fg", - momentum_settings.vgm_color_fg.value); - property_value_out( - &property_context, - "%04X", - 4, - "hardware", - "vgm", - "color", - "bg", - momentum_settings.vgm_color_bg.value); - if(sep == '.') { property_value_out( &property_context,