Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VGM/RPC: Rework custom colors, smoother config, better rainbow support #53

Merged
merged 18 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
11 changes: 7 additions & 4 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<!-- ### Breaking Changes:
- -->
### 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)
- FBT: New `SKIP_EXTERNAL` toggle and `EXTRA_EXT_APPS` config option (by @Willy-JL)

### 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)
Expand All @@ -17,5 +20,5 @@
- FBT: Consistent version/branch info, fix gitorigin (by @Willy-JL)
- OFW: Accessor: disable expansion service on start (by @skotopes)

<!-- ### Removed:
- -->
### Removed:
- API: Removed `Rgb565Color` and `rgb565cmp()` since VGM colors use normal RGB colors now
2 changes: 1 addition & 1 deletion applications/external
2 changes: 1 addition & 1 deletion applications/main/momentum_app/momentum_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
180 changes: 91 additions & 89 deletions applications/main/momentum_app/scenes/momentum_app_scene_misc_vgm.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "../momentum_app.h"

enum VarItemListIndex {
VarItemListIndexColors,
VarItemListIndexForeground,
VarItemListIndexBackground,
};
Expand All @@ -11,78 +10,74 @@ 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;
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);
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}},
{"Default", {{0, 0, 0}}},
{"Rainbow", {{0, 0, 0}}},
{"RgbMod", {{0, 0, 0}}},
Willy-JL marked this conversation as resolved.
Show resolved Hide resolved
{"Black", {{0, 0, 0}}},
{"Orange", {{255, 130, 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);

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;
app->save_settings = true;
if(momentum_settings.vgm_color_mode == VgmColorModeCustom) {
expansion_disable(app->expansion);
expansion_enable(app->expansion);
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;
}

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;
app->save_settings = true;
if(momentum_settings.vgm_color_mode == VgmColorModeCustom) {
expansion_disable(app->expansion);
expansion_enable(app->expansion);
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;
}

void momentum_app_scene_misc_vgm_on_enter(void* context) {
Expand All @@ -91,65 +86,71 @@ 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);
Rgb565Color 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;
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 = 3; 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[5];
snprintf(str, sizeof(str), "%04X", color.value);
char str[7];
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,
"Background",
vgm_colors_count,
momentum_app_scene_misc_vgm_background_changed,
app);
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;
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 = 3; 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[5];
snprintf(str, sizeof(str), "%04X", color.value);
char str[7];
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);
Expand All @@ -167,6 +168,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
Loading
Loading