mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-19 04:44:47 -07:00
Rainbow mode in progress
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
#include <furi_hal.h>
|
#include <furi_hal.h>
|
||||||
#include <storage/storage.h>
|
#include <storage/storage.h>
|
||||||
#include "rgb_backlight.h"
|
#include "rgb_backlight.h"
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#define COLOR_COUNT (sizeof(colors) / sizeof(RGBBacklightColor))
|
#define COLOR_COUNT (sizeof(colors) / sizeof(RGBBacklightColor))
|
||||||
|
|
||||||
@@ -87,14 +88,22 @@ void rgb_backlight_set_led_static_color(uint8_t led, uint8_t index) {
|
|||||||
// furi_record_close(RECORD_RGB_BACKLIGHT);
|
// furi_record_close(RECORD_RGB_BACKLIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// use RECORD for acces to rgb service instance and update current colors by custom
|
// use RECORD for acces to rgb service instance and update current colors by custom value
|
||||||
// void rgb_backlight_set_custom_color(uint8_t red, uint8_t green, uint8_t blue) {
|
void rgb_backlight_set_led_custom_color(uint8_t led, uint8_t red, uint8_t green, uint8_t blue) {
|
||||||
// RGBBacklightApp* app = furi_record_open(RECORD_RGB_BACKLIGHT);
|
// RGBBacklightApp* app = furi_record_open(RECORD_RGB_BACKLIGHT);
|
||||||
// app->current_red = red;
|
// float brightness = app->settings->brightness;
|
||||||
// app->current_green = green;
|
|
||||||
// app->current_blue = blue;
|
if(led < SK6805_get_led_count()) {
|
||||||
// furi_record_close(RECORD_RGB_BACKLIGHT);
|
|
||||||
// }
|
current_led[led].red = red;
|
||||||
|
current_led[led].green = green;
|
||||||
|
current_led[led].blue = blue;
|
||||||
|
|
||||||
|
SK6805_set_led_color(led, red, green, blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// furi_record_close(RECORD_RGB_BACKLIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
// use RECORD for acces to rgb service instance, use current_* colors and update backlight
|
// use RECORD for acces to rgb service instance, use current_* colors and update backlight
|
||||||
void rgb_backlight_update(float brightness) {
|
void rgb_backlight_update(float brightness) {
|
||||||
@@ -132,19 +141,77 @@ void rainbow_timer_starter(RGBBacklightApp* app) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HSV to RGB based on
|
||||||
|
// https://www.radiokot.ru/forum/viewtopic.php?p=3000181&ysclid=m88wvoz34w244644702
|
||||||
|
// https://radiolaba.ru/microcotrollers/tsvetnaya-lampa.html#comment-1790
|
||||||
|
// https://alexgyver.ru/lessons/arduino-rgb/?ysclid=m88voflppa24464916
|
||||||
|
void hsv_to_rgb(uint8_t red, uint8_t green, uint8_t blue, uint16_t hue ,uint8_t sat ,uint8_t val) {
|
||||||
|
float r = 1.0f;
|
||||||
|
float g = 1.0f;
|
||||||
|
float b = 1.0f;
|
||||||
|
|
||||||
|
float H = hue / 255.0f;
|
||||||
|
float S = sat / 255.0f;
|
||||||
|
float V = val / 255.0f;
|
||||||
|
|
||||||
|
uint8_t i = trunc(H * 6);
|
||||||
|
float f = H * 6 - i;
|
||||||
|
float p = V * (1 - S);
|
||||||
|
float q = V * (1 - f * S);
|
||||||
|
float t = V * (1 - (1 - f) * S);
|
||||||
|
|
||||||
|
switch(i) {
|
||||||
|
case 0:
|
||||||
|
r = V, g = t, b = p;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
r = q, g = V, b = p;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
r = p, g = V, b = t;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
r = p, g = q, b = V;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
r = t, g = p, b = V;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
r = V, g = p, b = q;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
red = r * 255;
|
||||||
|
green = g * 255;
|
||||||
|
blue = b * 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void rainbow_timer_callback(void* context) {
|
static void rainbow_timer_callback(void* context) {
|
||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
RGBBacklightApp* app = context;
|
RGBBacklightApp* app = context;
|
||||||
|
uint8_t r = 0;
|
||||||
|
uint8_t g = 0;
|
||||||
|
uint8_t b = 0;
|
||||||
|
|
||||||
if (app->settings->rgb_backlight_installed) {
|
if(app->settings->rgb_backlight_installed) {
|
||||||
switch(app->settings->rainbow_mode) {
|
switch(app->settings->rainbow_mode) {
|
||||||
case 1:
|
case 1:
|
||||||
|
for(uint8_t i = 0; i < SK6805_get_led_count(); i++) {
|
||||||
|
hsv_to_rgb(r,g,b,app->rainbow_hue, app->settings->rainbow_saturation,app->settings->brightness*255);
|
||||||
|
FURI_LOG_D(
|
||||||
|
TAG, "rgb %d,%d,%d", r, g, b);
|
||||||
|
//rgb_backlight_set_led_custom_color (i,*r,*g,*b);
|
||||||
|
//SK6805_update();
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
app->rainbow_hue++;
|
||||||
rgb_backlight_update(app->settings->brightness);
|
rgb_backlight_update(app->settings->brightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,6 +235,8 @@ int32_t rgb_backlight_srv(void* p) {
|
|||||||
app->settings = malloc(sizeof(RGBBacklightSettings));
|
app->settings = malloc(sizeof(RGBBacklightSettings));
|
||||||
rgb_backlight_settings_load(app->settings);
|
rgb_backlight_settings_load(app->settings);
|
||||||
|
|
||||||
|
app->rainbow_hue = 1;
|
||||||
|
|
||||||
furi_record_create(RECORD_RGB_BACKLIGHT, app);
|
furi_record_create(RECORD_RGB_BACKLIGHT, app);
|
||||||
|
|
||||||
//if rgb_backlight_installed then start rainbow or set leds colors from saved settings (default index = 0)
|
//if rgb_backlight_installed then start rainbow or set leds colors from saved settings (default index = 0)
|
||||||
|
|||||||
@@ -28,10 +28,10 @@ extern "C" {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
FuriTimer* rainbow_timer;
|
FuriTimer* rainbow_timer;
|
||||||
|
uint8_t rainbow_hue;
|
||||||
// int16_t current_red;
|
uint8_t rainbow_red;
|
||||||
// int16_t current_green;
|
uint8_t rainbow_green;
|
||||||
// int16_t current_blue;
|
uint8_t rainbow_blue;
|
||||||
|
|
||||||
RGBBacklightSettings* settings;
|
RGBBacklightSettings* settings;
|
||||||
|
|
||||||
|
|||||||
@@ -18,16 +18,17 @@ typedef struct {
|
|||||||
uint8_t version;
|
uint8_t version;
|
||||||
uint8_t rgb_backlight_installed;
|
uint8_t rgb_backlight_installed;
|
||||||
float brightness;
|
float brightness;
|
||||||
|
|
||||||
// static gradient mode settings
|
// static gradient mode settings
|
||||||
uint8_t led_2_color_index;
|
uint8_t led_2_color_index;
|
||||||
uint8_t led_1_color_index;
|
uint8_t led_1_color_index;
|
||||||
uint8_t led_0_color_index;
|
uint8_t led_0_color_index;
|
||||||
|
|
||||||
// rainbow mode setings
|
// rainbow mode setings
|
||||||
uint32_t rainbow_mode;
|
uint32_t rainbow_mode;
|
||||||
uint32_t rainbow_speed_ms;
|
uint32_t rainbow_speed_ms;
|
||||||
uint16_t rainbow_step;
|
uint16_t rainbow_step;
|
||||||
|
uint8_t rainbow_saturation;
|
||||||
} RGBBacklightSettingsPrevious;
|
} RGBBacklightSettingsPrevious;
|
||||||
|
|
||||||
void rgb_backlight_settings_load(RGBBacklightSettings* settings) {
|
void rgb_backlight_settings_load(RGBBacklightSettings* settings) {
|
||||||
@@ -82,6 +83,7 @@ void rgb_backlight_settings_load(RGBBacklightSettings* settings) {
|
|||||||
settings->brightness = 1.0f;
|
settings->brightness = 1.0f;
|
||||||
settings->rainbow_speed_ms = 100;
|
settings->rainbow_speed_ms = 100;
|
||||||
settings->rainbow_step = 1;
|
settings->rainbow_step = 1;
|
||||||
|
settings->rainbow_saturation = 255;
|
||||||
rgb_backlight_settings_save(settings);
|
rgb_backlight_settings_save(settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ typedef struct {
|
|||||||
uint32_t rainbow_mode;
|
uint32_t rainbow_mode;
|
||||||
uint32_t rainbow_speed_ms;
|
uint32_t rainbow_speed_ms;
|
||||||
uint16_t rainbow_step;
|
uint16_t rainbow_step;
|
||||||
|
uint8_t rainbow_saturation;
|
||||||
|
|
||||||
} RGBBacklightSettings;
|
} RGBBacklightSettings;
|
||||||
|
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ static void rgb_backlight_installed_changed(VariableItem* item) {
|
|||||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
||||||
slide = 1;
|
slide = 1;
|
||||||
}
|
}
|
||||||
for(int i = slide; i < (slide + 6); i++) {
|
for(int i = slide; i < (slide + 7); i++) {
|
||||||
VariableItem* t_item = variable_item_list_get(app->variable_item_list_rgb, i);
|
VariableItem* t_item = variable_item_list_get(app->variable_item_list_rgb, i);
|
||||||
if(index == 0) {
|
if(index == 0) {
|
||||||
variable_item_set_locked(t_item, true, "RGB\nOFF!");
|
variable_item_set_locked(t_item, true, "RGB\nOFF!");
|
||||||
@@ -362,267 +362,294 @@ static void rgb_backlight_rainbow_step_changed(VariableItem* item) {
|
|||||||
rgb_backlight_settings_save(app->notification->rgb_srv->settings);
|
rgb_backlight_settings_save(app->notification->rgb_srv->settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void rgb_backlight_rainbow_saturation_changed (VariableItem* item) {
|
||||||
|
NotificationAppSettings* app = variable_item_get_context(item);
|
||||||
|
|
||||||
// open rgb_settings_view if user press OK on first (index=0) menu string and (debug mode or rgb_backlight_installed is true)
|
//saturation must be 1..255, so (0..254)+1
|
||||||
void variable_item_list_enter_callback(void* context, uint32_t index) {
|
uint8_t index = variable_item_get_current_value_index(item)+1;
|
||||||
UNUSED(context);
|
char valtext[4] = {};
|
||||||
NotificationAppSettings* app = context;
|
snprintf(valtext, sizeof(valtext), "%d", index);
|
||||||
|
variable_item_set_current_value_text(item, valtext);
|
||||||
|
app->notification->rgb_srv->settings->rainbow_saturation = index;
|
||||||
|
rgb_backlight_settings_save(app->notification->rgb_srv->settings);
|
||||||
|
}
|
||||||
|
// open rgb_settings_view if user press OK on first (index=0) menu string and (debug mode or rgb_backlight_installed is true)
|
||||||
|
void variable_item_list_enter_callback(void* context, uint32_t index) {
|
||||||
|
UNUSED(context);
|
||||||
|
NotificationAppSettings* app = context;
|
||||||
|
|
||||||
if(((app->notification->rgb_srv->settings->rgb_backlight_installed) ||
|
if(((app->notification->rgb_srv->settings->rgb_backlight_installed) ||
|
||||||
(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug))) &&
|
(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug))) &&
|
||||||
(index == 0)) {
|
(index == 0)) {
|
||||||
view_dispatcher_switch_to_view(app->view_dispatcher, RGBViewId);
|
view_dispatcher_switch_to_view(app->view_dispatcher, RGBViewId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// switch to main view on exit from rgb_settings_view
|
// switch to main view on exit from rgb_settings_view
|
||||||
static uint32_t notification_app_rgb_settings_exit(void* context) {
|
static uint32_t notification_app_rgb_settings_exit(void* context) {
|
||||||
UNUSED(context);
|
UNUSED(context);
|
||||||
return MainViewId;
|
return MainViewId;
|
||||||
}
|
|
||||||
//--- RGB BACKLIGHT END ---
|
|
||||||
|
|
||||||
static uint32_t notification_app_settings_exit(void* context) {
|
|
||||||
UNUSED(context);
|
|
||||||
return VIEW_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static NotificationAppSettings* alloc_settings(void) {
|
|
||||||
NotificationAppSettings* app = malloc(sizeof(NotificationAppSettings));
|
|
||||||
app->notification = furi_record_open(RECORD_NOTIFICATION);
|
|
||||||
app->gui = furi_record_open(RECORD_GUI);
|
|
||||||
|
|
||||||
app->variable_item_list = variable_item_list_alloc();
|
|
||||||
View* view = variable_item_list_get_view(app->variable_item_list);
|
|
||||||
|
|
||||||
VariableItem* item;
|
|
||||||
uint8_t value_index;
|
|
||||||
|
|
||||||
//set callback for exit from main view
|
|
||||||
view_set_previous_callback(view, notification_app_settings_exit);
|
|
||||||
|
|
||||||
//--- RGB BACKLIGHT ---
|
|
||||||
// set callback for OK pressed in notification settings menu
|
|
||||||
variable_item_list_set_enter_callback(
|
|
||||||
app->variable_item_list, variable_item_list_enter_callback, app);
|
|
||||||
|
|
||||||
//Show RGB settings only when debug_mode or rgb_backlight_installed is active
|
|
||||||
if((app->notification->rgb_srv->settings->rgb_backlight_installed) ||
|
|
||||||
(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug))) {
|
|
||||||
item = variable_item_list_add(app->variable_item_list, "RGB settings", 0, NULL, app);
|
|
||||||
}
|
}
|
||||||
//--- RGB BACKLIGHT END ---
|
//--- RGB BACKLIGHT END ---
|
||||||
|
|
||||||
item = variable_item_list_add(
|
static uint32_t notification_app_settings_exit(void* context) {
|
||||||
app->variable_item_list, "LCD Contrast", CONTRAST_COUNT, contrast_changed, app);
|
UNUSED(context);
|
||||||
value_index =
|
return VIEW_NONE;
|
||||||
value_index_int32(app->notification->settings.contrast, contrast_value, CONTRAST_COUNT);
|
}
|
||||||
variable_item_set_current_value_index(item, value_index);
|
|
||||||
variable_item_set_current_value_text(item, contrast_text[value_index]);
|
|
||||||
|
|
||||||
item = variable_item_list_add(
|
static NotificationAppSettings* alloc_settings(void) {
|
||||||
app->variable_item_list, "LCD Backlight", BACKLIGHT_COUNT, backlight_changed, app);
|
NotificationAppSettings* app = malloc(sizeof(NotificationAppSettings));
|
||||||
value_index = value_index_float(
|
app->notification = furi_record_open(RECORD_NOTIFICATION);
|
||||||
app->notification->settings.display_brightness, backlight_value, BACKLIGHT_COUNT);
|
app->gui = furi_record_open(RECORD_GUI);
|
||||||
variable_item_set_current_value_index(item, value_index);
|
|
||||||
variable_item_set_current_value_text(item, backlight_text[value_index]);
|
|
||||||
|
|
||||||
item = variable_item_list_add(
|
app->variable_item_list = variable_item_list_alloc();
|
||||||
app->variable_item_list, "Backlight Time", DELAY_COUNT, screen_changed, app);
|
View* view = variable_item_list_get_view(app->variable_item_list);
|
||||||
value_index = value_index_uint32(
|
|
||||||
app->notification->settings.display_off_delay_ms, delay_value, DELAY_COUNT);
|
|
||||||
variable_item_set_current_value_index(item, value_index);
|
|
||||||
variable_item_set_current_value_text(item, delay_text[value_index]);
|
|
||||||
|
|
||||||
item = variable_item_list_add(
|
VariableItem* item;
|
||||||
app->variable_item_list, "LED Brightness", BACKLIGHT_COUNT, led_changed, app);
|
uint8_t value_index;
|
||||||
value_index = value_index_float(
|
|
||||||
app->notification->settings.led_brightness, backlight_value, BACKLIGHT_COUNT);
|
//set callback for exit from main view
|
||||||
variable_item_set_current_value_index(item, value_index);
|
view_set_previous_callback(view, notification_app_settings_exit);
|
||||||
variable_item_set_current_value_text(item, backlight_text[value_index]);
|
|
||||||
|
//--- RGB BACKLIGHT ---
|
||||||
|
// set callback for OK pressed in notification settings menu
|
||||||
|
variable_item_list_set_enter_callback(
|
||||||
|
app->variable_item_list, variable_item_list_enter_callback, app);
|
||||||
|
|
||||||
|
//Show RGB settings only when debug_mode or rgb_backlight_installed is active
|
||||||
|
if((app->notification->rgb_srv->settings->rgb_backlight_installed) ||
|
||||||
|
(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug))) {
|
||||||
|
item = variable_item_list_add(app->variable_item_list, "RGB settings", 0, NULL, app);
|
||||||
|
}
|
||||||
|
//--- RGB BACKLIGHT END ---
|
||||||
|
|
||||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagStealthMode)) {
|
|
||||||
item = variable_item_list_add(app->variable_item_list, "Volume", 1, NULL, app);
|
|
||||||
value_index = 0;
|
|
||||||
variable_item_set_current_value_index(item, value_index);
|
|
||||||
variable_item_set_current_value_text(item, "Stealth");
|
|
||||||
} else {
|
|
||||||
item = variable_item_list_add(
|
item = variable_item_list_add(
|
||||||
app->variable_item_list, "Volume", VOLUME_COUNT, volume_changed, app);
|
app->variable_item_list, "LCD Contrast", CONTRAST_COUNT, contrast_changed, app);
|
||||||
|
value_index = value_index_int32(
|
||||||
|
app->notification->settings.contrast, contrast_value, CONTRAST_COUNT);
|
||||||
|
variable_item_set_current_value_index(item, value_index);
|
||||||
|
variable_item_set_current_value_text(item, contrast_text[value_index]);
|
||||||
|
|
||||||
|
item = variable_item_list_add(
|
||||||
|
app->variable_item_list, "LCD Backlight", BACKLIGHT_COUNT, backlight_changed, app);
|
||||||
value_index = value_index_float(
|
value_index = value_index_float(
|
||||||
app->notification->settings.speaker_volume, volume_value, VOLUME_COUNT);
|
app->notification->settings.display_brightness, backlight_value, BACKLIGHT_COUNT);
|
||||||
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, volume_text[value_index]);
|
variable_item_set_current_value_text(item, backlight_text[value_index]);
|
||||||
}
|
|
||||||
|
|
||||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagStealthMode)) {
|
|
||||||
item = variable_item_list_add(app->variable_item_list, "Vibro", 1, NULL, app);
|
|
||||||
value_index = 0;
|
|
||||||
variable_item_set_current_value_index(item, value_index);
|
|
||||||
variable_item_set_current_value_text(item, "Stealth");
|
|
||||||
} else {
|
|
||||||
item = variable_item_list_add(
|
item = variable_item_list_add(
|
||||||
app->variable_item_list, "Vibro", VIBRO_COUNT, vibro_changed, app);
|
app->variable_item_list, "Backlight Time", DELAY_COUNT, screen_changed, app);
|
||||||
value_index =
|
value_index = value_index_uint32(
|
||||||
value_index_bool(app->notification->settings.vibro_on, vibro_value, VIBRO_COUNT);
|
app->notification->settings.display_off_delay_ms, delay_value, DELAY_COUNT);
|
||||||
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, vibro_text[value_index]);
|
variable_item_set_current_value_text(item, delay_text[value_index]);
|
||||||
}
|
|
||||||
|
|
||||||
//--- RGB BACKLIGHT ---
|
item = variable_item_list_add(
|
||||||
|
app->variable_item_list, "LED Brightness", BACKLIGHT_COUNT, led_changed, app);
|
||||||
|
value_index = value_index_float(
|
||||||
|
app->notification->settings.led_brightness, backlight_value, BACKLIGHT_COUNT);
|
||||||
|
variable_item_set_current_value_index(item, value_index);
|
||||||
|
variable_item_set_current_value_text(item, backlight_text[value_index]);
|
||||||
|
|
||||||
app->variable_item_list_rgb = variable_item_list_alloc();
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagStealthMode)) {
|
||||||
View* view_rgb = variable_item_list_get_view(app->variable_item_list_rgb);
|
item = variable_item_list_add(app->variable_item_list, "Volume", 1, NULL, app);
|
||||||
|
value_index = 0;
|
||||||
|
variable_item_set_current_value_index(item, value_index);
|
||||||
|
variable_item_set_current_value_text(item, "Stealth");
|
||||||
|
} else {
|
||||||
|
item = variable_item_list_add(
|
||||||
|
app->variable_item_list, "Volume", VOLUME_COUNT, volume_changed, app);
|
||||||
|
value_index = value_index_float(
|
||||||
|
app->notification->settings.speaker_volume, volume_value, VOLUME_COUNT);
|
||||||
|
variable_item_set_current_value_index(item, value_index);
|
||||||
|
variable_item_set_current_value_text(item, volume_text[value_index]);
|
||||||
|
}
|
||||||
|
|
||||||
// set callback for exit from rgb_settings_menu
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagStealthMode)) {
|
||||||
view_set_previous_callback(view_rgb, notification_app_rgb_settings_exit);
|
item = variable_item_list_add(app->variable_item_list, "Vibro", 1, NULL, app);
|
||||||
|
value_index = 0;
|
||||||
|
variable_item_set_current_value_index(item, value_index);
|
||||||
|
variable_item_set_current_value_text(item, "Stealth");
|
||||||
|
} else {
|
||||||
|
item = variable_item_list_add(
|
||||||
|
app->variable_item_list, "Vibro", VIBRO_COUNT, vibro_changed, app);
|
||||||
|
value_index =
|
||||||
|
value_index_bool(app->notification->settings.vibro_on, vibro_value, VIBRO_COUNT);
|
||||||
|
variable_item_set_current_value_index(item, value_index);
|
||||||
|
variable_item_set_current_value_text(item, vibro_text[value_index]);
|
||||||
|
}
|
||||||
|
|
||||||
// // Show rgb_backlight_Installed_Swith only in Debug mode
|
//--- RGB BACKLIGHT ---
|
||||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
|
||||||
|
app->variable_item_list_rgb = variable_item_list_alloc();
|
||||||
|
View* view_rgb = variable_item_list_get_view(app->variable_item_list_rgb);
|
||||||
|
|
||||||
|
// set callback for exit from rgb_settings_menu
|
||||||
|
view_set_previous_callback(view_rgb, notification_app_rgb_settings_exit);
|
||||||
|
|
||||||
|
// // Show rgb_backlight_Installed_Swith only in Debug mode
|
||||||
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
||||||
|
item = variable_item_list_add(
|
||||||
|
app->variable_item_list_rgb,
|
||||||
|
"RGB backlight installed",
|
||||||
|
RGB_BACKLIGHT_INSTALLED_COUNT,
|
||||||
|
rgb_backlight_installed_changed,
|
||||||
|
app);
|
||||||
|
value_index = value_index_bool(
|
||||||
|
app->notification->rgb_srv->settings->rgb_backlight_installed,
|
||||||
|
rgb_backlight_installed_value,
|
||||||
|
RGB_BACKLIGHT_INSTALLED_COUNT);
|
||||||
|
variable_item_set_current_value_index(item, value_index);
|
||||||
|
variable_item_set_current_value_text(item, rgb_backlight_installed_text[value_index]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// led_1 color
|
||||||
item = variable_item_list_add(
|
item = variable_item_list_add(
|
||||||
app->variable_item_list_rgb,
|
app->variable_item_list_rgb,
|
||||||
"RGB backlight installed",
|
"LED 1 Color",
|
||||||
RGB_BACKLIGHT_INSTALLED_COUNT,
|
rgb_backlight_get_color_count(),
|
||||||
rgb_backlight_installed_changed,
|
led_2_color_changed,
|
||||||
app);
|
app);
|
||||||
value_index = value_index_bool(
|
value_index = app->notification->rgb_srv->settings->led_2_color_index;
|
||||||
app->notification->rgb_srv->settings->rgb_backlight_installed,
|
|
||||||
rgb_backlight_installed_value,
|
|
||||||
RGB_BACKLIGHT_INSTALLED_COUNT);
|
|
||||||
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, rgb_backlight_installed_text[value_index]);
|
variable_item_set_current_value_text(item, rgb_backlight_get_color_text(value_index));
|
||||||
|
variable_item_set_locked(
|
||||||
|
item,
|
||||||
|
(app->notification->rgb_srv->settings->rgb_backlight_installed == 0),
|
||||||
|
"RGB MOD \nOFF!");
|
||||||
|
|
||||||
|
// led_2 color
|
||||||
|
item = variable_item_list_add(
|
||||||
|
app->variable_item_list_rgb,
|
||||||
|
"LED 2 Color",
|
||||||
|
rgb_backlight_get_color_count(),
|
||||||
|
led_1_color_changed,
|
||||||
|
app);
|
||||||
|
value_index = app->notification->rgb_srv->settings->led_1_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));
|
||||||
|
variable_item_set_locked(
|
||||||
|
item,
|
||||||
|
(app->notification->rgb_srv->settings->rgb_backlight_installed == 0),
|
||||||
|
"RGB MOD \nOFF!");
|
||||||
|
|
||||||
|
// led 3 color
|
||||||
|
item = variable_item_list_add(
|
||||||
|
app->variable_item_list_rgb,
|
||||||
|
"LED 3 Color",
|
||||||
|
rgb_backlight_get_color_count(),
|
||||||
|
led_0_color_changed,
|
||||||
|
app);
|
||||||
|
value_index = app->notification->rgb_srv->settings->led_0_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));
|
||||||
|
variable_item_set_locked(
|
||||||
|
item,
|
||||||
|
(app->notification->rgb_srv->settings->rgb_backlight_installed == 0),
|
||||||
|
"RGB MOD \nOFF!");
|
||||||
|
|
||||||
|
// Rainbow mode
|
||||||
|
item = variable_item_list_add(
|
||||||
|
app->variable_item_list_rgb,
|
||||||
|
"Rainbow mode",
|
||||||
|
RGB_BACKLIGHT_RAINBOW_MODE_COUNT,
|
||||||
|
rgb_backlight_rainbow_changed,
|
||||||
|
app);
|
||||||
|
value_index = value_index_uint32(
|
||||||
|
app->notification->rgb_srv->settings->rainbow_mode,
|
||||||
|
rgb_backlight_rainbow_mode_value,
|
||||||
|
RGB_BACKLIGHT_RAINBOW_MODE_COUNT);
|
||||||
|
variable_item_set_current_value_index(item, value_index);
|
||||||
|
variable_item_set_current_value_text(item, rgb_backlight_rainbow_mode_text[value_index]);
|
||||||
|
variable_item_set_locked(
|
||||||
|
item,
|
||||||
|
(app->notification->rgb_srv->settings->rgb_backlight_installed == 0),
|
||||||
|
"RGB MOD \nOFF!");
|
||||||
|
|
||||||
|
item = variable_item_list_add(
|
||||||
|
app->variable_item_list_rgb,
|
||||||
|
"Rainbow speed",
|
||||||
|
RGB_BACKLIGHT_RAINBOW_SPEED_COUNT,
|
||||||
|
rgb_backlight_rainbow_speed_changed,
|
||||||
|
app);
|
||||||
|
value_index = value_index_uint32(
|
||||||
|
app->notification->rgb_srv->settings->rainbow_speed_ms,
|
||||||
|
rgb_backlight_rainbow_speed_value,
|
||||||
|
RGB_BACKLIGHT_RAINBOW_SPEED_COUNT);
|
||||||
|
variable_item_set_current_value_index(item, value_index);
|
||||||
|
variable_item_set_current_value_text(item, rgb_backlight_rainbow_speed_text[value_index]);
|
||||||
|
variable_item_set_locked(
|
||||||
|
item,
|
||||||
|
(app->notification->rgb_srv->settings->rgb_backlight_installed == 0),
|
||||||
|
"RGB MOD \nOFF!");
|
||||||
|
|
||||||
|
item = variable_item_list_add(
|
||||||
|
app->variable_item_list_rgb,
|
||||||
|
"Rainbow step",
|
||||||
|
RGB_BACKLIGHT_RAINBOW_STEP_COUNT,
|
||||||
|
rgb_backlight_rainbow_step_changed,
|
||||||
|
app);
|
||||||
|
value_index = value_index_uint32(
|
||||||
|
app->notification->rgb_srv->settings->rainbow_step,
|
||||||
|
rgb_backlight_rainbow_step_value,
|
||||||
|
RGB_BACKLIGHT_RAINBOW_SPEED_COUNT);
|
||||||
|
variable_item_set_current_value_index(item, value_index);
|
||||||
|
variable_item_set_current_value_text(item, rgb_backlight_rainbow_step_text[value_index]);
|
||||||
|
variable_item_set_locked(
|
||||||
|
item,
|
||||||
|
(app->notification->rgb_srv->settings->rgb_backlight_installed == 0),
|
||||||
|
"RGB MOD \nOFF!");
|
||||||
|
|
||||||
|
item = variable_item_list_add(
|
||||||
|
app->variable_item_list_rgb,
|
||||||
|
"Saturation",
|
||||||
|
255,
|
||||||
|
rgb_backlight_rainbow_saturation_changed,
|
||||||
|
app);
|
||||||
|
value_index = app->notification->rgb_srv->settings->rainbow_saturation;
|
||||||
|
variable_item_set_current_value_index(item, value_index);
|
||||||
|
char valtext[4] = {};
|
||||||
|
snprintf(valtext, sizeof(valtext), "%d", value_index);
|
||||||
|
variable_item_set_current_value_text(item, valtext);
|
||||||
|
variable_item_set_locked(
|
||||||
|
item,
|
||||||
|
(app->notification->rgb_srv->settings->rgb_backlight_installed == 0),
|
||||||
|
"RGB MOD \nOFF!");
|
||||||
|
|
||||||
|
//--- RGB BACKLIGHT END ---
|
||||||
|
|
||||||
|
app->view_dispatcher = view_dispatcher_alloc();
|
||||||
|
view_dispatcher_attach_to_gui(
|
||||||
|
app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
|
||||||
|
view_dispatcher_add_view(app->view_dispatcher, MainViewId, view);
|
||||||
|
view_dispatcher_add_view(app->view_dispatcher, RGBViewId, view_rgb);
|
||||||
|
view_dispatcher_switch_to_view(app->view_dispatcher, MainViewId);
|
||||||
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
// led_1 color
|
|
||||||
item = variable_item_list_add(
|
|
||||||
app->variable_item_list_rgb,
|
|
||||||
"LED 1 Color",
|
|
||||||
rgb_backlight_get_color_count(),
|
|
||||||
led_2_color_changed,
|
|
||||||
app);
|
|
||||||
value_index = app->notification->rgb_srv->settings->led_2_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));
|
|
||||||
variable_item_set_locked(
|
|
||||||
item,
|
|
||||||
(app->notification->rgb_srv->settings->rgb_backlight_installed == 0),
|
|
||||||
"RGB MOD \nOFF!");
|
|
||||||
|
|
||||||
// led_2 color
|
static void free_settings(NotificationAppSettings * app) {
|
||||||
item = variable_item_list_add(
|
view_dispatcher_remove_view(app->view_dispatcher, MainViewId);
|
||||||
app->variable_item_list_rgb,
|
view_dispatcher_remove_view(app->view_dispatcher, RGBViewId);
|
||||||
"LED 2 Color",
|
variable_item_list_free(app->variable_item_list);
|
||||||
rgb_backlight_get_color_count(),
|
variable_item_list_free(app->variable_item_list_rgb);
|
||||||
led_1_color_changed,
|
view_dispatcher_free(app->view_dispatcher);
|
||||||
app);
|
|
||||||
value_index = app->notification->rgb_srv->settings->led_1_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));
|
|
||||||
variable_item_set_locked(
|
|
||||||
item,
|
|
||||||
(app->notification->rgb_srv->settings->rgb_backlight_installed == 0),
|
|
||||||
"RGB MOD \nOFF!");
|
|
||||||
|
|
||||||
// led 3 color
|
|
||||||
item = variable_item_list_add(
|
|
||||||
app->variable_item_list_rgb,
|
|
||||||
"LED 3 Color",
|
|
||||||
rgb_backlight_get_color_count(),
|
|
||||||
led_0_color_changed,
|
|
||||||
app);
|
|
||||||
value_index = app->notification->rgb_srv->settings->led_0_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));
|
|
||||||
variable_item_set_locked(
|
|
||||||
item,
|
|
||||||
(app->notification->rgb_srv->settings->rgb_backlight_installed == 0),
|
|
||||||
"RGB MOD \nOFF!");
|
|
||||||
|
|
||||||
// Rainbow mode
|
|
||||||
item = variable_item_list_add(
|
|
||||||
app->variable_item_list_rgb,
|
|
||||||
"Rainbow mode",
|
|
||||||
RGB_BACKLIGHT_RAINBOW_MODE_COUNT,
|
|
||||||
rgb_backlight_rainbow_changed,
|
|
||||||
app);
|
|
||||||
value_index = value_index_uint32(
|
|
||||||
app->notification->rgb_srv->settings->rainbow_mode,
|
|
||||||
rgb_backlight_rainbow_mode_value,
|
|
||||||
RGB_BACKLIGHT_RAINBOW_MODE_COUNT);
|
|
||||||
variable_item_set_current_value_index(item, value_index);
|
|
||||||
variable_item_set_current_value_text(item, rgb_backlight_rainbow_mode_text[value_index]);
|
|
||||||
variable_item_set_locked(
|
|
||||||
item,
|
|
||||||
(app->notification->rgb_srv->settings->rgb_backlight_installed == 0),
|
|
||||||
"RGB MOD \nOFF!");
|
|
||||||
|
|
||||||
item = variable_item_list_add(
|
furi_record_close(RECORD_GUI);
|
||||||
app->variable_item_list_rgb,
|
furi_record_close(RECORD_NOTIFICATION);
|
||||||
"Rainbow speed",
|
free(app);
|
||||||
RGB_BACKLIGHT_RAINBOW_SPEED_COUNT,
|
}
|
||||||
rgb_backlight_rainbow_speed_changed,
|
|
||||||
app);
|
|
||||||
value_index = value_index_uint32(
|
|
||||||
app->notification->rgb_srv->settings->rainbow_speed_ms,
|
|
||||||
rgb_backlight_rainbow_speed_value,
|
|
||||||
RGB_BACKLIGHT_RAINBOW_SPEED_COUNT);
|
|
||||||
variable_item_set_current_value_index(item, value_index);
|
|
||||||
variable_item_set_current_value_text(item, rgb_backlight_rainbow_speed_text[value_index]);
|
|
||||||
variable_item_set_locked(
|
|
||||||
item,
|
|
||||||
(app->notification->rgb_srv->settings->rgb_backlight_installed == 0),
|
|
||||||
"RGB MOD \nOFF!");
|
|
||||||
|
|
||||||
item = variable_item_list_add(
|
int32_t notification_settings_app(void* p) {
|
||||||
app->variable_item_list_rgb,
|
UNUSED(p);
|
||||||
"Rainbow step",
|
NotificationAppSettings* app = alloc_settings();
|
||||||
RGB_BACKLIGHT_RAINBOW_STEP_COUNT,
|
view_dispatcher_run(app->view_dispatcher);
|
||||||
rgb_backlight_rainbow_step_changed,
|
notification_message_save_settings(app->notification);
|
||||||
app);
|
|
||||||
value_index = value_index_uint32(
|
|
||||||
app->notification->rgb_srv->settings->rainbow_step,
|
|
||||||
rgb_backlight_rainbow_step_value,
|
|
||||||
RGB_BACKLIGHT_RAINBOW_SPEED_COUNT);
|
|
||||||
variable_item_set_current_value_index(item, value_index);
|
|
||||||
variable_item_set_current_value_text(item, rgb_backlight_rainbow_step_text[value_index]);
|
|
||||||
variable_item_set_locked(
|
|
||||||
item,
|
|
||||||
(app->notification->rgb_srv->settings->rgb_backlight_installed == 0),
|
|
||||||
"RGB MOD \nOFF!");
|
|
||||||
|
|
||||||
//--- RGB BACKLIGHT END ---
|
// Automaticaly switch_off debug_mode when user exit from settings with enabled rgb_backlight_installed
|
||||||
|
// if(app->notification->settings.rgb_backlight_installed) {
|
||||||
|
// furi_hal_rtc_reset_flag(FuriHalRtcFlagDebug);
|
||||||
|
// }
|
||||||
|
|
||||||
app->view_dispatcher = view_dispatcher_alloc();
|
free_settings(app);
|
||||||
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
|
return 0;
|
||||||
view_dispatcher_add_view(app->view_dispatcher, MainViewId, view);
|
}
|
||||||
view_dispatcher_add_view(app->view_dispatcher, RGBViewId, view_rgb);
|
|
||||||
view_dispatcher_switch_to_view(app->view_dispatcher, MainViewId);
|
|
||||||
return app;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void free_settings(NotificationAppSettings* app) {
|
|
||||||
view_dispatcher_remove_view(app->view_dispatcher, MainViewId);
|
|
||||||
view_dispatcher_remove_view(app->view_dispatcher, RGBViewId);
|
|
||||||
variable_item_list_free(app->variable_item_list);
|
|
||||||
variable_item_list_free(app->variable_item_list_rgb);
|
|
||||||
view_dispatcher_free(app->view_dispatcher);
|
|
||||||
|
|
||||||
furi_record_close(RECORD_GUI);
|
|
||||||
furi_record_close(RECORD_NOTIFICATION);
|
|
||||||
free(app);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t notification_settings_app(void* p) {
|
|
||||||
UNUSED(p);
|
|
||||||
NotificationAppSettings* app = alloc_settings();
|
|
||||||
view_dispatcher_run(app->view_dispatcher);
|
|
||||||
notification_message_save_settings(app->notification);
|
|
||||||
|
|
||||||
// Automaticaly switch_off debug_mode when user exit from settings with enabled rgb_backlight_installed
|
|
||||||
// if(app->notification->settings.rgb_backlight_installed) {
|
|
||||||
// furi_hal_rtc_reset_flag(FuriHalRtcFlagDebug);
|
|
||||||
// }
|
|
||||||
|
|
||||||
free_settings(app);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user