Skip to content

Commit

Permalink
Latest Release RM0308-1620-0.99.1-2f8b85d on PATREON - VGM RGB Mods
Browse files Browse the repository at this point in the history
  • Loading branch information
RogueMaster committed Mar 9, 2024
1 parent a9853be commit 93b532b
Show file tree
Hide file tree
Showing 12 changed files with 341 additions and 1 deletion.
1 change: 1 addition & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ This software is for experimental purposes only and is not meant for any illegal
- Updated: [JS Runner v1.0 (By nminaylov & DrZlo13)-OFW](https://github.com/flipperdevices/flipperzero-firmware/pull/3286) [Added ble beacon, math and keyboard to JavaScript API (By Spooks4576)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/commit/41bb09492400026be66ef5f8b78f506f21361f1d) [Many improvements (By Willy-JL)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/commit/9b00d0e37b304784cf8e0ac0bdabe6aa543a780e) [Some SubGHz support and Radio Device Loader module (By Sil333033) + Also BLE Beacon Improvements (By Willy-JL)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/commit/ed2716fb48f37a62cc3baf5c7fc8ee9a2864badc)
- Added: [FindMy Flipper v1.0 (By MatthewKuKanich)](https://github.com/MatthewKuKanich/FindMyFlipper)
- Updated: [BLE Spam v6.0 (By Willy-JL & ECTO-1A & Spooks4576 with research from xMasterX; OFW API thanks to noproto)](https://github.com/noproto/apple_ble_spam_ofw) [Added NameFlood option (By Willy-JL)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/commit/f2a6af257c8ce8e47181329c59a8a4e44e927c58) [Bug Fixes (By Willy-JL)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/commit/74d69fb623378395ed8407261c95453d12e59cd5)
- [VGM: Custom color options (By HaxSam & Willy-JL)]()

<a name="release">

Expand Down
2 changes: 2 additions & 0 deletions applications/settings/cfw_app/cfw_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ CfwApp* cfw_app_alloc() {
CfwApp* app = malloc(sizeof(CfwApp));
app->gui = furi_record_open(RECORD_GUI);
app->dialogs = furi_record_open(RECORD_DIALOGS);
app->expansion = furi_record_open(RECORD_EXPANSION);
app->notification = furi_record_open(RECORD_NOTIFICATION);

// View Dispatcher and Scene Manager
Expand Down Expand Up @@ -334,6 +335,7 @@ void cfw_app_free(CfwApp* app) {

// Records
furi_record_close(RECORD_NOTIFICATION);
furi_record_close(RECORD_EXPANSION);
furi_record_close(RECORD_DIALOGS);
furi_record_close(RECORD_GUI);
free(app);
Expand Down
3 changes: 3 additions & 0 deletions applications/settings/cfw_app/cfw_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <loader/loader_mainmenu.h>
#include <notification/notification_app.h>
#include <power/power_service/power.h>
#include <expansion/expansion.h>
#include <rgb_backlight.h>
#include <m-array.h>
#include <cfw/cfw.h>
Expand Down Expand Up @@ -62,6 +63,7 @@ static const struct {
typedef struct {
Gui* gui;
DialogsApp* dialogs;
Expansion* expansion;
NotificationApp* notification;
SceneManager* scene_manager;
ViewDispatcher* view_dispatcher;
Expand Down Expand Up @@ -95,6 +97,7 @@ typedef struct {
bool subghz_extend;
bool subghz_bypass;
RgbColor lcd_color;
Rgb565Color vgm_color;
char device_name[FURI_HAL_VERSION_ARRAY_NAME_LENGTH];
FuriString* version_tag;

Expand Down
2 changes: 2 additions & 0 deletions applications/settings/cfw_app/scenes/cfw_app_scene_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ ADD_SCENE(cfw_app, misc, Misc)
ADD_SCENE(cfw_app, misc_screen, MiscScreen)
ADD_SCENE(cfw_app, misc_screen_rgb_settings, MiscScreenRGBSettings)
ADD_SCENE(cfw_app, misc_screen_color, MiscScreenColor)
ADD_SCENE(cfw_app, misc_vgm, MiscVgm)
ADD_SCENE(cfw_app, misc_vgm_color, MiscVgmColor)
ADD_SCENE(cfw_app, misc_rename, MiscRename)
11 changes: 10 additions & 1 deletion applications/settings/cfw_app/scenes/cfw_app_scene_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

enum VarItemListIndex {
VarItemListIndexScreen,
VarItemListIndexVgm,
VarItemListIndexChangeDeviceName,
VarItemListIndexChargeCap,
};
Expand All @@ -28,7 +29,11 @@ void cfw_app_scene_misc_on_enter(void* context) {
VariableItem* item;
uint8_t value_index;

variable_item_list_add(var_item_list, "Screen", 0, NULL, app);
item = variable_item_list_add(var_item_list, "Screen", 0, NULL, app);
variable_item_set_current_value_text(item, ">");

item = variable_item_list_add(var_item_list, "VGM Options", 0, NULL, app);
variable_item_set_current_value_text(item, ">");

variable_item_list_add(var_item_list, "Change Device Name", 0, NULL, app);

Expand Down Expand Up @@ -65,6 +70,10 @@ bool cfw_app_scene_misc_on_event(void* context, SceneManagerEvent event) {
scene_manager_set_scene_state(app->scene_manager, CfwAppSceneMiscScreen, 0);
scene_manager_next_scene(app->scene_manager, CfwAppSceneMiscScreen);
break;
case VarItemListIndexVgm:
scene_manager_set_scene_state(app->scene_manager, CfwAppSceneMiscVgm, 0);
scene_manager_next_scene(app->scene_manager, CfwAppSceneMiscVgm);
break;
case VarItemListIndexChangeDeviceName:
scene_manager_set_scene_state(app->scene_manager, CfwAppSceneMiscRename, 0);
scene_manager_next_scene(app->scene_manager, CfwAppSceneMiscRename);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ static void cfw_app_scene_misc_screen_lcd_style_changed(VariableItem* item) {
}
app->save_backlight = true;
app->save_settings = true;
if(cfw_settings.vgm_color_mode == VgmColorModeRgbBacklight) {
expansion_disable(app->expansion);
expansion_enable(app->expansion);
}
}

void cfw_app_scene_misc_screen_on_enter(void* context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ bool cfw_app_scene_misc_screen_color_on_event(void* context, SceneManagerEvent e
rgb_backlight_set_color(2, &app->lcd_color);
notification_message(app->notification, &sequence_display_backlight_on);
app->save_backlight = true;
if(cfw_settings.vgm_color_mode == VgmColorModeRgbBacklight) {
expansion_disable(app->expansion);
expansion_enable(app->expansion);
}
break;
case 1:
notification_message(app->notification, &sequence_display_backlight_off);
Expand All @@ -55,6 +59,10 @@ bool cfw_app_scene_misc_screen_color_on_event(void* context, SceneManagerEvent e
&app->lcd_color);
notification_message(app->notification, &sequence_display_backlight_on);
app->save_backlight = true;
if(cfw_settings.vgm_color_mode == VgmColorModeRgbBacklight) {
expansion_disable(app->expansion);
expansion_enable(app->expansion);
}
break;
}
scene_manager_previous_scene(app->scene_manager);
Expand Down
169 changes: 169 additions & 0 deletions applications/settings/cfw_app/scenes/cfw_app_scene_misc_vgm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
#include "../cfw_app.h"

enum VarItemListIndex {
VarItemListIndexColors,
VarItemListIndexForeground,
VarItemListIndexBackground,
};

void cfw_app_scene_misc_vgm_var_item_list_callback(void* context, uint32_t index) {
CfwApp* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, index);
}

const char* const colors_names[VgmColorModeCount] = {
"Default",
"Custom",
"RGB Backlight",
};
static void cfw_app_scene_misc_vgm_colors_changed(VariableItem* item) {
CfwApp* 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]);
cfw_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;
} vgm_colors[] = {
{"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}},
};
static const size_t vgm_colors_count = COUNT_OF(vgm_colors);
static void cfw_app_scene_misc_vgm_foreground_changed(VariableItem* item) {
CfwApp* 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);
cfw_settings.vgm_color_fg = vgm_colors[index].color;
app->save_settings = true;
if(cfw_settings.vgm_color_mode == VgmColorModeCustom) {
expansion_disable(app->expansion);
expansion_enable(app->expansion);
}
}
static void cfw_app_scene_misc_vgm_background_changed(VariableItem* item) {
CfwApp* 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);
cfw_settings.vgm_color_bg = vgm_colors[index].color;
app->save_settings = true;
if(cfw_settings.vgm_color_mode == VgmColorModeCustom) {
expansion_disable(app->expansion);
expansion_enable(app->expansion);
}
}

void cfw_app_scene_misc_vgm_on_enter(void* context) {
CfwApp* app = context;
VariableItemList* var_item_list = app->var_item_list;
VariableItem* item;
uint8_t value_index;

item = variable_item_list_add(
var_item_list, "VGM Colors", VgmColorModeCount, cfw_app_scene_misc_vgm_colors_changed, app);
value_index = cfw_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,
cfw_app_scene_misc_vgm_foreground_changed,
app);
Rgb565Color color = cfw_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;
}
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);
} else {
char str[5];
snprintf(str, sizeof(str), "%04X", color.value);
variable_item_set_current_value_text(item, str);
}
variable_item_set_locked(
item, cfw_settings.vgm_color_mode != VgmColorModeCustom, "Need Custom\nColors!");

item = variable_item_list_add(
var_item_list,
"Background",
vgm_colors_count,
cfw_app_scene_misc_vgm_background_changed,
app);
color = cfw_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;
}
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);
} else {
char str[5];
snprintf(str, sizeof(str), "%04X", color.value);
variable_item_set_current_value_text(item, str);
}
variable_item_set_locked(
item, cfw_settings.vgm_color_mode != VgmColorModeCustom, "Need Custom\nColors!");

variable_item_list_set_enter_callback(
var_item_list, cfw_app_scene_misc_vgm_var_item_list_callback, app);

variable_item_list_set_selected_item(
var_item_list, scene_manager_get_scene_state(app->scene_manager, CfwAppSceneMiscVgm));

view_dispatcher_switch_to_view(app->view_dispatcher, CfwAppViewVarItemList);
}

bool cfw_app_scene_misc_vgm_on_event(void* context, SceneManagerEvent event) {
CfwApp* app = context;
bool consumed = false;

if(event.type == SceneManagerEventTypeCustom) {
scene_manager_set_scene_state(app->scene_manager, CfwAppSceneMiscVgm, event.event);
consumed = true;
switch(event.event) {
case VarItemListIndexForeground:
case VarItemListIndexBackground:
scene_manager_set_scene_state(
app->scene_manager,
CfwAppSceneMiscVgmColor,
event.event - VarItemListIndexForeground);
scene_manager_next_scene(app->scene_manager, CfwAppSceneMiscVgmColor);
break;
default:
break;
}
}

return consumed;
}

void cfw_app_scene_misc_vgm_on_exit(void* context) {
CfwApp* app = context;
variable_item_list_reset(app->var_item_list);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#include "../cfw_app.h"

enum ByteInputResult {
ByteInputResultOk,
};

void cfw_app_scene_misc_vgm_color_byte_input_callback(void* context) {
CfwApp* app = context;

view_dispatcher_send_custom_event(app->view_dispatcher, ByteInputResultOk);
}

void cfw_app_scene_misc_vgm_color_on_enter(void* context) {
CfwApp* app = context;
ByteInput* byte_input = app->byte_input;

byte_input_set_header_text(byte_input, "Set VGM Color (RGB565)");

if(scene_manager_get_scene_state(app->scene_manager, CfwAppSceneMiscVgmColor)) {
app->vgm_color = cfw_settings.vgm_color_bg;
} else {
app->vgm_color = cfw_settings.vgm_color_fg;
}
app->vgm_color.value = __REVSH(app->vgm_color.value);

byte_input_set_result_callback(
byte_input,
cfw_app_scene_misc_vgm_color_byte_input_callback,
NULL,
app,
(void*)&app->vgm_color,
sizeof(app->vgm_color));

view_dispatcher_switch_to_view(app->view_dispatcher, CfwAppViewByteInput);
}

bool cfw_app_scene_misc_vgm_color_on_event(void* context, SceneManagerEvent event) {
CfwApp* app = context;
bool consumed = false;

if(event.type == SceneManagerEventTypeCustom) {
consumed = true;
switch(event.event) {
case ByteInputResultOk:
app->vgm_color.value = __REVSH(app->vgm_color.value);
if(scene_manager_get_scene_state(app->scene_manager, CfwAppSceneMiscVgmColor)) {
cfw_settings.vgm_color_bg = app->vgm_color;
} else {
cfw_settings.vgm_color_fg = app->vgm_color;
}
app->save_settings = true;
if(cfw_settings.vgm_color_mode == VgmColorModeCustom) {
expansion_disable(app->expansion);
expansion_enable(app->expansion);
}
scene_manager_previous_scene(app->scene_manager);
break;
default:
break;
}
}

return consumed;
}

void cfw_app_scene_misc_vgm_color_on_exit(void* context) {
CfwApp* app = context;
byte_input_set_result_callback(app->byte_input, NULL, NULL, NULL, NULL, 0);
byte_input_set_header_text(app->byte_input, "");
}
11 changes: 11 additions & 0 deletions lib/cfw/cfw.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <stdint.h>
#include <stdbool.h>
#include <furi_hal_serial_types.h>
#include <toolbox/colors.h>
// #include <gui/icon_i.h>
// #include <power/power_service/power.h>

Expand Down Expand Up @@ -37,6 +38,13 @@ typedef enum {
SpiCount,
} SpiHandle;

typedef enum {
VgmColorModeDefault,
VgmColorModeCustom,
VgmColorModeRgbBacklight,
VgmColorModeCount,
} VgmColorMode;

typedef struct {
char* manifest_name;
MenuStyle menu_style;
Expand All @@ -52,6 +60,9 @@ typedef struct {
SpiHandle spi_nrf24_handle;
FuriHalSerialId uart_esp_channel;
FuriHalSerialId uart_nmea_channel;
VgmColorMode vgm_color_mode;
Rgb565Color vgm_color_fg;
Rgb565Color vgm_color_bg;
bool rgb_backlight;
uint32_t lcd_style;
} CfwSettings;
Expand Down
Loading

0 comments on commit 93b532b

Please sign in to comment.