diff --git a/applications/main/momentum_app/momentum_app.h b/applications/main/momentum_app/momentum_app.h index 9511185d36..17ee99a347 100644 --- a/applications/main/momentum_app/momentum_app.h +++ b/applications/main/momentum_app/momentum_app.h @@ -60,7 +60,7 @@ typedef struct { char subghz_freq_buffer[7]; bool subghz_extend; 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 945a3c724f..031543b767 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 @@ -40,13 +40,13 @@ static const struct { char* name; RgbColor color; } lcd_colors[] = { - {"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}}}, }; static const size_t lcd_sz = COUNT_OF(lcd_colors); static void momentum_app_scene_misc_screen_lcd_color_changed(VariableItem* item, uint8_t led) { 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 4c6d9a65aa..a5148d52db 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 @@ -31,19 +31,19 @@ static void momentum_app_scene_misc_vgm_colors_changed(VariableItem* item) { 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[] = { - {"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}}, + {"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}}}, }; static const size_t vgm_colors_count = COUNT_OF(vgm_colors); static void momentum_app_scene_misc_vgm_foreground_changed(VariableItem* item) { @@ -52,10 +52,6 @@ static void momentum_app_scene_misc_vgm_foreground_changed(VariableItem* 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); - } } static void momentum_app_scene_misc_vgm_background_changed(VariableItem* item) { MomentumApp* app = variable_item_get_context(item); @@ -63,10 +59,6 @@ static void momentum_app_scene_misc_vgm_background_changed(VariableItem* 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); - } } void momentum_app_scene_misc_vgm_on_enter(void* context) { @@ -91,10 +83,10 @@ void momentum_app_scene_misc_vgm_on_enter(void* context) { vgm_colors_count, momentum_app_scene_misc_vgm_foreground_changed, app); - Rgb565Color color = momentum_settings.vgm_color_fg; + RgbColor 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; + if(rgbcmp(&color, &vgm_colors[i].color) != 0) continue; value_index = i; found = true; break; @@ -103,8 +95,8 @@ void momentum_app_scene_misc_vgm_on_enter(void* context) { 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), "%06X", color.value); variable_item_set_current_value_text(item, str); } variable_item_set_locked( @@ -119,7 +111,7 @@ void momentum_app_scene_misc_vgm_on_enter(void* context) { 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; + if(rgbcmp(&color, &vgm_colors[i].color) != 0) continue; value_index = i; found = true; break; @@ -128,8 +120,8 @@ void momentum_app_scene_misc_vgm_on_enter(void* context) { 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), "%06X", color.value); variable_item_set_current_value_text(item, str); } variable_item_set_locked( 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..f8941b2a00 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 @@ -49,10 +49,6 @@ bool momentum_app_scene_misc_vgm_color_on_event(void* context, SceneManagerEvent momentum_settings.vgm_color_fg = 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..b96ab84af2 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 "colors.h" #include #include @@ -97,6 +99,11 @@ 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]; + rpc_gui->transmit_frame->content.gui_screen_frame.fg_color = + momentum_settings.vgm_color_fg.value; + rpc_gui->transmit_frame->content.gui_screen_frame.bg_color = + momentum_settings.vgm_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..c9bbbfbaf8 160000 --- a/assets/protobuf +++ b/assets/protobuf @@ -1 +1 @@ -Subproject commit 1956b83bba99313ee8d8386e5d35d0549341ca26 +Subproject commit c9bbbfbaf82bb995ac42af8afbe1bdd4c6abdded diff --git a/lib/drivers/rgb_backlight.c b/lib/drivers/rgb_backlight.c index 0da1761fbe..81832f2b06 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 e2555c99c7..c2732c6a86 100644 --- a/lib/momentum/momentum.h +++ b/lib/momentum/momentum.h @@ -89,8 +89,8 @@ typedef struct { FuriHalSerialId uart_nmea_channel; bool file_naming_prefix_after; VgmColorMode vgm_color_mode; - Rgb565Color vgm_color_fg; - Rgb565Color vgm_color_bg; + RgbColor vgm_color_fg; + RgbColor vgm_color_bg; } MomentumSettings; typedef struct { diff --git a/lib/toolbox/colors.c b/lib/toolbox/colors.c index d40cf89897..d66380d1d8 100644 --- a/lib/toolbox/colors.c +++ b/lib/toolbox/colors.c @@ -2,6 +2,9 @@ #include "colors.h" +_Static_assert(sizeof(RgbColor) == 3, "RGB color must be 24-bit"); +_Static_assert(sizeof(HsvColor) == 3, "HSV color must be 24-bit"); + inline int rgbcmp(const RgbColor* a, const RgbColor* b) { return memcmp(a, b, sizeof(RgbColor)); } diff --git a/lib/toolbox/colors.h b/lib/toolbox/colors.h index c76af31baa..087cdda90a 100644 --- a/lib/toolbox/colors.h +++ b/lib/toolbox/colors.h @@ -7,16 +7,22 @@ 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; int rgbcmp(const RgbColor* a, const RgbColor* b); 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,