Skip to content

Commit

Permalink
transmit VgmMode
Browse files Browse the repository at this point in the history
  • Loading branch information
HaxSam committed Mar 30, 2024
1 parent 113ed1f commit 31fba53
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 59 deletions.
4 changes: 2 additions & 2 deletions applications/services/rpc/rpc_gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
70 changes: 16 additions & 54 deletions lib/momentum/rpc_rgb.c
Original file line number Diff line number Diff line change
@@ -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;
}
14 changes: 11 additions & 3 deletions lib/momentum/rpc_rgb.h
Original file line number Diff line number Diff line change
@@ -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();

Expand Down

0 comments on commit 31fba53

Please sign in to comment.