Merge branch 'ofw-dev' into dev

This commit is contained in:
MX
2023-06-07 00:29:06 +03:00
69 changed files with 672 additions and 90 deletions

View File

@@ -75,6 +75,8 @@ typedef enum {
NotificationMessageTypeForceDisplayBrightnessSetting,
NotificationMessageTypeLedBrightnessSettingApply,
NotificationMessageTypeLcdContrastUpdate,
} NotificationMessageType;
typedef struct {

View File

@@ -3,6 +3,9 @@
#include <furi_hal.h>
#include <storage/storage.h>
#include <input/input.h>
#include <gui/gui_i.h>
#include <u8g2_glue.h>
#include "notification.h"
#include "notification_messages.h"
#include "notification_app.h"
@@ -20,14 +23,14 @@ static const uint8_t reset_sound_mask = 1 << 4;
static const uint8_t reset_display_mask = 1 << 5;
static const uint8_t reset_blink_mask = 1 << 6;
void notification_vibro_on(bool force);
void notification_vibro_off();
void notification_sound_on(float freq, float volume, bool force);
void notification_sound_off();
static void notification_vibro_on(bool force);
static void notification_vibro_off();
static void notification_sound_on(float freq, float volume, bool force);
static void notification_sound_off();
uint8_t notification_settings_get_display_brightness(NotificationApp* app, uint8_t value);
uint8_t notification_settings_get_rgb_led_brightness(NotificationApp* app, uint8_t value);
uint32_t notification_settings_display_off_delay_ticks(NotificationApp* app);
static uint8_t notification_settings_get_display_brightness(NotificationApp* app, uint8_t value);
static uint8_t notification_settings_get_rgb_led_brightness(NotificationApp* app, uint8_t value);
static uint32_t notification_settings_display_off_delay_ticks(NotificationApp* app);
void notification_message_save_settings(NotificationApp* app) {
NotificationAppMessage m = {
@@ -39,7 +42,8 @@ void notification_message_save_settings(NotificationApp* app) {
};
// internal layer
void notification_apply_internal_led_layer(NotificationLedLayer* layer, uint8_t layer_value) {
static void
notification_apply_internal_led_layer(NotificationLedLayer* layer, uint8_t layer_value) {
furi_assert(layer);
furi_assert(layer->index < LayerMAX);
@@ -52,7 +56,13 @@ void notification_apply_internal_led_layer(NotificationLedLayer* layer, uint8_t
}
}
bool notification_is_any_led_layer_internal_and_not_empty(NotificationApp* app) {
static void notification_apply_lcd_contrast(NotificationApp* app) {
Gui* gui = furi_record_open(RECORD_GUI);
u8x8_d_st756x_set_contrast(&gui->canvas->fb.u8x8, app->settings.contrast);
furi_record_close(RECORD_GUI);
}
static bool notification_is_any_led_layer_internal_and_not_empty(NotificationApp* app) {
bool result = false;
if((app->led[0].index == LayerInternal) || (app->led[1].index == LayerInternal) ||
(app->led[2].index == LayerInternal)) {
@@ -67,7 +77,7 @@ bool notification_is_any_led_layer_internal_and_not_empty(NotificationApp* app)
}
// notification layer
void notification_apply_notification_led_layer(
static void notification_apply_notification_led_layer(
NotificationLedLayer* layer,
const uint8_t layer_value) {
furi_assert(layer);
@@ -81,7 +91,7 @@ void notification_apply_notification_led_layer(
furi_hal_light_set(layer->light, layer->value[LayerNotification]);
}
void notification_reset_notification_led_layer(NotificationLedLayer* layer) {
static void notification_reset_notification_led_layer(NotificationLedLayer* layer) {
furi_assert(layer);
furi_assert(layer->index < LayerMAX);
@@ -94,7 +104,7 @@ void notification_reset_notification_led_layer(NotificationLedLayer* layer) {
furi_hal_light_set(layer->light, layer->value[LayerInternal]);
}
void notification_reset_notification_layer(NotificationApp* app, uint8_t reset_mask) {
static void notification_reset_notification_layer(NotificationApp* app, uint8_t reset_mask) {
if(reset_mask & reset_blink_mask) {
furi_hal_light_blink_stop();
}
@@ -130,28 +140,28 @@ uint8_t notification_settings_get_display_brightness(NotificationApp* app, uint8
return (value * app->settings.display_brightness);
}
uint8_t notification_settings_get_rgb_led_brightness(NotificationApp* app, uint8_t value) {
static uint8_t notification_settings_get_rgb_led_brightness(NotificationApp* app, uint8_t value) {
return (value * app->settings.led_brightness);
}
uint32_t notification_settings_display_off_delay_ticks(NotificationApp* app) {
static uint32_t notification_settings_display_off_delay_ticks(NotificationApp* app) {
return (
(float)(app->settings.display_off_delay_ms) /
(1000.0f / furi_kernel_get_tick_frequency()));
}
// generics
void notification_vibro_on(bool force) {
static void notification_vibro_on(bool force) {
if(!furi_hal_rtc_is_flag_set(FuriHalRtcFlagStealthMode) || force) {
furi_hal_vibro_on(true);
}
}
void notification_vibro_off() {
static void notification_vibro_off() {
furi_hal_vibro_on(false);
}
void notification_sound_on(float freq, float volume, bool force) {
static void notification_sound_on(float freq, float volume, bool force) {
if(!furi_hal_rtc_is_flag_set(FuriHalRtcFlagStealthMode) || force) {
if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) {
furi_hal_speaker_start(freq, volume);
@@ -159,7 +169,7 @@ void notification_sound_on(float freq, float volume, bool force) {
}
}
void notification_sound_off() {
static void notification_sound_off() {
if(furi_hal_speaker_is_mine()) {
furi_hal_speaker_stop();
furi_hal_speaker_release();
@@ -174,7 +184,7 @@ static void notification_display_timer(void* ctx) {
}
// message processing
void notification_process_notification_message(
static void notification_process_notification_message(
NotificationApp* app,
NotificationAppMessage* message) {
uint32_t notification_message_index = 0;
@@ -333,6 +343,9 @@ void notification_process_notification_message(
reset_mask |= reset_green_mask;
reset_mask |= reset_blue_mask;
break;
case NotificationMessageTypeLcdContrastUpdate:
notification_apply_lcd_contrast(app);
break;
}
notification_message_index++;
notification_message = (*message->sequence)[notification_message_index];
@@ -361,7 +374,8 @@ void notification_process_notification_message(
}
}
void notification_process_internal_message(NotificationApp* app, NotificationAppMessage* message) {
static void
notification_process_internal_message(NotificationApp* app, NotificationAppMessage* message) {
uint32_t notification_message_index = 0;
const NotificationMessage* notification_message;
notification_message = (*message->sequence)[notification_message_index];
@@ -548,6 +562,7 @@ int32_t notification_srv(void* p) {
notification_apply_internal_led_layer(&app->led[0], 0x00);
notification_apply_internal_led_layer(&app->led[1], 0x00);
notification_apply_internal_led_layer(&app->led[2], 0x00);
notification_apply_lcd_contrast(app);
furi_record_create(RECORD_NOTIFICATION, app);

View File

@@ -32,7 +32,7 @@ typedef struct {
Light light;
} NotificationLedLayer;
#define NOTIFICATION_SETTINGS_VERSION 0x01
#define NOTIFICATION_SETTINGS_VERSION 0x02
#define NOTIFICATION_SETTINGS_PATH INT_PATH(NOTIFICATION_SETTINGS_FILE_NAME)
typedef struct {
@@ -41,6 +41,7 @@ typedef struct {
float led_brightness;
float speaker_volume;
uint32_t display_off_delay_ms;
int8_t contrast;
bool vibro_on;
} NotificationSettings;

View File

@@ -197,6 +197,10 @@ const NotificationMessage message_force_display_brightness_setting_1f = {
.data.forced_settings.display_brightness = 1.0f,
};
const NotificationMessage message_lcd_contrast_update = {
.type = NotificationMessageTypeLcdContrastUpdate,
};
/****************************** Message sequences ******************************/
// Reset
@@ -566,3 +570,8 @@ const NotificationSequence sequence_audiovisual_alert = {
&message_vibro_off,
NULL,
};
const NotificationSequence sequence_lcd_contrast_update = {
&message_lcd_contrast_update,
NULL,
};

View File

@@ -63,6 +63,9 @@ extern const NotificationMessage message_force_vibro_setting_on;
extern const NotificationMessage message_force_vibro_setting_off;
extern const NotificationMessage message_force_display_brightness_setting_1f;
// LCD Messages
extern const NotificationMessage message_lcd_contrast_update;
/****************************** Message sequences ******************************/
// Reset
@@ -138,6 +141,9 @@ extern const NotificationSequence sequence_success;
extern const NotificationSequence sequence_error;
extern const NotificationSequence sequence_audiovisual_alert;
// LCD
extern const NotificationSequence sequence_lcd_contrast_update;
#ifdef __cplusplus
}
#endif