1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-12 12:42:30 +04:00

Сombining rgb_backlight and original_backlight finished.

- RGB Colors settings available only when Settings-Notification-RGB_MOD_Installed swithed ON
- RGB_MOD_Installed switch (ON|OFF) available in Notification only with Debug mode swithed ON.
This commit is contained in:
Dmitry422
2025-03-01 22:55:25 +07:00
parent 3c7d9e63fb
commit bb170140e2
3 changed files with 67 additions and 29 deletions

View File

@@ -523,6 +523,7 @@ static NotificationApp* notification_app_alloc(void) {
app->settings.led_brightness = 1.0f; app->settings.led_brightness = 1.0f;
app->settings.display_off_delay_ms = 30000; app->settings.display_off_delay_ms = 30000;
app->settings.vibro_on = true; app->settings.vibro_on = true;
app->settings.rgb_mod_installed = false;
app->display.value[LayerInternal] = 0x00; app->display.value[LayerInternal] = 0x00;
app->display.value[LayerNotification] = 0x00; app->display.value[LayerNotification] = 0x00;

View File

@@ -33,7 +33,7 @@ typedef struct {
Light light; Light light;
} NotificationLedLayer; } NotificationLedLayer;
#define NOTIFICATION_SETTINGS_VERSION 0x02 #define NOTIFICATION_SETTINGS_VERSION 0x03
#define NOTIFICATION_SETTINGS_PATH INT_PATH(NOTIFICATION_SETTINGS_FILE_NAME) #define NOTIFICATION_SETTINGS_PATH INT_PATH(NOTIFICATION_SETTINGS_FILE_NAME)
typedef struct { typedef struct {
@@ -44,6 +44,7 @@ typedef struct {
uint32_t display_off_delay_ms; uint32_t display_off_delay_ms;
int8_t contrast; int8_t contrast;
bool vibro_on; bool vibro_on;
bool rgb_mod_installed;
} NotificationSettings; } NotificationSettings;
struct NotificationApp { struct NotificationApp {

View File

@@ -1,4 +1,5 @@
#include <furi.h> #include <furi.h>
#include <furi_hal_rtc.h>
#include <notification/notification_app.h> #include <notification/notification_app.h>
#include <gui/modules/variable_item_list.h> #include <gui/modules/variable_item_list.h>
#include <gui/view_dispatcher.h> #include <gui/view_dispatcher.h>
@@ -107,6 +108,13 @@ const char* const vibro_text[VIBRO_COUNT] = {
}; };
const bool vibro_value[VIBRO_COUNT] = {false, true}; const bool vibro_value[VIBRO_COUNT] = {false, true};
#define RGB_MOD_COUNT 2
const char* const rgb_mod_text[RGB_MOD_COUNT] = {
"OFF",
"ON",
};
const bool rgb_mod_value[RGB_MOD_COUNT] = {false, true};
static void contrast_changed(VariableItem* item) { static void contrast_changed(VariableItem* item) {
NotificationAppSettings* app = variable_item_get_context(item); NotificationAppSettings* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item); uint8_t index = variable_item_get_current_value_index(item);
@@ -171,6 +179,13 @@ static void vibro_changed(VariableItem* item) {
notification_message(app->notification, &sequence_single_vibro); notification_message(app->notification, &sequence_single_vibro);
} }
static void rgb_mod_installed_changed(VariableItem* item) {
NotificationAppSettings* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, rgb_mod_text[index]);
app->notification->settings.rgb_mod_installed = rgb_mod_value[index];
}
// Set RGB backlight color // Set RGB backlight color
static void color_changed(VariableItem* item) { static void color_changed(VariableItem* item) {
NotificationAppSettings* app = variable_item_get_context(item); NotificationAppSettings* app = variable_item_get_context(item);
@@ -248,38 +263,59 @@ static NotificationAppSettings* alloc_settings(void) {
variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, contrast_text[value_index]); variable_item_set_current_value_text(item, contrast_text[value_index]);
// RGB Colors // Show RGB_MOD_Installed_Swith only in Debug mode
item = variable_item_list_add( if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
app->variable_item_list, "LCD Color", rgb_backlight_get_color_count(), color_changed, app); item = variable_item_list_add(
value_index = rgb_backlight_get_settings()->display_color_index; app->variable_item_list,
variable_item_set_current_value_index(item, value_index); "RGB MOD Installed",
variable_item_set_current_value_text(item, rgb_backlight_get_color_text(value_index)); RGB_MOD_COUNT,
temp_item = item; rgb_mod_installed_changed,
app);
value_index = value_index_bool(
app->notification->settings.rgb_mod_installed, rgb_mod_value, RGB_MOD_COUNT);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, rgb_mod_text[value_index]);
}
// Custom Color - REFACTOR THIS //Show RGB settings only when debug mode enabled or rgb_mod_installed is true
item = variable_item_list_add( if((furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) ||
app->variable_item_list, "Custom Red", 255, color_set_custom_red, app); (app->notification->settings.rgb_mod_installed)) {
value_index = rgb_backlight_get_settings()->custom_r; // RGB Colors
variable_item_set_current_value_index(item, value_index); item = variable_item_list_add(
char valtext[4] = {}; app->variable_item_list,
snprintf(valtext, sizeof(valtext), "%d", value_index); "LCD Color",
variable_item_set_current_value_text(item, valtext); rgb_backlight_get_color_count(),
color_changed,
app);
value_index = rgb_backlight_get_settings()->display_color_index;
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, rgb_backlight_get_color_text(value_index));
temp_item = item;
item = variable_item_list_add( // Custom Color - REFACTOR THIS
app->variable_item_list, "Custom Green", 255, color_set_custom_green, app); item = variable_item_list_add(
value_index = rgb_backlight_get_settings()->custom_g; app->variable_item_list, "Custom Red", 255, color_set_custom_red, app);
variable_item_set_current_value_index(item, value_index); value_index = rgb_backlight_get_settings()->custom_r;
snprintf(valtext, sizeof(valtext), "%d", value_index); variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, valtext); char valtext[4] = {};
snprintf(valtext, sizeof(valtext), "%d", value_index);
variable_item_set_current_value_text(item, valtext);
item = variable_item_list_add( item = variable_item_list_add(
app->variable_item_list, "Custom Blue", 255, color_set_custom_blue, app); app->variable_item_list, "Custom Green", 255, color_set_custom_green, app);
value_index = rgb_backlight_get_settings()->custom_b; value_index = rgb_backlight_get_settings()->custom_g;
variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_index(item, value_index);
snprintf(valtext, sizeof(valtext), "%d", value_index); snprintf(valtext, sizeof(valtext), "%d", value_index);
variable_item_set_current_value_text(item, valtext); variable_item_set_current_value_text(item, valtext);
// End of RGB
item = variable_item_list_add(
app->variable_item_list, "Custom Blue", 255, color_set_custom_blue, app);
value_index = rgb_backlight_get_settings()->custom_b;
variable_item_set_current_value_index(item, value_index);
snprintf(valtext, sizeof(valtext), "%d", value_index);
variable_item_set_current_value_text(item, valtext);
// End of RGB
}
item = variable_item_list_add( item = variable_item_list_add(
app->variable_item_list, "LCD Brightness", BACKLIGHT_COUNT, backlight_changed, app); app->variable_item_list, "LCD Brightness", BACKLIGHT_COUNT, backlight_changed, app);
value_index = value_index_float( value_index = value_index_float(