From ed4268ceaa68eb42cbbe4c9f454274e809e2728c Mon Sep 17 00:00:00 2001 From: HaxSam Date: Mon, 18 Mar 2024 19:23:25 +0100 Subject: [PATCH 01/16] first poc works modified: applications/main/momentum_app/momentum_app.h modified: applications/main/momentum_app/scenes/momentum_app_scene_misc_screen.c modified: applications/main/momentum_app/scenes/momentum_app_scene_misc_vgm.c modified: applications/main/momentum_app/scenes/momentum_app_scene_misc_vgm_color.c modified: applications/services/rpc/rpc_gui.c modified: assets/protobuf modified: lib/drivers/rgb_backlight.c modified: lib/momentum/momentum.h modified: lib/toolbox/colors.c modified: lib/toolbox/colors.h modified: targets/f7/furi_hal/furi_hal_info.c modified: applications/external modified: applications/main/momentum_app/momentum_app.h modified: applications/main/momentum_app/scenes/momentum_app_scene_misc_screen.c modified: applications/main/momentum_app/scenes/momentum_app_scene_misc_vgm.c modified: applications/main/momentum_app/scenes/momentum_app_scene_misc_vgm_color.c modified: applications/services/rpc/rpc_gui.c modified: assets/protobuf modified: lib/drivers/rgb_backlight.c modified: lib/momentum/momentum.h modified: lib/toolbox/colors.c modified: lib/toolbox/colors.h modified: targets/f7/furi_hal/furi_hal_info.c --- applications/external | 2 +- applications/main/momentum_app/momentum_app.h | 2 +- .../scenes/momentum_app_scene_misc_screen.c | 38 +++++------ .../scenes/momentum_app_scene_misc_vgm.c | 64 ++++++++----------- .../momentum_app_scene_misc_vgm_color.c | 4 -- applications/services/rpc/rpc_gui.c | 7 ++ assets/protobuf | 2 +- lib/drivers/rgb_backlight.c | 8 +-- lib/momentum/momentum.h | 4 +- lib/toolbox/colors.c | 3 + lib/toolbox/colors.h | 22 ++++--- targets/f7/furi_hal/furi_hal_info.c | 51 --------------- 12 files changed, 79 insertions(+), 128 deletions(-) diff --git a/applications/external b/applications/external index 5dc4104f0c..3c0dd6c25a 160000 --- a/applications/external +++ b/applications/external @@ -1 +1 @@ -Subproject commit 5dc4104f0c62d0ed026cb10a3d65e54cbbe4b50a +Subproject commit 3c0dd6c25a8c546a78eea1c28abeceedd89c8131 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 10f5adda49..6de40d69fd 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 @@ -41,25 +41,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); 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..f52f4470eb 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,34 +31,32 @@ 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[] = { // 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}}, + {"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 vgm_colors_count = COUNT_OF(vgm_colors); @@ -68,10 +66,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); @@ -79,10 +73,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) { @@ -107,10 +97,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; @@ -119,8 +109,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( @@ -135,7 +125,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; @@ -144,8 +134,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 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..f595f2154f 100644 --- a/lib/momentum/momentum.h +++ b/lib/momentum/momentum.h @@ -88,9 +88,9 @@ typedef struct { FuriHalSerialId uart_nmea_channel; bool file_naming_prefix_after; VgmColorMode vgm_color_mode; - Rgb565Color vgm_color_fg; - Rgb565Color vgm_color_bg; FuriHalVersionColor spoof_color; + 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, From 2b318651f5d26926cafd7b9335761115eb28fee1 Mon Sep 17 00:00:00 2001 From: HaxSam Date: Mon, 25 Mar 2024 00:16:28 +0100 Subject: [PATCH 02/16] rainbow mode now works over rpc still not done refrash rate from flipper change and is slow so the rainbow mode doesnt look good modified: applications/main/momentum_app/scenes/momentum_app_scene_misc_vgm_color.c modified: applications/services/rpc/rpc_gui.c new file: lib/momentum/rpc_rgb.c new file: lib/momentum/rpc_rgb.h modified: lib/toolbox/colors.c modified: lib/toolbox/colors.h modified: targets/f7/api_symbols.csv --- .../momentum_app_scene_misc_vgm_color.c | 2 +- applications/services/rpc/rpc_gui.c | 9 +-- lib/momentum/rpc_rgb.c | 80 +++++++++++++++++++ lib/momentum/rpc_rgb.h | 18 +++++ lib/toolbox/colors.c | 29 ++++++- lib/toolbox/colors.h | 15 ++-- targets/f7/api_symbols.csv | 3 +- 7 files changed, 137 insertions(+), 19 deletions(-) create mode 100644 lib/momentum/rpc_rgb.c create mode 100644 lib/momentum/rpc_rgb.h 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 f8941b2a00..b9985db776 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,7 +14,7 @@ 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"); if(scene_manager_get_scene_state(app->scene_manager, MomentumAppSceneMiscVgmColor)) { app->vgm_color = momentum_settings.vgm_color_bg; diff --git a/applications/services/rpc/rpc_gui.c b/applications/services/rpc/rpc_gui.c index b96ab84af2..0a75856001 100644 --- a/applications/services/rpc/rpc_gui.c +++ b/applications/services/rpc/rpc_gui.c @@ -1,8 +1,7 @@ #include "rpc_i.h" #include #include -#include -#include "colors.h" +#include #include #include @@ -99,10 +98,8 @@ 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; + rpc_gui->transmit_frame->content.gui_screen_frame.fg_color = get_screen_color_fg().value; + rpc_gui->transmit_frame->content.gui_screen_frame.bg_color = get_screen_color_bg().value; furi_thread_flags_set(furi_thread_get_id(rpc_gui->transmit_thread), RpcGuiWorkerFlagTransmit); } diff --git a/lib/momentum/rpc_rgb.c b/lib/momentum/rpc_rgb.c new file mode 100644 index 0000000000..fc0f5e6823 --- /dev/null +++ b/lib/momentum/rpc_rgb.c @@ -0,0 +1,80 @@ +#include "rpc_rgb.h" + +#include "colors.h" +#include "momentum.h" +#include "drivers/rgb_backlight.h" + +static const RgbColor rainbow_colors[] = { + {{255, 0, 0}}, // Red + {{255, 130, 0}}, // Orange + {{255, 255, 0}}, // Yellow + {{0, 255, 0}}, // Green + {{0, 0, 255}}, // Blue + {{123, 0, 255}}, // Indigo + {{255, 0, 255}} // Violet +}; + +typedef struct { + uint8_t color; + uint8_t step; +} rgb_trans; + +static struct { + rgb_trans fg; + rgb_trans bg; +} state = { + .fg = {0, 0}, + .bg = {0, 0}, +}; + +RgbColor rainbow_step(rgb_trans* rgb) { + if(rgb->step >= 20) { + rgb->color = (rgb->color + 1) % 7; + rgb->step = 0; + } + + RgbColor color = interpolate_color( + &rainbow_colors[rgb->color], &rainbow_colors[(rgb->color + 1) % 7], rgb->step, 20); + rgb->step++; + + return color; +} + +RgbColor get_screen_color_fg() { + RgbColor color = {{0, 0, 0}}; + + switch(momentum_settings.vgm_color_mode) { + case VgmColorModeCustom: + color = momentum_settings.vgm_color_fg; + break; + case VgmColorModeRainbow: + //color = rainbow_step(&state.fg); + break; + case VgmColorModeRgbBacklight: + //rgb_backlight_get_color(0, &color); + break; + default: + break; + } + + return color; +} + +RgbColor get_screen_color_bg() { + RgbColor color = {{255, 130, 0}}; + switch(momentum_settings.vgm_color_mode) { + case VgmColorModeCustom: + color = momentum_settings.vgm_color_bg; + break; + case VgmColorModeRainbow: + color = rainbow_step(&state.bg); + break; + case VgmColorModeRgbBacklight: + rgb_backlight_get_color(0, &color); + break; + default: + break; + } + + return color; +} diff --git a/lib/momentum/rpc_rgb.h b/lib/momentum/rpc_rgb.h new file mode 100644 index 0000000000..c9095fc28e --- /dev/null +++ b/lib/momentum/rpc_rgb.h @@ -0,0 +1,18 @@ +#pragma once + +#include "colors.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void rpc_rgb_init(); + +RgbColor get_screen_color_fg(); +RgbColor get_screen_color_bg(); + +void rpc_rgb_deinit(); + +#ifdef __cplusplus +} +#endif diff --git a/lib/toolbox/colors.c b/lib/toolbox/colors.c index d66380d1d8..399977cd9e 100644 --- a/lib/toolbox/colors.c +++ b/lib/toolbox/colors.c @@ -90,6 +90,31 @@ void rgb2hsv(const RgbColor* rgb, HsvColor* hsv) { } } -inline int rgb565cmp(const Rgb565Color* a, const Rgb565Color* b) { - return memcmp(a, b, sizeof(Rgb565Color)); +RgbColor interpolate_color( + const RgbColor* colorStart, + const RgbColor* colorEnd, + uint8_t step, + uint8_t maxSteps) { + RgbColor color; + + if(step >= maxSteps) { + memcpy(&color, colorEnd, sizeof(RgbColor)); + return color; + } + + color.r = colorStart->r + (colorEnd->r - colorStart->r) * step / maxSteps; + color.g = colorStart->g + (colorEnd->g - colorStart->g) * step / maxSteps; + color.b = colorStart->b + (colorEnd->b - colorStart->b) * step / maxSteps; + + return color; +} + +RgbColor lerp_color(const RgbColor* colorStart, const RgbColor* colorEnd, double t) { + RgbColor color; + + color.r = colorStart->r * ((double)1.0 - t) + colorEnd->r * t; + color.g = colorStart->g * ((double)1.0 - t) + colorEnd->g * t; + color.b = colorStart->b * ((double)1.0 - t) + colorEnd->b * t; + + return color; } diff --git a/lib/toolbox/colors.h b/lib/toolbox/colors.h index 087cdda90a..3c8d0f7557 100644 --- a/lib/toolbox/colors.h +++ b/lib/toolbox/colors.h @@ -31,16 +31,13 @@ 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; +RgbColor interpolate_color( + const RgbColor* colorStart, + const RgbColor* colorEnd, + uint8_t step, + uint8_t maxSteps); -int rgb565cmp(const Rgb565Color* a, const Rgb565Color* b); +RgbColor lerp_color(const RgbColor* colorStart, const RgbColor* colorEnd, double t); #ifdef __cplusplus } diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index b8a825f0ec..2e19a7f920 100644 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -2064,6 +2064,7 @@ Function,+,infrared_worker_tx_stop,void,InfraredWorker* Function,-,initstate,char*,"unsigned, char*, size_t" Function,+,input_get_key_name,const char*,InputKey Function,+,input_get_type_name,const char*,InputType +Function,+,interpolate_color,RgbColor,"const RgbColor*, const RgbColor*, uint8_t, uint8_t" Function,-,iprintf,int,"const char*, ..." Function,-,isalnum,int,int Function,-,isalnum_l,int,"int, locale_t" @@ -2224,6 +2225,7 @@ Function,-,ldexp,double,"double, int" Function,-,ldexpf,float,"float, int" Function,-,ldexpl,long double,"long double, int" Function,-,ldiv,ldiv_t,"long, long" +Function,+,lerp_color,RgbColor,"const RgbColor*, const RgbColor*, double" Function,+,lfrfid_dict_file_load,ProtocolId,"ProtocolDict*, const char*" Function,+,lfrfid_dict_file_save,_Bool,"ProtocolDict*, ProtocolId, const char*" Function,+,lfrfid_raw_file_alloc,LFRFIDRawFile*,Storage* @@ -3002,7 +3004,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, From b6c0d3a4db1034d5eca080ff3989d5ecb700cb83 Mon Sep 17 00:00:00 2001 From: HaxSam Date: Sat, 30 Mar 2024 13:55:07 +0100 Subject: [PATCH 03/16] transmit VgmMode --- applications/services/rpc/rpc_gui.c | 4 +- lib/momentum/rpc_rgb.c | 70 +++++++---------------------- lib/momentum/rpc_rgb.h | 14 ++++-- 3 files changed, 29 insertions(+), 59 deletions(-) diff --git a/applications/services/rpc/rpc_gui.c b/applications/services/rpc/rpc_gui.c index 0a75856001..3ef2a0edaa 100644 --- a/applications/services/rpc/rpc_gui.c +++ b/applications/services/rpc/rpc_gui.c @@ -98,8 +98,8 @@ 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 = get_screen_color_fg().value; - rpc_gui->transmit_frame->content.gui_screen_frame.bg_color = get_screen_color_bg().value; + rpc_gui->transmit_frame->content.gui_screen_frame.fg_color = get_screen_color_fg(); + rpc_gui->transmit_frame->content.gui_screen_frame.bg_color = get_screen_color_bg(); furi_thread_flags_set(furi_thread_get_id(rpc_gui->transmit_thread), RpcGuiWorkerFlagTransmit); } diff --git a/lib/momentum/rpc_rgb.c b/lib/momentum/rpc_rgb.c index fc0f5e6823..24f6c8e1d3 100644 --- a/lib/momentum/rpc_rgb.c +++ b/lib/momentum/rpc_rgb.c @@ -1,80 +1,42 @@ #include "rpc_rgb.h" -#include "colors.h" -#include "momentum.h" #include "drivers/rgb_backlight.h" -static const RgbColor rainbow_colors[] = { - {{255, 0, 0}}, // Red - {{255, 130, 0}}, // Orange - {{255, 255, 0}}, // Yellow - {{0, 255, 0}}, // Green - {{0, 0, 255}}, // Blue - {{123, 0, 255}}, // Indigo - {{255, 0, 255}} // Violet -}; - -typedef struct { - uint8_t color; - uint8_t step; -} rgb_trans; - -static struct { - rgb_trans fg; - rgb_trans bg; -} state = { - .fg = {0, 0}, - .bg = {0, 0}, -}; - -RgbColor rainbow_step(rgb_trans* rgb) { - if(rgb->step >= 20) { - rgb->color = (rgb->color + 1) % 7; - rgb->step = 0; - } - - RgbColor color = interpolate_color( - &rainbow_colors[rgb->color], &rainbow_colors[(rgb->color + 1) % 7], rgb->step, 20); - rgb->step++; - - return color; -} - -RgbColor get_screen_color_fg() { - RgbColor color = {{0, 0, 0}}; +uint32_t get_screen_color_fg() { + RgbColorTransmit color = { + .mode = momentum_settings.vgm_color_mode, + .rgb = {{0, 0, 0}}, + }; switch(momentum_settings.vgm_color_mode) { case VgmColorModeCustom: - color = momentum_settings.vgm_color_fg; - break; - case VgmColorModeRainbow: - //color = rainbow_step(&state.fg); + color.rgb = momentum_settings.vgm_color_fg; break; case VgmColorModeRgbBacklight: - //rgb_backlight_get_color(0, &color); break; default: break; } - return color; + return color.value; } -RgbColor get_screen_color_bg() { - RgbColor color = {{255, 130, 0}}; +uint32_t get_screen_color_bg() { + RgbColorTransmit color = { + .mode = momentum_settings.vgm_color_mode, + .rgb = {{255, 130, 0}}, + }; + switch(momentum_settings.vgm_color_mode) { case VgmColorModeCustom: - color = momentum_settings.vgm_color_bg; - break; - case VgmColorModeRainbow: - color = rainbow_step(&state.bg); + color.rgb = momentum_settings.vgm_color_bg; break; case VgmColorModeRgbBacklight: - rgb_backlight_get_color(0, &color); + rgb_backlight_get_color(0, &color.rgb); break; default: break; } - return color; + return color.value; } diff --git a/lib/momentum/rpc_rgb.h b/lib/momentum/rpc_rgb.h index c9095fc28e..36a5897389 100644 --- a/lib/momentum/rpc_rgb.h +++ b/lib/momentum/rpc_rgb.h @@ -1,15 +1,23 @@ #pragma once -#include "colors.h" +#include "momentum.h" #ifdef __cplusplus extern "C" { #endif +typedef union __attribute__((packed)) { + struct { + VgmColorMode mode : 8; + RgbColor rgb; + }; + uint32_t value; +} RgbColorTransmit; + void rpc_rgb_init(); -RgbColor get_screen_color_fg(); -RgbColor get_screen_color_bg(); +uint32_t get_screen_color_fg(); +uint32_t get_screen_color_bg(); void rpc_rgb_deinit(); From b8a6ba70286d00500178b7560a049e7df0d14c2d Mon Sep 17 00:00:00 2001 From: HaxSam Date: Sat, 6 Apr 2024 17:19:42 +0200 Subject: [PATCH 04/16] use all the 32bit modified: applications/main/momentum_app/scenes/momentum_app_scene_misc_vgm.c modified: applications/services/rpc/rpc_gui.c modified: lib/momentum/momentum.h modified: lib/momentum/rpc_rgb.c modified: lib/momentum/rpc_rgb.h modified: applications/main/momentum_app/scenes/momentum_app_scene_misc_vgm.c modified: applications/services/rpc/rpc_gui.c modified: lib/momentum/momentum.h modified: lib/momentum/rpc_rgb.c modified: lib/momentum/rpc_rgb.h --- .../scenes/momentum_app_scene_misc_vgm.c | 43 +++++++++++++++++-- applications/services/rpc/rpc_gui.c | 6 ++- lib/momentum/momentum.h | 12 +++++- lib/momentum/rpc_rgb.c | 41 ------------------ lib/momentum/rpc_rgb.h | 15 ------- 5 files changed, 53 insertions(+), 64 deletions(-) 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 f52f4470eb..47e798864b 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 @@ -17,11 +17,18 @@ const char* const colors_names[VgmColorModeCount] = { "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; + + if(index == VgmColorModeDefault) { + momentum_settings.vgm_color_fg.mode = VgmColorModeDefault; + momentum_settings.vgm_color_bg.mode = VgmColorModeDefault; + } + app->save_settings = true; variable_item_set_locked( variable_item_list_get(app->var_item_list, VarItemListIndexForeground), @@ -39,6 +46,8 @@ static const struct { } vgm_colors[] = { // clang-format off {"Off", {{0, 0, 0}}}, + {"Rainbow", {{0, 0, 0}}}, + {"RgbMod", {{0, 0, 0}}}, {"Orange", {{255, 69, 0}}}, {"Red", {{255, 0, 0}}}, {"Maroon", {{128, 0, 0}}}, @@ -59,19 +68,40 @@ static const struct { {"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; + momentum_settings.vgm_color_fg.rgb = vgm_colors[index].color; + + if(strcmp("Rainbow", vgm_colors[index].name) == 0) { + momentum_settings.vgm_color_fg.mode = VgmColorModeRainbow; + } + if(strcmp("RgbMod", vgm_colors[index].name) == 0) { + momentum_settings.vgm_color_fg.mode = VgmColorModeRgbBacklight; + rgb_backlight_get_color(0, &momentum_settings.vgm_color_fg.rgb); + } + 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; + momentum_settings.vgm_color_bg.rgb = vgm_colors[index].color; + + if(strcmp("Rainbow", vgm_colors[index].name) == 0) { + momentum_settings.vgm_color_bg.mode = VgmColorModeRainbow; + } + if(strcmp("RgbMod", vgm_colors[index].name) == 0) { + momentum_settings.vgm_color_bg.mode = VgmColorModeRgbBacklight; + rgb_backlight_get_color(0, &momentum_settings.vgm_color_bg.rgb); + } + app->save_settings = true; } @@ -97,14 +127,16 @@ void momentum_app_scene_misc_vgm_on_enter(void* context) { vgm_colors_count, momentum_app_scene_misc_vgm_foreground_changed, app); - RgbColor color = momentum_settings.vgm_color_fg; + RgbColor color = momentum_settings.vgm_color_fg.rgb; bool found = false; + for(size_t i = 0; i < vgm_colors_count; i++) { if(rgbcmp(&color, &vgm_colors[i].color) != 0) continue; value_index = i; found = true; break; } + variable_item_set_current_value_index(item, found ? value_index : vgm_colors_count); if(found) { variable_item_set_current_value_text(item, vgm_colors[value_index].name); @@ -122,14 +154,16 @@ 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; + color = momentum_settings.vgm_color_bg.rgb; found = false; + for(size_t i = 0; i < vgm_colors_count; i++) { if(rgbcmp(&color, &vgm_colors[i].color) != 0) continue; value_index = i; found = true; break; } + variable_item_set_current_value_index(item, found ? value_index : vgm_colors_count); if(found) { variable_item_set_current_value_text(item, vgm_colors[value_index].name); @@ -157,6 +191,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/services/rpc/rpc_gui.c b/applications/services/rpc/rpc_gui.c index 3ef2a0edaa..513e6141dd 100644 --- a/applications/services/rpc/rpc_gui.c +++ b/applications/services/rpc/rpc_gui.c @@ -98,8 +98,10 @@ 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 = get_screen_color_fg(); - rpc_gui->transmit_frame->content.gui_screen_frame.bg_color = get_screen_color_bg(); + 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/lib/momentum/momentum.h b/lib/momentum/momentum.h index f595f2154f..f8d943f8e3 100644 --- a/lib/momentum/momentum.h +++ b/lib/momentum/momentum.h @@ -53,6 +53,14 @@ typedef enum { VgmColorModeCount, } VgmColorMode; +typedef union __attribute__((packed)) { + struct { + VgmColorMode mode; + RgbColor rgb; + }; + uint32_t value; +} RgbColorTransmit; + typedef struct { char asset_pack[ASSET_PACKS_NAME_LEN]; uint32_t anim_speed; @@ -89,8 +97,8 @@ typedef struct { bool file_naming_prefix_after; VgmColorMode vgm_color_mode; FuriHalVersionColor spoof_color; - RgbColor vgm_color_fg; - RgbColor vgm_color_bg; + RgbColorTransmit vgm_color_fg; + RgbColorTransmit vgm_color_bg; } MomentumSettings; typedef struct { diff --git a/lib/momentum/rpc_rgb.c b/lib/momentum/rpc_rgb.c index 24f6c8e1d3..80089c2bac 100644 --- a/lib/momentum/rpc_rgb.c +++ b/lib/momentum/rpc_rgb.c @@ -1,42 +1 @@ #include "rpc_rgb.h" - -#include "drivers/rgb_backlight.h" - -uint32_t get_screen_color_fg() { - RgbColorTransmit color = { - .mode = momentum_settings.vgm_color_mode, - .rgb = {{0, 0, 0}}, - }; - - switch(momentum_settings.vgm_color_mode) { - case VgmColorModeCustom: - color.rgb = momentum_settings.vgm_color_fg; - break; - case VgmColorModeRgbBacklight: - break; - default: - break; - } - - return color.value; -} - -uint32_t get_screen_color_bg() { - RgbColorTransmit color = { - .mode = momentum_settings.vgm_color_mode, - .rgb = {{255, 130, 0}}, - }; - - switch(momentum_settings.vgm_color_mode) { - case VgmColorModeCustom: - color.rgb = momentum_settings.vgm_color_bg; - break; - case VgmColorModeRgbBacklight: - rgb_backlight_get_color(0, &color.rgb); - break; - default: - break; - } - - return color.value; -} diff --git a/lib/momentum/rpc_rgb.h b/lib/momentum/rpc_rgb.h index 36a5897389..eda1bfe259 100644 --- a/lib/momentum/rpc_rgb.h +++ b/lib/momentum/rpc_rgb.h @@ -6,21 +6,6 @@ extern "C" { #endif -typedef union __attribute__((packed)) { - struct { - VgmColorMode mode : 8; - RgbColor rgb; - }; - uint32_t value; -} RgbColorTransmit; - -void rpc_rgb_init(); - -uint32_t get_screen_color_fg(); -uint32_t get_screen_color_bg(); - -void rpc_rgb_deinit(); - #ifdef __cplusplus } #endif From 482eebcf676e9535a6724b9adb374e4fa2a2c04b Mon Sep 17 00:00:00 2001 From: HaxSam Date: Sun, 12 May 2024 13:53:48 +0200 Subject: [PATCH 05/16] some config stuff --- .../momentum_app/scenes/momentum_app_scene_misc_vgm.c | 2 ++ .../scenes/momentum_app_scene_misc_vgm_color.c | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) 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 47e798864b..8303874827 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 @@ -76,6 +76,7 @@ static void momentum_app_scene_misc_vgm_foreground_changed(VariableItem* 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.rgb = vgm_colors[index].color; + momentum_settings.vgm_color_fg.mode = VgmColorModeCustom; if(strcmp("Rainbow", vgm_colors[index].name) == 0) { momentum_settings.vgm_color_fg.mode = VgmColorModeRainbow; @@ -93,6 +94,7 @@ static void momentum_app_scene_misc_vgm_background_changed(VariableItem* 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.rgb = vgm_colors[index].color; + momentum_settings.vgm_color_bg.mode = VgmColorModeCustom; if(strcmp("Rainbow", vgm_colors[index].name) == 0) { momentum_settings.vgm_color_bg.mode = VgmColorModeRainbow; 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 b9985db776..6cdcb1ab28 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 @@ -17,9 +17,9 @@ void momentum_app_scene_misc_vgm_color_on_enter(void* context) { byte_input_set_header_text(byte_input, "Set VGM Color"); if(scene_manager_get_scene_state(app->scene_manager, MomentumAppSceneMiscVgmColor)) { - app->vgm_color = momentum_settings.vgm_color_bg; + app->vgm_color = momentum_settings.vgm_color_bg.rgb; } else { - app->vgm_color = momentum_settings.vgm_color_fg; + app->vgm_color = momentum_settings.vgm_color_fg.rgb; } app->vgm_color.value = __REVSH(app->vgm_color.value); @@ -44,9 +44,9 @@ bool momentum_app_scene_misc_vgm_color_on_event(void* context, SceneManagerEvent 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.vgm_color_bg.rgb = app->vgm_color; } else { - momentum_settings.vgm_color_fg = app->vgm_color; + momentum_settings.vgm_color_fg.rgb = app->vgm_color; } app->save_settings = true; scene_manager_previous_scene(app->scene_manager); From 600cde76fc9a033d39abfc2a16ef8cd7730fd0b4 Mon Sep 17 00:00:00 2001 From: HaxSam Date: Sun, 12 May 2024 14:19:17 +0200 Subject: [PATCH 06/16] sync apps --- applications/external | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/external b/applications/external index 3c0dd6c25a..5dc4104f0c 160000 --- a/applications/external +++ b/applications/external @@ -1 +1 @@ -Subproject commit 3c0dd6c25a8c546a78eea1c28abeceedd89c8131 +Subproject commit 5dc4104f0c62d0ed026cb10a3d65e54cbbe4b50a From 6284da1d0a7d6fa74fd9c5eb2dd5d67458c8ebf7 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sun, 2 Jun 2024 04:12:16 +0100 Subject: [PATCH 07/16] Change protobuf repo --- .gitmodules | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 From 477675762be3b7374ee2bb3835318462479392db Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sun, 2 Jun 2024 04:17:12 +0100 Subject: [PATCH 08/16] Some lib naming changes and cleanup --- applications/services/rpc/rpc_gui.c | 4 ++-- lib/momentum/momentum.h | 21 ++++++++++----------- lib/momentum/rpc_rgb.c | 1 - lib/momentum/rpc_rgb.h | 11 ----------- lib/momentum/settings.c | 5 ++--- 5 files changed, 14 insertions(+), 28 deletions(-) delete mode 100644 lib/momentum/rpc_rgb.c delete mode 100644 lib/momentum/rpc_rgb.h diff --git a/applications/services/rpc/rpc_gui.c b/applications/services/rpc/rpc_gui.c index 513e6141dd..e03d4a6fd7 100644 --- a/applications/services/rpc/rpc_gui.c +++ b/applications/services/rpc/rpc_gui.c @@ -99,9 +99,9 @@ static void rpc_system_gui_screen_stream_frame_callback( rpc_system_gui_screen_orientation_map[orientation]; rpc_gui->transmit_frame->content.gui_screen_frame.fg_color = - momentum_settings.vgm_color_fg.value; + momentum_settings.rpc_color_fg.value; rpc_gui->transmit_frame->content.gui_screen_frame.bg_color = - momentum_settings.vgm_color_bg.value; + momentum_settings.rpc_color_bg.value; furi_thread_flags_set(furi_thread_get_id(rpc_gui->transmit_thread), RpcGuiWorkerFlagTransmit); } diff --git a/lib/momentum/momentum.h b/lib/momentum/momentum.h index f8d943f8e3..ba87fb7503 100644 --- a/lib/momentum/momentum.h +++ b/lib/momentum/momentum.h @@ -46,20 +46,20 @@ typedef enum { } SpiHandle; typedef enum { - VgmColorModeDefault, - VgmColorModeCustom, - VgmColorModeRainbow, - VgmColorModeRgbBacklight, - VgmColorModeCount, -} VgmColorMode; + ScreenColorModeDefault, + ScreenColorModeCustom, + ScreenColorModeRainbow, + ScreenColorModeRgbBacklight, + ScreenColorModeCount, +} ScreenColorMode; typedef union __attribute__((packed)) { struct { - VgmColorMode mode; + ScreenColorMode mode; RgbColor rgb; }; uint32_t value; -} RgbColorTransmit; +} ScreenFrameColor; typedef struct { char asset_pack[ASSET_PACKS_NAME_LEN]; @@ -95,10 +95,9 @@ typedef struct { FuriHalSerialId uart_esp_channel; FuriHalSerialId uart_nmea_channel; bool file_naming_prefix_after; - VgmColorMode vgm_color_mode; FuriHalVersionColor spoof_color; - RgbColorTransmit vgm_color_fg; - RgbColorTransmit vgm_color_bg; + ScreenFrameColor rpc_color_fg; + ScreenFrameColor rpc_color_bg; } MomentumSettings; typedef struct { diff --git a/lib/momentum/rpc_rgb.c b/lib/momentum/rpc_rgb.c deleted file mode 100644 index 80089c2bac..0000000000 --- a/lib/momentum/rpc_rgb.c +++ /dev/null @@ -1 +0,0 @@ -#include "rpc_rgb.h" diff --git a/lib/momentum/rpc_rgb.h b/lib/momentum/rpc_rgb.h deleted file mode 100644 index eda1bfe259..0000000000 --- a/lib/momentum/rpc_rgb.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "momentum.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif diff --git a/lib/momentum/settings.c b/lib/momentum/settings.c index 0294a796f2..63951975a8 100644 --- a/lib/momentum/settings.c +++ b/lib/momentum/settings.c @@ -110,10 +110,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) { From 8546834f0126a802225a77d37b93b8bc3995d0dc Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sun, 2 Jun 2024 05:03:20 +0100 Subject: [PATCH 09/16] Format protobuf --- assets/protobuf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/protobuf b/assets/protobuf index c9bbbfbaf8..fae8e0e9b9 160000 --- a/assets/protobuf +++ b/assets/protobuf @@ -1 +1 @@ -Subproject commit c9bbbfbaf82bb995ac42af8afbe1bdd4c6abdded +Subproject commit fae8e0e9b95895f10e97679fac779066794f197c From b063125806e9a485af0d5c024271f3b00c5862ee Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sun, 2 Jun 2024 06:55:32 +0100 Subject: [PATCH 10/16] Update from RGB backlight if enabled --- applications/services/rpc/rpc_gui.c | 34 ++++++++++++++++++++++++----- lib/momentum/settings.c | 5 ++--- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/applications/services/rpc/rpc_gui.c b/applications/services/rpc/rpc_gui.c index e03d4a6fd7..319abefe39 100644 --- a/applications/services/rpc/rpc_gui.c +++ b/applications/services/rpc/rpc_gui.c @@ -1,7 +1,8 @@ #include "rpc_i.h" #include #include -#include +#include +#include #include #include @@ -98,10 +99,33 @@ 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.rpc_color_fg.value; - rpc_gui->transmit_frame->content.gui_screen_frame.bg_color = - momentum_settings.rpc_color_bg.value; + 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/lib/momentum/settings.c b/lib/momentum/settings.c index 63951975a8..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 { From 11a41411e9b6844824b5f2548b89a5814b501536 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sun, 2 Jun 2024 07:26:38 +0100 Subject: [PATCH 11/16] Remove old expansion toggling --- .../main/momentum_app/scenes/momentum_app_scene_misc_screen.c | 4 ---- .../scenes/momentum_app_scene_misc_screen_color.c | 4 ---- 2 files changed, 8 deletions(-) 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 57f41783c4..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 @@ -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: From ec1505a5d83f0e54ea1f02bbb212b4f3006d6a2a Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sun, 2 Jun 2024 07:41:22 +0100 Subject: [PATCH 12/16] Update settings UI --- .../scenes/momentum_app_scene_misc_vgm.c | 143 ++++++++---------- .../momentum_app_scene_misc_vgm_color.c | 12 +- 2 files changed, 64 insertions(+), 91 deletions(-) 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 8303874827..dc8368ffdb 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,44 +10,16 @@ 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; - - if(index == VgmColorModeDefault) { - momentum_settings.vgm_color_fg.mode = VgmColorModeDefault; - momentum_settings.vgm_color_bg.mode = VgmColorModeDefault; - } - - 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); -} - static const struct { char* name; RgbColor color; } vgm_colors[] = { // clang-format off - {"Off", {{0, 0, 0}}}, + {"Default", {{0, 0, 0}}}, {"Rainbow", {{0, 0, 0}}}, {"RgbMod", {{0, 0, 0}}}, - {"Orange", {{255, 69, 0}}}, + {"Black", {{0, 0, 0}}}, + {"Orange", {{255, 130, 0}}}, {"Red", {{255, 0, 0}}}, {"Maroon", {{128, 0, 0}}}, {"Yellow", {{255, 255, 0}}}, @@ -75,15 +46,16 @@ 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.rgb = vgm_colors[index].color; - momentum_settings.vgm_color_fg.mode = VgmColorModeCustom; - - if(strcmp("Rainbow", vgm_colors[index].name) == 0) { - momentum_settings.vgm_color_fg.mode = VgmColorModeRainbow; - } - if(strcmp("RgbMod", vgm_colors[index].name) == 0) { - momentum_settings.vgm_color_fg.mode = VgmColorModeRgbBacklight; - rgb_backlight_get_color(0, &momentum_settings.vgm_color_fg.rgb); + 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; @@ -93,15 +65,16 @@ 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.rgb = vgm_colors[index].color; - momentum_settings.vgm_color_bg.mode = VgmColorModeCustom; - - if(strcmp("Rainbow", vgm_colors[index].name) == 0) { - momentum_settings.vgm_color_bg.mode = VgmColorModeRainbow; - } - if(strcmp("RgbMod", vgm_colors[index].name) == 0) { - momentum_settings.vgm_color_bg.mode = VgmColorModeRgbBacklight; - rgb_backlight_get_color(0, &momentum_settings.vgm_color_bg.rgb); + 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; @@ -113,42 +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); - RgbColor color = momentum_settings.vgm_color_fg.rgb; - bool found = false; - - for(size_t i = 0; i < vgm_colors_count; i++) { - if(rgbcmp(&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 = 0; 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[7]; - snprintf(str, sizeof(str), "%06X", color.value); + 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, @@ -156,26 +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.rgb; - found = false; - - for(size_t i = 0; i < vgm_colors_count; i++) { - if(rgbcmp(&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 = 0; 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[7]; - snprintf(str, sizeof(str), "%06X", color.value); + 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); 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 6cdcb1ab28..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"); + 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.rgb; + app->vgm_color = momentum_settings.rpc_color_bg.rgb; } else { - app->vgm_color = momentum_settings.vgm_color_fg.rgb; + 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,11 +41,10 @@ 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.rgb = app->vgm_color; + momentum_settings.rpc_color_bg.rgb = app->vgm_color; } else { - momentum_settings.vgm_color_fg.rgb = app->vgm_color; + momentum_settings.rpc_color_fg.rgb = app->vgm_color; } app->save_settings = true; scene_manager_previous_scene(app->scene_manager); From 480bbe42f2b7c749bc4a210c3b93469cf3024a0d Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sun, 2 Jun 2024 07:46:06 +0100 Subject: [PATCH 13/16] Fix searching previous value --- .../main/momentum_app/scenes/momentum_app_scene_misc_vgm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 dc8368ffdb..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 @@ -100,7 +100,7 @@ void momentum_app_scene_misc_vgm_on_enter(void* context) { value_index = 2; } else if(color.mode == ScreenColorModeCustom) { found = false; - for(size_t i = 0; i < vgm_colors_count; i++) { + 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; @@ -133,7 +133,7 @@ void momentum_app_scene_misc_vgm_on_enter(void* context) { value_index = 2; } else if(color.mode == ScreenColorModeCustom) { found = false; - for(size_t i = 0; i < vgm_colors_count; i++) { + 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; From 7076a75b73df7b41687e63cf7708bf05792a791f Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sun, 2 Jun 2024 07:46:41 +0100 Subject: [PATCH 14/16] VGM Tool: Add new RGB firmware --- applications/external | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 9ddcd09e655b0f52e43d0b855f4a27b2024bc679 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sun, 2 Jun 2024 07:47:22 +0100 Subject: [PATCH 15/16] Update changelog --- ChangeLog.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 From eea54b856d83c7c6a27a1b08bc934f2bf9a64fd6 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sun, 2 Jun 2024 08:30:44 +0100 Subject: [PATCH 16/16] These are unused --- lib/toolbox/colors.c | 32 -------------------------------- lib/toolbox/colors.h | 11 +++-------- targets/f7/api_symbols.csv | 2 -- 3 files changed, 3 insertions(+), 42 deletions(-) diff --git a/lib/toolbox/colors.c b/lib/toolbox/colors.c index 399977cd9e..22f06ac681 100644 --- a/lib/toolbox/colors.c +++ b/lib/toolbox/colors.c @@ -2,9 +2,6 @@ #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)); } @@ -89,32 +86,3 @@ void rgb2hsv(const RgbColor* rgb, HsvColor* hsv) { hsv->h = 171 + 43 * (rgb->r - rgb->g) / (rgbMax - rgbMin); } } - -RgbColor interpolate_color( - const RgbColor* colorStart, - const RgbColor* colorEnd, - uint8_t step, - uint8_t maxSteps) { - RgbColor color; - - if(step >= maxSteps) { - memcpy(&color, colorEnd, sizeof(RgbColor)); - return color; - } - - color.r = colorStart->r + (colorEnd->r - colorStart->r) * step / maxSteps; - color.g = colorStart->g + (colorEnd->g - colorStart->g) * step / maxSteps; - color.b = colorStart->b + (colorEnd->b - colorStart->b) * step / maxSteps; - - return color; -} - -RgbColor lerp_color(const RgbColor* colorStart, const RgbColor* colorEnd, double t) { - RgbColor color; - - color.r = colorStart->r * ((double)1.0 - t) + colorEnd->r * t; - color.g = colorStart->g * ((double)1.0 - t) + colorEnd->g * t; - color.b = colorStart->b * ((double)1.0 - t) + colorEnd->b * t; - - return color; -} diff --git a/lib/toolbox/colors.h b/lib/toolbox/colors.h index 3c8d0f7557..6369858c06 100644 --- a/lib/toolbox/colors.h +++ b/lib/toolbox/colors.h @@ -25,20 +25,15 @@ typedef union __attribute__((packed)) { 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); -RgbColor interpolate_color( - const RgbColor* colorStart, - const RgbColor* colorEnd, - uint8_t step, - uint8_t maxSteps); - -RgbColor lerp_color(const RgbColor* colorStart, const RgbColor* colorEnd, double t); - #ifdef __cplusplus } #endif diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index ef70b64f49..e411729114 100644 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -2080,7 +2080,6 @@ Function,+,infrared_worker_tx_stop,void,InfraredWorker* Function,-,initstate,char*,"unsigned, char*, size_t" Function,+,input_get_key_name,const char*,InputKey Function,+,input_get_type_name,const char*,InputType -Function,+,interpolate_color,RgbColor,"const RgbColor*, const RgbColor*, uint8_t, uint8_t" Function,-,iprintf,int,"const char*, ..." Function,-,isalnum,int,int Function,-,isalnum_l,int,"int, locale_t" @@ -2241,7 +2240,6 @@ Function,-,ldexp,double,"double, int" Function,-,ldexpf,float,"float, int" Function,-,ldexpl,long double,"long double, int" Function,-,ldiv,ldiv_t,"long, long" -Function,+,lerp_color,RgbColor,"const RgbColor*, const RgbColor*, double" Function,+,lfrfid_dict_file_load,ProtocolId,"ProtocolDict*, const char*" Function,+,lfrfid_dict_file_save,_Bool,"ProtocolDict*, ProtocolId, const char*" Function,+,lfrfid_raw_file_alloc,LFRFIDRawFile*,Storage*