mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-16 04:24:45 -07:00
Integrate RGB backlight into API + add to xfw app
This commit is contained in:
@@ -12,15 +12,6 @@ void xtreme_app_scene_misc_var_item_list_callback(void* context, uint32_t index)
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
|
||||
static void xtreme_app_scene_misc_rgb_backlight_changed(VariableItem* item) {
|
||||
XtremeApp* app = variable_item_get_context(item);
|
||||
bool value = variable_item_get_current_value_index(item);
|
||||
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
|
||||
XTREME_SETTINGS()->rgb_backlight = value;
|
||||
app->save_settings = true;
|
||||
app->require_reboot = true;
|
||||
}
|
||||
|
||||
static void xtreme_app_scene_misc_xp_level_changed(VariableItem* item) {
|
||||
XtremeApp* app = variable_item_get_context(item);
|
||||
app->xp_level = variable_item_get_current_value_index(item) + 1;
|
||||
@@ -30,6 +21,23 @@ static void xtreme_app_scene_misc_xp_level_changed(VariableItem* item) {
|
||||
app->save_level = true;
|
||||
}
|
||||
|
||||
static void xtreme_app_scene_misc_rgb_backlight_changed(VariableItem* item) {
|
||||
XtremeApp* app = variable_item_get_context(item);
|
||||
bool value = variable_item_get_current_value_index(item);
|
||||
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
|
||||
XTREME_SETTINGS()->rgb_backlight = value;
|
||||
app->save_settings = true;
|
||||
notification_message(app->notification, &sequence_display_backlight_on);
|
||||
}
|
||||
|
||||
static void xtreme_app_scene_misc_lcd_color_changed(VariableItem* item) {
|
||||
XtremeApp* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
variable_item_set_current_value_text(item, rgb_backlight_get_color_text(index));
|
||||
rgb_backlight_set_color(index);
|
||||
notification_message(app->notification, &sequence_display_backlight_on);
|
||||
}
|
||||
|
||||
const char* const butthurt_timer_names[] =
|
||||
{"OFF", "30 M", "1 H", "2 H", "4 H", "6 H", "8 H", "12 H", "24 H", "48 H"};
|
||||
const int32_t butthurt_timer_values[COUNT_OF(butthurt_timer_names)] =
|
||||
@@ -52,11 +60,6 @@ void xtreme_app_scene_misc_on_enter(void* context) {
|
||||
|
||||
variable_item_list_add(var_item_list, "Change Device Name", 0, NULL, app);
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list, "RGB Backlight", 2, xtreme_app_scene_misc_rgb_backlight_changed, app);
|
||||
variable_item_set_current_value_index(item, xtreme_settings->rgb_backlight);
|
||||
variable_item_set_current_value_text(item, xtreme_settings->rgb_backlight ? "ON" : "OFF");
|
||||
|
||||
char level_str[4];
|
||||
snprintf(level_str, 4, "%li", app->xp_level);
|
||||
item = variable_item_list_add(
|
||||
@@ -79,6 +82,18 @@ void xtreme_app_scene_misc_on_enter(void* context) {
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, butthurt_timer_names[value_index]);
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list, "RGB Backlight", 2, xtreme_app_scene_misc_rgb_backlight_changed, app);
|
||||
variable_item_set_current_value_index(item, xtreme_settings->rgb_backlight);
|
||||
variable_item_set_current_value_text(item, xtreme_settings->rgb_backlight ? "ON" : "OFF");
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list, "LCD Color", rgb_backlight_get_color_count(), xtreme_app_scene_misc_lcd_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));
|
||||
variable_item_set_locked(item, !xtreme_settings->rgb_backlight, "Needs RGB\nBacklight!");
|
||||
|
||||
variable_item_list_set_enter_callback(
|
||||
var_item_list, xtreme_app_scene_misc_var_item_list_callback, app);
|
||||
|
||||
|
||||
@@ -139,6 +139,7 @@ XtremeApp* xtreme_app_alloc() {
|
||||
XtremeApp* app = malloc(sizeof(XtremeApp));
|
||||
app->gui = furi_record_open(RECORD_GUI);
|
||||
app->dialogs = furi_record_open(RECORD_DIALOGS);
|
||||
app->notification = furi_record_open(RECORD_NOTIFICATION);
|
||||
|
||||
// View Dispatcher and Scene Manager
|
||||
app->view_dispatcher = view_dispatcher_alloc();
|
||||
@@ -301,6 +302,7 @@ void xtreme_app_free(XtremeApp* app) {
|
||||
furi_string_free(app->version_tag);
|
||||
|
||||
// Records
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
furi_record_close(RECORD_DIALOGS);
|
||||
furi_record_close(RECORD_GUI);
|
||||
free(app);
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include <lib/flipper_format/flipper_format.h>
|
||||
#include <lib/subghz/subghz_setting.h>
|
||||
#include <applications/main/fap_loader/fap_loader_app.h>
|
||||
#include <notification/notification_app.h>
|
||||
#include <rgb_backlight/rgb_backlight.h>
|
||||
#include <m-array.h>
|
||||
#include "xtreme/settings.h"
|
||||
#include "xtreme/assets.h"
|
||||
@@ -31,6 +33,7 @@ ARRAY_DEF(CharList, char*)
|
||||
typedef struct {
|
||||
Gui* gui;
|
||||
DialogsApp* dialogs;
|
||||
NotificationApp* notification;
|
||||
SceneManager* scene_manager;
|
||||
ViewDispatcher* view_dispatcher;
|
||||
VariableItemList* var_item_list;
|
||||
|
||||
@@ -10,6 +10,7 @@ App(
|
||||
"desktop",
|
||||
"loader",
|
||||
"power",
|
||||
"rgb_backlight",
|
||||
"namechangersrv",
|
||||
],
|
||||
)
|
||||
|
||||
9
applications/services/rgb_backlight/application.fam
Normal file
9
applications/services/rgb_backlight/application.fam
Normal file
@@ -0,0 +1,9 @@
|
||||
App(
|
||||
appid="rgb_backlight",
|
||||
name="RGB Backlight",
|
||||
apptype=FlipperAppType.SERVICE,
|
||||
entry_point="rgb_backlight_srv",
|
||||
sdk_headers=[
|
||||
"rgb_backlight.h",
|
||||
],
|
||||
)
|
||||
@@ -174,3 +174,8 @@ void rgb_backlight_update(uint8_t brightness) {
|
||||
|
||||
SK6805_update();
|
||||
}
|
||||
|
||||
int32_t rgb_backlight_srv(void* p) {
|
||||
UNUSED(p);
|
||||
return 0;
|
||||
}
|
||||
@@ -19,6 +19,10 @@
|
||||
#include <furi.h>
|
||||
#include "SK6805.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
uint8_t red;
|
||||
@@ -77,3 +81,7 @@ uint8_t rgb_backlight_get_color_count(void);
|
||||
* @return Указатель на строку с названием цвета
|
||||
*/
|
||||
const char* rgb_backlight_get_color_text(uint8_t index);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <gui/modules/variable_item_list.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <lib/toolbox/value_index.h>
|
||||
#include "rgb_backlight.h"
|
||||
|
||||
#define MAX_NOTIFICATION_SETTINGS 4
|
||||
|
||||
@@ -120,14 +119,6 @@ static void vibro_changed(VariableItem* item) {
|
||||
notification_message(app->notification, &sequence_single_vibro);
|
||||
}
|
||||
|
||||
static void color_changed(VariableItem* item) {
|
||||
NotificationAppSettings* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
rgb_backlight_set_color(index);
|
||||
variable_item_set_current_value_text(item, rgb_backlight_get_color_text(index));
|
||||
notification_message(app->notification, &sequence_display_backlight_on);
|
||||
}
|
||||
|
||||
static uint32_t notification_app_settings_exit(void* context) {
|
||||
UNUSED(context);
|
||||
return VIEW_NONE;
|
||||
@@ -145,12 +136,6 @@ static NotificationAppSettings* alloc_settings() {
|
||||
VariableItem* item;
|
||||
uint8_t value_index;
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list, "LCD Color", 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));
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list, "LCD Brightness", BACKLIGHT_COUNT, backlight_changed, app);
|
||||
value_index = value_index_float(
|
||||
|
||||
@@ -37,6 +37,7 @@ Header,+,applications/services/locale/locale.h,,
|
||||
Header,+,applications/services/notification/notification.h,,
|
||||
Header,+,applications/services/notification/notification_messages.h,,
|
||||
Header,+,applications/services/power/power_service/power.h,,
|
||||
Header,+,applications/services/rgb_backlight/rgb_backlight.h,,
|
||||
Header,+,applications/services/rpc/rpc_app.h,,
|
||||
Header,+,applications/services/storage/storage.h,,
|
||||
Header,+,applications/services/xtreme/assets.h,,
|
||||
@@ -314,6 +315,10 @@ Function,-,LL_USART_DeInit,ErrorStatus,USART_TypeDef*
|
||||
Function,+,LL_USART_Init,ErrorStatus,"USART_TypeDef*, LL_USART_InitTypeDef*"
|
||||
Function,-,LL_USART_StructInit,void,LL_USART_InitTypeDef*
|
||||
Function,-,LL_mDelay,void,uint32_t
|
||||
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,+,XTREME_ASSETS,XtremeAssets*,
|
||||
@@ -2516,6 +2521,13 @@ Function,-,rfal_platform_spi_acquire,void,
|
||||
Function,-,rfal_platform_spi_release,void,
|
||||
Function,-,rfal_set_callback_context,void,void*
|
||||
Function,-,rfal_set_state_changed_callback,void,RfalStateChangedCallback
|
||||
Function,+,rgb_backlight_get_color_count,uint8_t,
|
||||
Function,+,rgb_backlight_get_color_text,const char*,uint8_t
|
||||
Function,+,rgb_backlight_get_settings,RGBBacklightSettings*,
|
||||
Function,-,rgb_backlight_load_settings,void,
|
||||
Function,-,rgb_backlight_save_settings,void,
|
||||
Function,+,rgb_backlight_set_color,void,uint8_t
|
||||
Function,-,rgb_backlight_update,void,uint8_t
|
||||
Function,-,rindex,char*,"const char*, int"
|
||||
Function,-,rint,double,double
|
||||
Function,-,rintf,float,float
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#include <lp5562.h>
|
||||
#include <stdint.h>
|
||||
#include <xtreme/settings.h>
|
||||
#include <applications/settings/notification_settings/rgb_backlight.h>
|
||||
#include <rgb_backlight/rgb_backlight.h>
|
||||
|
||||
#define LED_CURRENT_RED 50
|
||||
#define LED_CURRENT_GREEN 50
|
||||
|
||||
Reference in New Issue
Block a user