Skip to content

Commit

Permalink
use all the 32bit
Browse files Browse the repository at this point in the history
	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
  • Loading branch information
HaxSam committed May 12, 2024
1 parent b6c0d3a commit b8a6ba7
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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}}},
Expand All @@ -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;
}

Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 4 additions & 2 deletions applications/services/rpc/rpc_gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 10 additions & 2 deletions lib/momentum/momentum.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
41 changes: 0 additions & 41 deletions lib/momentum/rpc_rgb.c
Original file line number Diff line number Diff line change
@@ -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;
}
15 changes: 0 additions & 15 deletions lib/momentum/rpc_rgb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b8a6ba7

Please sign in to comment.