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
  • Loading branch information
HaxSam committed Apr 24, 2024
1 parent 81914e7 commit 312a5f6
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 71 deletions.
55 changes: 44 additions & 11 deletions applications/main/momentum_app/scenes/momentum_app_scene_misc_vgm.c
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 @@ -37,27 +44,48 @@ static const struct {
char* name;
RgbColor color;
} vgm_colors[] = {
{"Off", {{0, 0, 0}}}, {"Orange", {{255, 130, 0}}}, {"Red", {{255, 0, 0}}},
{"Maroon", {{176, 48, 96}}}, {"Yellow", {{255, 255, 0}}}, {"Olive", {{128, 128, 0}}},
{"Lime", {{0, 255, 0}}}, {"Green", {{74, 255, 0}}}, {"Aqua", {{0, 255, 255}}},
{"Cyan", {{0, 255, 255}}}, {"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", {{150, 75, 0}}},
{"White", {{255, 255, 255}}},
{"Off", {{0, 0, 0}}}, {"Rainbow", {{0, 0, 0}}}, {"RgbMod", {{0, 0, 0}}},
{"Orange", {{255, 130, 0}}}, {"Red", {{255, 0, 0}}}, {"Maroon", {{176, 48, 96}}},
{"Yellow", {{255, 255, 0}}}, {"Olive", {{128, 128, 0}}}, {"Lime", {{0, 255, 0}}},
{"Green", {{74, 255, 0}}}, {"Aqua", {{0, 255, 255}}}, {"Cyan", {{0, 255, 255}}},
{"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", {{150, 75, 0}}}, {"White", {{255, 255, 255}}},
};

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 @@ -83,14 +111,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 @@ -108,14 +138,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 @@ -143,6 +175,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 312a5f6

Please sign in to comment.