2021-05-24 23:44:14 +10:00
|
|
|
#include <furi.h>
|
2022-01-05 19:10:18 +03:00
|
|
|
#include <furi_hal.h>
|
2021-05-24 23:44:14 +10:00
|
|
|
#include "notification.h"
|
2022-01-05 19:10:18 +03:00
|
|
|
#include "notification_messages.h"
|
2022-07-26 15:21:51 +03:00
|
|
|
#include "notification_settings_filename.h"
|
2025-04-10 18:01:47 +07:00
|
|
|
#include <SK6805.h>
|
|
|
|
|
#include <math.h>
|
2021-05-24 23:44:14 +10:00
|
|
|
|
2024-07-15 20:02:45 +03:00
|
|
|
#define NOTIFICATION_LED_COUNT 3
|
2021-05-24 23:44:14 +10:00
|
|
|
#define NOTIFICATION_EVENT_COMPLETE 0x00000001U
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
|
NotificationLayerMessage,
|
|
|
|
|
InternalLayerMessage,
|
2021-07-05 08:03:56 +10:00
|
|
|
SaveSettingsMessage,
|
2024-08-10 13:18:51 +03:00
|
|
|
LoadSettingsMessage,
|
2021-05-24 23:44:14 +10:00
|
|
|
} NotificationAppMessageType;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
const NotificationSequence* sequence;
|
|
|
|
|
NotificationAppMessageType type;
|
2022-07-20 13:56:33 +03:00
|
|
|
FuriEventFlag* back_event;
|
2021-05-24 23:44:14 +10:00
|
|
|
} NotificationAppMessage;
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
|
LayerInternal = 0,
|
|
|
|
|
LayerNotification = 1,
|
|
|
|
|
LayerMAX = 2,
|
|
|
|
|
} NotificationLedLayerIndex;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2022-04-21 15:33:03 +03:00
|
|
|
uint8_t value_last[LayerMAX];
|
2021-05-24 23:44:14 +10:00
|
|
|
uint8_t value[LayerMAX];
|
|
|
|
|
NotificationLedLayerIndex index;
|
|
|
|
|
Light light;
|
|
|
|
|
} NotificationLedLayer;
|
|
|
|
|
|
2025-04-10 23:44:57 +07:00
|
|
|
#define NOTIFICATION_SETTINGS_VERSION 0x05
|
2024-07-15 20:02:45 +03:00
|
|
|
#define NOTIFICATION_SETTINGS_PATH INT_PATH(NOTIFICATION_SETTINGS_FILE_NAME)
|
2021-07-05 08:03:56 +10:00
|
|
|
|
2025-04-10 18:01:47 +07:00
|
|
|
typedef struct {
|
|
|
|
|
//Common settings
|
|
|
|
|
uint8_t rgb_backlight_installed;
|
|
|
|
|
|
|
|
|
|
// static gradient mode settings
|
|
|
|
|
uint8_t led_2_color_index;
|
|
|
|
|
uint8_t led_1_color_index;
|
|
|
|
|
uint8_t led_0_color_index;
|
|
|
|
|
|
|
|
|
|
// rainbow mode setings
|
|
|
|
|
uint32_t rainbow_mode;
|
|
|
|
|
uint32_t rainbow_speed_ms;
|
|
|
|
|
uint16_t rainbow_step;
|
|
|
|
|
uint8_t rainbow_saturation;
|
|
|
|
|
uint8_t rainbow_wide;
|
|
|
|
|
} RGBBacklightSettings;
|
|
|
|
|
|
2021-05-24 23:44:14 +10:00
|
|
|
typedef struct {
|
2021-07-05 08:03:56 +10:00
|
|
|
uint8_t version;
|
2021-05-24 23:44:14 +10:00
|
|
|
float display_brightness;
|
|
|
|
|
float led_brightness;
|
2021-06-29 00:42:30 +10:00
|
|
|
float speaker_volume;
|
2021-05-24 23:44:14 +10:00
|
|
|
uint32_t display_off_delay_ms;
|
2023-06-07 02:46:01 +09:00
|
|
|
int8_t contrast;
|
2021-07-05 08:03:56 +10:00
|
|
|
bool vibro_on;
|
2025-03-26 18:51:36 +07:00
|
|
|
float night_shift;
|
|
|
|
|
uint32_t night_shift_start;
|
2025-03-28 14:02:12 +03:00
|
|
|
uint32_t night_shift_end;
|
2025-04-10 00:55:02 +07:00
|
|
|
bool lcd_inversion;
|
2025-04-10 18:01:47 +07:00
|
|
|
RGBBacklightSettings rgb;
|
2021-05-24 23:44:14 +10:00
|
|
|
} NotificationSettings;
|
|
|
|
|
|
|
|
|
|
struct NotificationApp {
|
2022-07-20 13:56:33 +03:00
|
|
|
FuriMessageQueue* queue;
|
2021-11-01 23:35:54 +03:00
|
|
|
FuriPubSub* event_record;
|
2022-07-20 13:56:33 +03:00
|
|
|
FuriTimer* display_timer;
|
2021-05-24 23:44:14 +10:00
|
|
|
|
|
|
|
|
NotificationLedLayer display;
|
|
|
|
|
NotificationLedLayer led[NOTIFICATION_LED_COUNT];
|
2025-10-31 12:28:08 +03:00
|
|
|
bool display_led_lock;
|
2021-05-24 23:44:14 +10:00
|
|
|
|
|
|
|
|
NotificationSettings settings;
|
2025-03-28 01:14:57 +07:00
|
|
|
|
|
|
|
|
FuriTimer* night_shift_timer;
|
|
|
|
|
float current_night_shift;
|
2025-04-10 18:01:47 +07:00
|
|
|
|
|
|
|
|
FuriTimer* rainbow_timer;
|
|
|
|
|
uint16_t rainbow_hue;
|
|
|
|
|
uint8_t rainbow_red;
|
|
|
|
|
uint8_t rainbow_green;
|
|
|
|
|
uint8_t rainbow_blue;
|
2021-07-05 08:03:56 +10:00
|
|
|
};
|
|
|
|
|
|
2025-03-15 08:14:00 +03:00
|
|
|
void notification_message_save_settings(NotificationApp* app);
|
2025-03-28 01:14:57 +07:00
|
|
|
void night_shift_timer_start(NotificationApp* app);
|
|
|
|
|
void night_shift_timer_stop(NotificationApp* app);
|
2025-04-10 18:01:47 +07:00
|
|
|
void rgb_backlight_update(float brightness);
|
|
|
|
|
void rgb_backlight_set_led_static_color(uint8_t led, uint8_t index);
|
|
|
|
|
void rainbow_timer_start(NotificationApp* app);
|
|
|
|
|
void rainbow_timer_stop(NotificationApp* app);
|
|
|
|
|
void rainbow_timer_starter(NotificationApp* app);
|
|
|
|
|
const char* rgb_backlight_get_color_text(uint8_t index);
|
2025-04-10 23:44:57 +07:00
|
|
|
uint8_t rgb_backlight_get_color_count(void);
|
|
|
|
|
void set_rgb_backlight_installed_variable(uint8_t var);
|