mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 04:34:43 +04:00
Still in progress
This commit is contained in:
@@ -4,7 +4,7 @@ App(
|
||||
apptype=FlipperAppType.SERVICE,
|
||||
entry_point="notification_srv",
|
||||
cdefines=["SRV_NOTIFICATION"],
|
||||
requires=["input"],
|
||||
requires=["input","rgb_backlight"],
|
||||
provides=["notification_settings"],
|
||||
stack_size=int(1.5 * 1024),
|
||||
order=100,
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "notification.h"
|
||||
#include "notification_messages.h"
|
||||
#include "notification_app.h"
|
||||
#include "applications/settings/notification_settings/rgb_backlight.h"
|
||||
#include "applications/services/rgb_backlight/rgb_backlight.h"
|
||||
|
||||
#define TAG "NotificationSrv"
|
||||
|
||||
@@ -189,110 +189,110 @@ static void notification_display_timer(void* ctx) {
|
||||
notification_message(app, &sequence_display_backlight_off);
|
||||
}
|
||||
|
||||
// --- RGB MOD RAINBOW SECTION ---
|
||||
// // --- RGB MOD RAINBOW SECTION ---
|
||||
|
||||
//start furi timer for rgb_mod_rainbow
|
||||
static void rgb_mod_rainbow_timer_start(NotificationApp* app) {
|
||||
furi_timer_start(
|
||||
app->rgb_mod_rainbow_timer, furi_ms_to_ticks(app->settings.rgb_mod_rainbow_speed_ms));
|
||||
}
|
||||
// //start furi timer for rgb_mod_rainbow
|
||||
// static void rgb_mod_rainbow_timer_start(NotificationApp* app) {
|
||||
// furi_timer_start(
|
||||
// app->rgb_mod_rainbow_timer, furi_ms_to_ticks(app->settings.rgb_mod_rainbow_speed_ms));
|
||||
// }
|
||||
|
||||
//stop furi timer for rgb_mod_rainbow
|
||||
static void rgb_mod_rainbow_timer_stop(NotificationApp* app) {
|
||||
furi_timer_stop(app->rgb_mod_rainbow_timer);
|
||||
}
|
||||
// //stop furi timer for rgb_mod_rainbow
|
||||
// static void rgb_mod_rainbow_timer_stop(NotificationApp* app) {
|
||||
// furi_timer_stop(app->rgb_mod_rainbow_timer);
|
||||
// }
|
||||
|
||||
// start/restart/stop rgb_mod_rainbow_timer only if rgb_mod_installed and apply rainbow colors to backlight
|
||||
static void rgb_mod_rainbow_timer_starter(NotificationApp* app) {
|
||||
if(app->settings.rgb_mod_installed) {
|
||||
if(app->settings.rgb_mod_rainbow_mode > 0) {
|
||||
rgb_mod_rainbow_update(
|
||||
app->rgb_mod_rainbow_red,
|
||||
app->rgb_mod_rainbow_green,
|
||||
app->rgb_mod_rainbow_blue,
|
||||
app->settings.display_brightness);
|
||||
rgb_mod_rainbow_timer_start(app);
|
||||
} else {
|
||||
if(furi_timer_is_running(app->rgb_mod_rainbow_timer)) {
|
||||
rgb_mod_rainbow_timer_stop(app);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// // start/restart/stop rgb_mod_rainbow_timer only if rgb_mod_installed and apply rainbow colors to backlight
|
||||
// static void rgb_mod_rainbow_timer_starter(NotificationApp* app) {
|
||||
// if(app->settings.rgb_mod_installed) {
|
||||
// if(app->settings.rgb_mod_rainbow_mode > 0) {
|
||||
// rgb_mod_rainbow_update(
|
||||
// app->rgb_mod_rainbow_red,
|
||||
// app->rgb_mod_rainbow_green,
|
||||
// app->rgb_mod_rainbow_blue,
|
||||
// app->settings.display_brightness);
|
||||
// rgb_mod_rainbow_timer_start(app);
|
||||
// } else {
|
||||
// if(furi_timer_is_running(app->rgb_mod_rainbow_timer)) {
|
||||
// rgb_mod_rainbow_timer_stop(app);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// callback for rgb_mod_rainbow_timer (what we do when timer end)
|
||||
static void rgb_mod_rainbow_timer_callback(void* context) {
|
||||
furi_assert(context);
|
||||
NotificationApp* app = context;
|
||||
// // callback for rgb_mod_rainbow_timer (what we do when timer end)
|
||||
// static void rgb_mod_rainbow_timer_callback(void* context) {
|
||||
// furi_assert(context);
|
||||
// NotificationApp* app = context;
|
||||
|
||||
// if rgb_mode_rainbow_mode is rainbow do rainbow effect
|
||||
if(app->settings.rgb_mod_rainbow_mode == 1) {
|
||||
switch(app->rgb_mod_rainbow_stage) {
|
||||
// from red to yellow
|
||||
case 1:
|
||||
app->rgb_mod_rainbow_green += app->settings.rgb_mod_rainbow_step;
|
||||
if(app->rgb_mod_rainbow_green >= 255) {
|
||||
app->rgb_mod_rainbow_green = 255;
|
||||
app->rgb_mod_rainbow_stage++;
|
||||
}
|
||||
break;
|
||||
// yellow red to green
|
||||
case 2:
|
||||
app->rgb_mod_rainbow_red -= app->settings.rgb_mod_rainbow_step;
|
||||
if(app->rgb_mod_rainbow_red <= 0) {
|
||||
app->rgb_mod_rainbow_red = 0;
|
||||
app->rgb_mod_rainbow_stage++;
|
||||
}
|
||||
break;
|
||||
// from green to light blue
|
||||
case 3:
|
||||
app->rgb_mod_rainbow_blue += app->settings.rgb_mod_rainbow_step;
|
||||
if(app->rgb_mod_rainbow_blue >= 255) {
|
||||
app->rgb_mod_rainbow_blue = 255;
|
||||
app->rgb_mod_rainbow_stage++;
|
||||
}
|
||||
break;
|
||||
//from light blue to blue
|
||||
case 4:
|
||||
app->rgb_mod_rainbow_green -= app->settings.rgb_mod_rainbow_step;
|
||||
if(app->rgb_mod_rainbow_green <= 0) {
|
||||
app->rgb_mod_rainbow_green = 0;
|
||||
app->rgb_mod_rainbow_stage++;
|
||||
}
|
||||
break;
|
||||
//from blue to violet
|
||||
case 5:
|
||||
app->rgb_mod_rainbow_red += app->settings.rgb_mod_rainbow_step;
|
||||
if(app->rgb_mod_rainbow_red >= 255) {
|
||||
app->rgb_mod_rainbow_red = 255;
|
||||
app->rgb_mod_rainbow_stage++;
|
||||
}
|
||||
break;
|
||||
//from violet to red
|
||||
case 6:
|
||||
app->rgb_mod_rainbow_blue -= app->settings.rgb_mod_rainbow_step;
|
||||
if(app->rgb_mod_rainbow_blue <= 0) {
|
||||
app->rgb_mod_rainbow_blue = 0;
|
||||
app->rgb_mod_rainbow_stage = 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// // if rgb_mode_rainbow_mode is rainbow do rainbow effect
|
||||
// if(app->settings.rgb_mod_rainbow_mode == 1) {
|
||||
// switch(app->rgb_mod_rainbow_stage) {
|
||||
// // from red to yellow
|
||||
// case 1:
|
||||
// app->rgb_mod_rainbow_green += app->settings.rgb_mod_rainbow_step;
|
||||
// if(app->rgb_mod_rainbow_green >= 255) {
|
||||
// app->rgb_mod_rainbow_green = 255;
|
||||
// app->rgb_mod_rainbow_stage++;
|
||||
// }
|
||||
// break;
|
||||
// // yellow red to green
|
||||
// case 2:
|
||||
// app->rgb_mod_rainbow_red -= app->settings.rgb_mod_rainbow_step;
|
||||
// if(app->rgb_mod_rainbow_red <= 0) {
|
||||
// app->rgb_mod_rainbow_red = 0;
|
||||
// app->rgb_mod_rainbow_stage++;
|
||||
// }
|
||||
// break;
|
||||
// // from green to light blue
|
||||
// case 3:
|
||||
// app->rgb_mod_rainbow_blue += app->settings.rgb_mod_rainbow_step;
|
||||
// if(app->rgb_mod_rainbow_blue >= 255) {
|
||||
// app->rgb_mod_rainbow_blue = 255;
|
||||
// app->rgb_mod_rainbow_stage++;
|
||||
// }
|
||||
// break;
|
||||
// //from light blue to blue
|
||||
// case 4:
|
||||
// app->rgb_mod_rainbow_green -= app->settings.rgb_mod_rainbow_step;
|
||||
// if(app->rgb_mod_rainbow_green <= 0) {
|
||||
// app->rgb_mod_rainbow_green = 0;
|
||||
// app->rgb_mod_rainbow_stage++;
|
||||
// }
|
||||
// break;
|
||||
// //from blue to violet
|
||||
// case 5:
|
||||
// app->rgb_mod_rainbow_red += app->settings.rgb_mod_rainbow_step;
|
||||
// if(app->rgb_mod_rainbow_red >= 255) {
|
||||
// app->rgb_mod_rainbow_red = 255;
|
||||
// app->rgb_mod_rainbow_stage++;
|
||||
// }
|
||||
// break;
|
||||
// //from violet to red
|
||||
// case 6:
|
||||
// app->rgb_mod_rainbow_blue -= app->settings.rgb_mod_rainbow_step;
|
||||
// if(app->rgb_mod_rainbow_blue <= 0) {
|
||||
// app->rgb_mod_rainbow_blue = 0;
|
||||
// app->rgb_mod_rainbow_stage = 1;
|
||||
// }
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
|
||||
rgb_mod_rainbow_update(
|
||||
app->rgb_mod_rainbow_red,
|
||||
app->rgb_mod_rainbow_green,
|
||||
app->rgb_mod_rainbow_blue,
|
||||
app->settings.display_brightness);
|
||||
}
|
||||
// rgb_mod_rainbow_update(
|
||||
// app->rgb_mod_rainbow_red,
|
||||
// app->rgb_mod_rainbow_green,
|
||||
// app->rgb_mod_rainbow_blue,
|
||||
// app->settings.display_brightness);
|
||||
// }
|
||||
|
||||
// if rgb_mode_rainbow_mode is ..... do another effect
|
||||
// if(app->settings.rgb_mod_rainbow_mode == 2) {
|
||||
// }
|
||||
}
|
||||
// // if rgb_mode_rainbow_mode is ..... do another effect
|
||||
// // if(app->settings.rgb_mod_rainbow_mode == 2) {
|
||||
// // }
|
||||
// }
|
||||
|
||||
// --- END OF RGB MOD RAINBOW SECTION ---
|
||||
// // --- END OF RGB MOD RAINBOW SECTION ---
|
||||
|
||||
// message processing
|
||||
static void notification_process_notification_message(
|
||||
@@ -326,7 +326,7 @@ static void notification_process_notification_message(
|
||||
reset_mask |= reset_display_mask;
|
||||
|
||||
//start rgb_mod_rainbow_timer when display backlight is ON and all corresponding settings is ON too
|
||||
rgb_mod_rainbow_timer_starter(app);
|
||||
rainbow_timer_starter(app->rgb_srv);
|
||||
|
||||
} else {
|
||||
reset_mask &= ~reset_display_mask;
|
||||
@@ -335,8 +335,8 @@ static void notification_process_notification_message(
|
||||
furi_timer_stop(app->display_timer);
|
||||
}
|
||||
//stop rgb_mod_rainbow_timer when display backlight is OFF
|
||||
if(furi_timer_is_running(app->rgb_mod_rainbow_timer)) {
|
||||
rgb_mod_rainbow_timer_stop(app);
|
||||
if(furi_timer_is_running(app->rgb_srv->rainbow_timer)) {
|
||||
rainbow_timer_stop(app->rgb_srv);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -664,25 +664,26 @@ static NotificationApp* notification_app_alloc(void) {
|
||||
furi_pubsub_subscribe(app->event_record, input_event_callback, app);
|
||||
notification_message(app, &sequence_display_backlight_on);
|
||||
|
||||
// --- RGB MOD INIT SETTINGS SECTION ---
|
||||
// // --- RGB MOD INIT SETTINGS SECTION ---
|
||||
|
||||
app->settings.rgb_mod_installed = false;
|
||||
app->settings.rgb_mod_rainbow_mode = 0;
|
||||
app->settings.rgb_mod_rainbow_speed_ms = 100;
|
||||
app->settings.rgb_mod_rainbow_step = 5;
|
||||
app->rgb_mod_rainbow_red = 255;
|
||||
app->rgb_mod_rainbow_green = 0;
|
||||
app->rgb_mod_rainbow_blue = 0;
|
||||
app->rgb_mod_rainbow_stage = 1;
|
||||
// app->settings.rgb_mod_installed = false;
|
||||
// app->settings.rgb_mod_rainbow_mode = 0;
|
||||
// app->settings.rgb_mod_rainbow_speed_ms = 100;
|
||||
// app->settings.rgb_mod_rainbow_step = 5;
|
||||
// app->rgb_mod_rainbow_red = 255;
|
||||
// app->rgb_mod_rainbow_green = 0;
|
||||
// app->rgb_mod_rainbow_blue = 0;
|
||||
// app->rgb_mod_rainbow_stage = 1;
|
||||
|
||||
// //define rgb_mod_rainbow_timer and they callback
|
||||
// app->rgb_mod_rainbow_timer =
|
||||
// furi_timer_alloc(rgb_mod_rainbow_timer_callback, FuriTimerTypePeriodic, app);
|
||||
// // --- END OF RGB MOD INIT SETTINGS SECTION ---
|
||||
|
||||
//define rgb_mod_rainbow_timer and they callback
|
||||
app->rgb_mod_rainbow_timer =
|
||||
furi_timer_alloc(rgb_mod_rainbow_timer_callback, FuriTimerTypePeriodic, app);
|
||||
return app;
|
||||
|
||||
// --- END OF RGB MOD INIT SETTINGS SECTION ---
|
||||
}
|
||||
|
||||
|
||||
static void notification_storage_callback(const void* message, void* context) {
|
||||
furi_assert(context);
|
||||
NotificationApp* app = context;
|
||||
@@ -703,8 +704,8 @@ static void notification_apply_settings(NotificationApp* app) {
|
||||
}
|
||||
|
||||
notification_apply_lcd_contrast(app);
|
||||
//start rgb_mod_rainbow_timer on system init if they ON in config
|
||||
rgb_mod_rainbow_timer_starter(app);
|
||||
// //start rgb_mod_rainbow_timer on system init if they ON in config
|
||||
// rgb_mod_rainbow_timer_starter(app);
|
||||
}
|
||||
|
||||
static void notification_init_settings(NotificationApp* app) {
|
||||
@@ -723,7 +724,7 @@ static void notification_init_settings(NotificationApp* app) {
|
||||
int32_t notification_srv(void* p) {
|
||||
UNUSED(p);
|
||||
NotificationApp* app = notification_app_alloc();
|
||||
|
||||
app->rgb_srv = furi_record_open (RECORD_RGB_BACKLIGHT);
|
||||
notification_init_settings(app);
|
||||
|
||||
notification_vibro_off();
|
||||
@@ -748,8 +749,8 @@ int32_t notification_srv(void* p) {
|
||||
break;
|
||||
case SaveSettingsMessage:
|
||||
//call rgb_mod_timer_control (start or stop) when we save settings
|
||||
rgb_mod_rainbow_timer_starter(app);
|
||||
rgb_backlight_save_settings();
|
||||
rainbow_timer_starter(app->rgb_srv);
|
||||
rgb_backlight_settings_save(app->rgb_srv->settings);
|
||||
notification_save_settings(app);
|
||||
break;
|
||||
case LoadSettingsMessage:
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "notification.h"
|
||||
#include "notification_messages.h"
|
||||
#include "notification_settings_filename.h"
|
||||
#include "applications/services/rgb_backlight/rgb_backlight.h"
|
||||
|
||||
#define NOTIFICATION_LED_COUNT 3
|
||||
#define NOTIFICATION_EVENT_COMPLETE 0x00000001U
|
||||
@@ -45,10 +46,10 @@ typedef struct {
|
||||
int8_t contrast;
|
||||
bool vibro_on;
|
||||
/// --- RGB MOD SETTINGS SECTION ---
|
||||
bool rgb_mod_installed;
|
||||
uint32_t rgb_mod_rainbow_mode;
|
||||
uint32_t rgb_mod_rainbow_speed_ms;
|
||||
uint16_t rgb_mod_rainbow_step;
|
||||
// bool rgb_mod_installed;
|
||||
// uint32_t rgb_mod_rainbow_mode;
|
||||
// uint32_t rgb_mod_rainbow_speed_ms;
|
||||
// uint16_t rgb_mod_rainbow_step;
|
||||
/// --- END OF RGB MOD SETTINGS SECTION ---
|
||||
|
||||
} NotificationSettings;
|
||||
@@ -63,14 +64,15 @@ struct NotificationApp {
|
||||
uint8_t display_led_lock;
|
||||
|
||||
// --- RGB RAINBOW MODE VARIABLES SECTION ---
|
||||
FuriTimer* rgb_mod_rainbow_timer;
|
||||
int16_t rgb_mod_rainbow_red;
|
||||
int16_t rgb_mod_rainbow_green;
|
||||
int16_t rgb_mod_rainbow_blue;
|
||||
uint8_t rgb_mod_rainbow_stage;
|
||||
// FuriTimer* rgb_mod_rainbow_timer;
|
||||
// int16_t rgb_mod_rainbow_red;
|
||||
// int16_t rgb_mod_rainbow_green;
|
||||
// int16_t rgb_mod_rainbow_blue;
|
||||
// uint8_t rgb_mod_rainbow_stage;
|
||||
// --- ENd OF RGB RAINBOW MODE VARIABLES SECTION ---
|
||||
|
||||
NotificationSettings settings;
|
||||
RGBBacklightApp* rgb_srv;
|
||||
};
|
||||
|
||||
void notification_message_save_settings(NotificationApp* app);
|
||||
@@ -5,6 +5,6 @@ App(
|
||||
entry_point="rgb_backlight_srv",
|
||||
cdefines=["SRV_RGB_BACKLIGHT"],
|
||||
stack_size=1 * 1024,
|
||||
order=99,
|
||||
order=95,
|
||||
sdk_headers=["rgb_backlight.h"],
|
||||
)
|
||||
@@ -25,11 +25,11 @@
|
||||
#include "rgb_backlight.h"
|
||||
|
||||
|
||||
#define STATIC_COLOR_COUNT (sizeof(colors) / sizeof(RGBBacklightStaticColor))
|
||||
#define PREDEFINED_COLOR_COUNT (sizeof(colors) / sizeof(RGBBacklightPredefinedColor))
|
||||
|
||||
#define TAG "RGB_BACKLIGHT_SRV"
|
||||
|
||||
static const RGBBacklightStaticColor colors[] = {
|
||||
static const RGBBacklightPredefinedColor colors[] = {
|
||||
{"Orange", 255, 60, 0},
|
||||
{"Yellow", 255, 144, 0},
|
||||
{"Spring", 167, 255, 0},
|
||||
@@ -46,16 +46,89 @@ static const RGBBacklightStaticColor colors[] = {
|
||||
{"Custom", 0, 0, 0},
|
||||
};
|
||||
|
||||
void rgb_backlight_set_custom_color(uint8_t red, uint8_t green, uint8_t blue, float brightness) {
|
||||
uint8_t rgb_backlight_get_color_count(void) {
|
||||
return PREDEFINED_COLOR_COUNT;
|
||||
}
|
||||
|
||||
const char* rgb_backlight_get_color_text(uint8_t index) {
|
||||
return colors[index].name;
|
||||
}
|
||||
|
||||
|
||||
void rgb_backlight_set_static_color(uint8_t index, float brightness) {
|
||||
// use RECORD for acces to rgb service instance and use current_* colors and static colors
|
||||
RGBBacklightApp* app = furi_record_open(RECORD_RGB_BACKLIGHT);
|
||||
|
||||
for(uint8_t i = 0; i < SK6805_get_led_count(); i++) {
|
||||
uint8_t r = red * (brightness);
|
||||
uint8_t g = green * (brightness);
|
||||
uint8_t b = blue * (brightness);
|
||||
app->current_red = colors[index].red;
|
||||
app->current_green = colors[index].green;
|
||||
app->current_blue = colors[index].blue;
|
||||
|
||||
uint8_t r = app->current_red * brightness;
|
||||
uint8_t g = app->current_green * brightness;
|
||||
uint8_t b = app->current_blue * brightness;
|
||||
|
||||
SK6805_set_led_color(i, r, g, b);
|
||||
}
|
||||
|
||||
furi_record_close(RECORD_RGB_BACKLIGHT);
|
||||
SK6805_update();
|
||||
}
|
||||
|
||||
// void rgb_backlight_set_custom_color(uint8_t red, uint8_t green, uint8_t blue, float brightness) {
|
||||
// for(uint8_t i = 0; i < SK6805_get_led_count(); i++) {
|
||||
// uint8_t r = red * (brightness);
|
||||
// uint8_t g = green * (brightness);
|
||||
// uint8_t b = blue * (brightness);
|
||||
// SK6805_set_led_color(i, r, g, b);
|
||||
// }
|
||||
// SK6805_update();
|
||||
// }
|
||||
|
||||
// apply new brightness to current display color set
|
||||
void rgb_backlight_update (float brightness) {
|
||||
// use RECORD for acces to rgb service instance and use current_* colors
|
||||
RGBBacklightApp* app = furi_record_open(RECORD_RGB_BACKLIGHT);
|
||||
|
||||
for(uint8_t i = 0; i < SK6805_get_led_count(); i++) {
|
||||
uint8_t r = app->current_red * brightness;
|
||||
uint8_t g = app->current_green * brightness;
|
||||
uint8_t b = app->current_blue * brightness;
|
||||
SK6805_set_led_color(i, r, g, b);
|
||||
}
|
||||
|
||||
furi_record_close(RECORD_RGB_BACKLIGHT);
|
||||
SK6805_update();
|
||||
}
|
||||
//start furi timer for rainbow
|
||||
void rainbow_timer_start(RGBBacklightApp* app) {
|
||||
furi_timer_start(
|
||||
app->rainbow_timer, furi_ms_to_ticks(app->settings->rainbow_speed_ms));
|
||||
}
|
||||
|
||||
//stop furi timer for rainbow
|
||||
void rainbow_timer_stop(RGBBacklightApp* app) {
|
||||
furi_timer_stop(app->rainbow_timer);
|
||||
}
|
||||
|
||||
// if rgb_mod_installed then apply rainbow colors to backlight and start/restart/stop rainbow_timer
|
||||
void rainbow_timer_starter(RGBBacklightApp* app) {
|
||||
if(app->settings->rgb_mod_installed) {
|
||||
if(app->settings->rainbow_mode > 0) {
|
||||
// rgb_backlight_set_custom_color(
|
||||
// app->rainbow_red,
|
||||
// app->rainbow_green,
|
||||
// app->rainbow_blue,
|
||||
// app->settings->brightness);
|
||||
rainbow_timer_start(app);
|
||||
} else {
|
||||
if(furi_timer_is_running(app->rainbow_timer)) {
|
||||
rainbow_timer_stop(app);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void rainbow_timer_callback(void* context) {
|
||||
furi_assert(context);
|
||||
RGBBacklightApp* app = context;
|
||||
@@ -63,51 +136,51 @@ static void rainbow_timer_callback(void* context) {
|
||||
// if rgb_mode_rainbow_mode is rainbow do rainbow effect
|
||||
if(app->settings->rainbow_mode == 1) {
|
||||
switch(app->rainbow_stage) {
|
||||
// from red to yellow
|
||||
// from red to yellow (255,0,0) - (255,255,0)
|
||||
case 1:
|
||||
app->rainbow_green += app->settings->rainbow_step;
|
||||
if(app->rainbow_green >= 255) {
|
||||
app->rainbow_green = 255;
|
||||
app->current_green += app->settings->rainbow_step;
|
||||
if(app->current_green >= 255) {
|
||||
app->current_green = 255;
|
||||
app->rainbow_stage++;
|
||||
}
|
||||
break;
|
||||
// yellow red to green
|
||||
// yellow to green (255,255,0) - (0,255,0)
|
||||
case 2:
|
||||
app->rainbow_red -= app->settings->rainbow_step;
|
||||
if(app->rainbow_red <= 0) {
|
||||
app->rainbow_red = 0;
|
||||
app->current_red -= app->settings->rainbow_step;
|
||||
if(app->current_red <= 0) {
|
||||
app->current_red = 0;
|
||||
app->rainbow_stage++;
|
||||
}
|
||||
break;
|
||||
// from green to light blue
|
||||
// from green to light blue (0,255,0) - (0,255,255)
|
||||
case 3:
|
||||
app->rainbow_blue += app->settings->rainbow_step;
|
||||
if(app->rainbow_blue >= 255) {
|
||||
app->rainbow_blue = 255;
|
||||
app->current_blue += app->settings->rainbow_step;
|
||||
if(app->current_blue >= 255) {
|
||||
app->current_blue = 255;
|
||||
app->rainbow_stage++;
|
||||
}
|
||||
break;
|
||||
//from light blue to blue
|
||||
//from light blue to blue (0,255,255) - (0,0,255)
|
||||
case 4:
|
||||
app->rainbow_green -= app->settings->rainbow_step;
|
||||
if(app->rainbow_green <= 0) {
|
||||
app->rainbow_green = 0;
|
||||
app->current_green -= app->settings->rainbow_step;
|
||||
if(app->current_green <= 0) {
|
||||
app->current_green = 0;
|
||||
app->rainbow_stage++;
|
||||
}
|
||||
break;
|
||||
//from blue to violet
|
||||
//from blue to violet (0,0,255) - (255,0,255)
|
||||
case 5:
|
||||
app->rainbow_red += app->settings->rainbow_step;
|
||||
if(app->rainbow_red >= 255) {
|
||||
app->rainbow_red = 255;
|
||||
app->current_red += app->settings->rainbow_step;
|
||||
if(app->current_red >= 255) {
|
||||
app->current_red = 255;
|
||||
app->rainbow_stage++;
|
||||
}
|
||||
break;
|
||||
//from violet to red
|
||||
//from violet to red (255,0,255) - (255,0,0)
|
||||
case 6:
|
||||
app->rainbow_blue -= app->settings->rainbow_step;
|
||||
if(app->rainbow_blue <= 0) {
|
||||
app->rainbow_blue = 0;
|
||||
app->current_blue -= app->settings->rainbow_step;
|
||||
if(app->current_blue <= 0) {
|
||||
app->current_blue = 0;
|
||||
app->rainbow_stage = 1;
|
||||
}
|
||||
break;
|
||||
@@ -115,25 +188,23 @@ static void rainbow_timer_callback(void* context) {
|
||||
break;
|
||||
}
|
||||
|
||||
rgb_backlight_set_custom_color(
|
||||
app->rainbow_red,
|
||||
app->rainbow_green,
|
||||
app->rainbow_blue,
|
||||
app->settings->brightness);
|
||||
// rgb_backlight_set_custom_color(
|
||||
// app->current_red,
|
||||
// app->current_green,
|
||||
// app->current_blue,
|
||||
// app->settings->brightness);
|
||||
}
|
||||
|
||||
rgb_backlight_update (app->settings->brightness);
|
||||
|
||||
// if rgb_mode_rainbow_mode is ..... do another effect
|
||||
// if(app->settings.rainbow_mode == 2) {
|
||||
// }
|
||||
}
|
||||
|
||||
void rgb_backlight_settings_apply(RGBBacklightSettings* settings) {
|
||||
UNUSED (settings);
|
||||
//запуск таймера если все включено
|
||||
// применить сохраненые настройки цвета к дисплею статику или кастом если индекс=13
|
||||
}
|
||||
int32_t rgb_backlight_srv (void* p) {
|
||||
UNUSED(p);
|
||||
|
||||
int32_t rgb_backlight_srv (void* p){
|
||||
// Define object app (full app with settings and running variables),
|
||||
// allocate memory and create record for access to app structure from outside
|
||||
RGBBacklightApp* app = malloc(sizeof(RGBBacklightApp));
|
||||
@@ -143,11 +214,28 @@ int32_t rgb_backlight_srv (void* p){
|
||||
app->rainbow_timer =
|
||||
furi_timer_alloc(rainbow_timer_callback, FuriTimerTypePeriodic, app);
|
||||
|
||||
// load or init new settings and apply it
|
||||
// settings load or create default
|
||||
rgb_backlight_settings_load (app->settings);
|
||||
rgb_backlight_settings_apply (app->settings);
|
||||
|
||||
UNUSED(p);
|
||||
// Init app variables
|
||||
app->current_red = 255;
|
||||
app->current_green = 60;
|
||||
app->current_green = 0;
|
||||
app->rainbow_stage = 1;
|
||||
|
||||
// а нужно ли это все при старте сервиса, если мы получим сигнал на подсветку от Нотификейшена. Может вынести в ИНИТ и при старте нотиф дернуть его 1 раз
|
||||
// if rgb_mod_installed start rainbow or set static color from settings (default index = 0)
|
||||
if(app->settings->rgb_mod_installed) {
|
||||
if(app->settings->rainbow_mode > 0 ) {
|
||||
rainbow_timer_starter(app);
|
||||
} else {
|
||||
rgb_backlight_set_static_color(app->settings->static_color_index, app->settings->brightness);
|
||||
}
|
||||
// if not rgb_mod_installed set default static orange color (index=0)
|
||||
} else {
|
||||
rgb_backlight_set_static_color(0, app->settings->brightness);
|
||||
}
|
||||
|
||||
while(1) {
|
||||
FURI_LOG_I(TAG, "working");
|
||||
furi_delay_ms(2000);
|
||||
|
||||
@@ -17,23 +17,28 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <furi.h>
|
||||
#include "rgb_backlight_settings.h"
|
||||
#include "SK6805.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
uint8_t red;
|
||||
uint8_t green;
|
||||
uint8_t blue;
|
||||
} RGBBacklightStaticColor;
|
||||
} RGBBacklightPredefinedColor;
|
||||
|
||||
typedef struct {
|
||||
FuriTimer* rainbow_timer;
|
||||
|
||||
int16_t rainbow_red;
|
||||
int16_t rainbow_green;
|
||||
int16_t rainbow_blue;
|
||||
int16_t current_red;
|
||||
int16_t current_green;
|
||||
int16_t current_blue;
|
||||
uint8_t rainbow_stage;
|
||||
|
||||
RGBBacklightSettings* settings;
|
||||
@@ -42,3 +47,14 @@ typedef struct {
|
||||
|
||||
#define RECORD_RGB_BACKLIGHT "rgb_backlight"
|
||||
|
||||
void rgb_backlight_update (float brightness);
|
||||
void rgb_backlight_set_static_color(uint8_t index, float brightness);
|
||||
void rainbow_timer_stop(RGBBacklightApp* app);
|
||||
void rainbow_timer_start(RGBBacklightApp* app);
|
||||
void rainbow_timer_starter(RGBBacklightApp* app);
|
||||
const char* rgb_backlight_get_color_text(uint8_t index);
|
||||
uint8_t rgb_backlight_get_color_count(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -17,7 +17,7 @@ typedef struct {
|
||||
uint8_t version;
|
||||
bool rgb_mod_installed;
|
||||
|
||||
uint8_t display_static_color_index;
|
||||
uint8_t static_color_index;
|
||||
uint8_t custom_r;
|
||||
uint8_t custom_g;
|
||||
uint8_t custom_b;
|
||||
|
||||
@@ -7,10 +7,10 @@ typedef struct {
|
||||
uint8_t version;
|
||||
bool rgb_mod_installed;
|
||||
|
||||
uint8_t display_static_color_index;
|
||||
uint8_t custom_r;
|
||||
uint8_t custom_g;
|
||||
uint8_t custom_b;
|
||||
uint8_t static_color_index;
|
||||
uint8_t custom_red;
|
||||
uint8_t custom_green;
|
||||
uint8_t custom_blue;
|
||||
float brightness;
|
||||
|
||||
uint32_t rainbow_mode;
|
||||
|
||||
Reference in New Issue
Block a user