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();