diff --git a/applications/services/input/input_settings.c b/applications/services/input/input_settings.c
index cd3de6d50..f1f18ba3d 100644
--- a/applications/services/input/input_settings.c
+++ b/applications/services/input/input_settings.c
@@ -30,7 +30,6 @@ void input_settings_load(InputSettings* settings) {
sizeof(InputSettings),
INPUT_SETTINGS_MAGIC,
INPUT_SETTINGS_VER);
- // if config previous version - load it and inicialize new settings
}
// in case of another config version we exit from useless cycle to next step
} while(false);
diff --git a/applications/services/rgb_backlight/application.fam b/applications/services/rgb_backlight/application.fam
index 168a7bbd0..bb42d7b83 100644
--- a/applications/services/rgb_backlight/application.fam
+++ b/applications/services/rgb_backlight/application.fam
@@ -7,5 +7,4 @@ App(
stack_size=1 * 1024,
order=99,
sdk_headers=["rgb_backlight.h"],
- provides=["rgb_backlight_settings"],
)
\ No newline at end of file
diff --git a/applications/services/rgb_backlight/rgb_backlight.c b/applications/services/rgb_backlight/rgb_backlight.c
index 046cd4771..f198ae13f 100644
--- a/applications/services/rgb_backlight/rgb_backlight.c
+++ b/applications/services/rgb_backlight/rgb_backlight.c
@@ -1,15 +1,156 @@
+/*
+ RGB BackLight Service based on
+ RGB backlight FlipperZero driver
+ Copyright (C) 2022-2023 Victor Nikitchuk (https://github.com/quen0n)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
#include
#include
#include
+#include
+#include
#include "rgb_backlight.h"
+
+#define STATIC_COLOR_COUNT (sizeof(colors) / sizeof(RGBBacklightStaticColor))
+
#define TAG "RGB_BACKLIGHT_SRV"
-int32_t rgb_backlight_srv (void* p){
-UNUSED (p);
-while (1){
- FURI_LOG_I (TAG,"working");
- furi_delay_ms (2000);
+static const RGBBacklightStaticColor colors[] = {
+ {"Orange", 255, 60, 0},
+ {"Yellow", 255, 144, 0},
+ {"Spring", 167, 255, 0},
+ {"Lime", 0, 255, 0},
+ {"Aqua", 0, 255, 127},
+ {"Cyan", 0, 210, 210},
+ {"Azure", 0, 127, 255},
+ {"Blue", 0, 0, 255},
+ {"Purple", 127, 0, 255},
+ {"Magenta", 210, 0, 210},
+ {"Pink", 255, 0, 127},
+ {"Red", 255, 0, 0},
+ {"White", 254, 210, 200},
+ {"Custom", 0, 0, 0},
+};
+
+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();
}
-return 0;
+
+static void rainbow_timer_callback(void* context) {
+ furi_assert(context);
+ RGBBacklightApp* app = 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
+ case 1:
+ app->rainbow_green += app->settings->rainbow_step;
+ if(app->rainbow_green >= 255) {
+ app->rainbow_green = 255;
+ app->rainbow_stage++;
+ }
+ break;
+ // yellow red to green
+ case 2:
+ app->rainbow_red -= app->settings->rainbow_step;
+ if(app->rainbow_red <= 0) {
+ app->rainbow_red = 0;
+ app->rainbow_stage++;
+ }
+ break;
+ // from green to light blue
+ case 3:
+ app->rainbow_blue += app->settings->rainbow_step;
+ if(app->rainbow_blue >= 255) {
+ app->rainbow_blue = 255;
+ app->rainbow_stage++;
+ }
+ break;
+ //from light blue to blue
+ case 4:
+ app->rainbow_green -= app->settings->rainbow_step;
+ if(app->rainbow_green <= 0) {
+ app->rainbow_green = 0;
+ app->rainbow_stage++;
+ }
+ break;
+ //from blue to violet
+ case 5:
+ app->rainbow_red += app->settings->rainbow_step;
+ if(app->rainbow_red >= 255) {
+ app->rainbow_red = 255;
+ app->rainbow_stage++;
+ }
+ break;
+ //from violet to red
+ case 6:
+ app->rainbow_blue -= app->settings->rainbow_step;
+ if(app->rainbow_blue <= 0) {
+ app->rainbow_blue = 0;
+ app->rainbow_stage = 1;
+ }
+ break;
+ default:
+ break;
+ }
+
+ rgb_backlight_set_custom_color(
+ app->rainbow_red,
+ app->rainbow_green,
+ app->rainbow_blue,
+ 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){
+ // 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));
+ furi_record_create(RECORD_RGB_BACKLIGHT, app);
+
+ //define rainbow_timer and they callback
+ app->rainbow_timer =
+ furi_timer_alloc(rainbow_timer_callback, FuriTimerTypePeriodic, app);
+
+ // load or init new settings and apply it
+ rgb_backlight_settings_load (app->settings);
+ rgb_backlight_settings_apply (app->settings);
+
+ UNUSED(p);
+ while(1) {
+ FURI_LOG_I(TAG, "working");
+ furi_delay_ms(2000);
+ }
+ return 0;
}
\ No newline at end of file
diff --git a/applications/services/rgb_backlight/rgb_backlight.h b/applications/services/rgb_backlight/rgb_backlight.h
index e69de29bb..88f3270c1 100644
--- a/applications/services/rgb_backlight/rgb_backlight.h
+++ b/applications/services/rgb_backlight/rgb_backlight.h
@@ -0,0 +1,44 @@
+/*
+ RGB BackLight Service based on
+ RGB backlight FlipperZero driver
+ Copyright (C) 2022-2023 Victor Nikitchuk (https://github.com/quen0n)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+#include
+#include "rgb_backlight_settings.h"
+#include "SK6805.h"
+
+typedef struct {
+ char* name;
+ uint8_t red;
+ uint8_t green;
+ uint8_t blue;
+} RGBBacklightStaticColor;
+
+typedef struct {
+ FuriTimer* rainbow_timer;
+
+ int16_t rainbow_red;
+ int16_t rainbow_green;
+ int16_t rainbow_blue;
+ uint8_t rainbow_stage;
+
+ RGBBacklightSettings* settings;
+
+} RGBBacklightApp;
+
+#define RECORD_RGB_BACKLIGHT "rgb_backlight"
+
diff --git a/applications/services/rgb_backlight/rgb_backlight_settings.c b/applications/services/rgb_backlight/rgb_backlight_settings.c
new file mode 100644
index 000000000..62cc47994
--- /dev/null
+++ b/applications/services/rgb_backlight/rgb_backlight_settings.c
@@ -0,0 +1,95 @@
+#include "rgb_backlight_settings.h"
+
+#include
+#include
+
+#define TAG "RGBBackligthSettings"
+
+#define RGB_BACKLIGHT_SETTINGS_FILE_NAME ".rgb_backlight.settings"
+#define RGB_BACKLIGHT_SETTINGS_PATH INT_PATH(RGB_BACKLIGHT_SETTINGS_FILE_NAME)
+
+#define RGB_BACKLIGHT_SETTINGS_MAGIC (0x30)
+#define RGB_BACKLIGHT_SETTINGS_VER_PREV (0) // Previous version number
+#define RGB_BACKLIGHT_SETTINGS_VER (1) // New version number
+
+//pervious settings must be copyed from previous rgb_backlight_settings.h file
+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;
+
+ uint32_t rainbow_mode;
+ uint32_t rainbow_speed_ms;
+ uint16_t rainbow_step;
+} RGBBacklightSettingsPrevious;
+
+void rgb_backlight_settings_load(RGBBacklightSettings* settings) {
+ furi_assert(settings);
+
+ bool success = false;
+
+ //a useless cycle do-while, may will be used in future with anoter condition
+ do {
+ // take version from settings file metadata, if cant then break and fill settings with 0 and save to settings file;
+ uint8_t version;
+ if(!saved_struct_get_metadata(RGB_BACKLIGHT_SETTINGS_PATH, NULL, &version, NULL)) break;
+
+ // if config actual version - load it directly
+ if(version == RGB_BACKLIGHT_SETTINGS_VER) {
+ success = saved_struct_load(
+ RGB_BACKLIGHT_SETTINGS_PATH,
+ settings,
+ sizeof(RGBBacklightSettings),
+ RGB_BACKLIGHT_SETTINGS_MAGIC,
+ RGB_BACKLIGHT_SETTINGS_VER);
+ // if config previous version - load it and inicialize new settings
+ } else if(version == RGB_BACKLIGHT_SETTINGS_VER_PREV) {
+ RGBBacklightSettingsPrevious* settings_previous = malloc(sizeof(RGBBacklightSettingsPrevious));
+
+ success = saved_struct_load(
+ RGB_BACKLIGHT_SETTINGS_PATH,
+ settings_previous,
+ sizeof(RGBBacklightSettingsPrevious),
+ RGB_BACKLIGHT_SETTINGS_MAGIC,
+ RGB_BACKLIGHT_SETTINGS_VER_PREV);
+ // new settings initialization
+ if(success) {
+ // copy loaded old settings as part of new
+ uint32_t size = sizeof(settings);
+ memcpy(settings, settings_previous, size);
+ // set new options to initial value
+ // settings.something = something;
+ }
+
+ free(settings_previous);
+ }
+ // in case of another config version we exit from useless cycle to next step
+ } while(false);
+
+ // fill settings with 0 and save to settings file;
+ // Orange color (index=0) will be default
+ if(!success) {
+ FURI_LOG_W(TAG, "Failed to load file, using defaults 0");
+ memset(settings, 0, sizeof(RGBBacklightSettings));
+ rgb_backlight_settings_save(settings);
+ }
+}
+
+void rgb_backlight_settings_save(const RGBBacklightSettings* settings) {
+ furi_assert(settings);
+
+ const bool success = saved_struct_save(
+ RGB_BACKLIGHT_SETTINGS_PATH,
+ settings,
+ sizeof(RGBBacklightSettings),
+ RGB_BACKLIGHT_SETTINGS_MAGIC,
+ RGB_BACKLIGHT_SETTINGS_VER);
+
+ if(!success) {
+ FURI_LOG_E(TAG, "Failed to save rgb_backlight_settings file");
+ }
+}
diff --git a/applications/services/rgb_backlight/rgb_backlight_settings.h b/applications/services/rgb_backlight/rgb_backlight_settings.h
new file mode 100644
index 000000000..f7a4af177
--- /dev/null
+++ b/applications/services/rgb_backlight/rgb_backlight_settings.h
@@ -0,0 +1,31 @@
+#pragma once
+
+#include
+#include
+
+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;
+ float brightness;
+
+ uint32_t rainbow_mode;
+ uint32_t rainbow_speed_ms;
+ uint16_t rainbow_step;
+
+} RGBBacklightSettings;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void rgb_backlight_settings_load(RGBBacklightSettings* settings);
+void rgb_backlight_settings_save(const RGBBacklightSettings* settings);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/applications/settings/application.fam b/applications/settings/application.fam
index 8e184a706..2ad4aa030 100644
--- a/applications/settings/application.fam
+++ b/applications/settings/application.fam
@@ -7,7 +7,6 @@ App(
"system_settings",
"clock_settings",
"input_settings",
- "rgb_backlight_settings",
"about",
],
)
diff --git a/applications/settings/rgb_backlight_settings/application.fam b/applications/settings/rgb_backlight_settings/application.fam
deleted file mode 100644
index 50621228a..000000000
--- a/applications/settings/rgb_backlight_settings/application.fam
+++ /dev/null
@@ -1,9 +0,0 @@
-App(
- appid="rgb_backlight_settings",
- name="RGB backlight",
- apptype=FlipperAppType.SETTINGS,
- entry_point="rgb_backlight_settings",
- requires=["rgb_backlight"],
- stack_size=1 * 1024,
- order=110,
-)
\ No newline at end of file
diff --git a/applications/settings/rgb_backlight_settings/rgb_backlight_settings.c b/applications/settings/rgb_backlight_settings/rgb_backlight_settings.c
deleted file mode 100644
index 096852063..000000000
--- a/applications/settings/rgb_backlight_settings/rgb_backlight_settings.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include
-#include
-#include
-#include "rgb_backlight_settings.h"
-
-#define TAG "RGB_BACKLIGHT_SETTINGS"
-
-int32_t rgb_backlight_settings (void* p){
-UNUSED (p);
-FURI_LOG_I (TAG,"Settings");
-furi_delay_ms (2000);
-return 0;
-}
\ No newline at end of file
diff --git a/applications/settings/rgb_backlight_settings/rgb_backlight_settings.h b/applications/settings/rgb_backlight_settings/rgb_backlight_settings.h
deleted file mode 100644
index e69de29bb..000000000
diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv
index f78775215..310a669ef 100644
--- a/targets/f7/api_symbols.csv
+++ b/targets/f7/api_symbols.csv
@@ -1,5 +1,5 @@
entry,status,name,type,params
-Version,+,83.0,,
+Version,+,83.1,,
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
Header,+,applications/services/bt/bt_service/bt.h,,
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
@@ -411,6 +411,10 @@ Function,-,LL_mDelay,void,uint32_t
Function,-,Osal_MemCmp,int,"const void*, const void*, unsigned int"
Function,-,Osal_MemCpy,void*,"void*, const void*, unsigned int"
Function,-,Osal_MemSet,void*,"void*, int, unsigned int"
+Function,+,SK6805_get_led_count,uint8_t,
+Function,+,SK6805_init,void,
+Function,+,SK6805_set_led_color,void,"uint8_t, uint8_t, uint8_t, uint8_t"
+Function,+,SK6805_update,void,
Function,-,SystemCoreClockUpdate,void,
Function,-,SystemInit,void,
Function,-,_Exit,void,int
@@ -3139,6 +3143,8 @@ Function,-,remquol,long double,"long double, long double, int*"
Function,-,rename,int,"const char*, const char*"
Function,-,renameat,int,"int, const char*, int, const char*"
Function,-,rewind,void,FILE*
+Function,+,rgb_backlight_settings_load,void,RGBBacklightSettings*
+Function,+,rgb_backlight_settings_save,void,const RGBBacklightSettings*
Function,-,rindex,char*,"const char*, int"
Function,-,rint,double,double
Function,-,rintf,float,float