[FL-2463, FL-2471, FL-2472, FL-2473] Notifications, GUI elements, archive fixes #1137

This commit is contained in:
Nikolay Minaylov
2022-04-21 15:33:03 +03:00
committed by GitHub
parent cea118cf2d
commit ad1ee8a5c6
9 changed files with 55 additions and 17 deletions

View File

@@ -59,6 +59,8 @@ typedef enum {
NotificationMessageTypeForceSpeakerVolumeSetting,
NotificationMessageTypeForceVibroSetting,
NotificationMessageTypeForceDisplayBrightnessSetting,
NotificationMessageTypeLedBrightnessSettingApply,
} NotificationMessageType;
typedef struct {

View File

@@ -212,18 +212,21 @@ void notification_process_notification_message(
// store and send on delay or after seq
led_active = true;
led_values[0] = notification_message->data.led.value;
app->led[0].value_last[LayerNotification] = led_values[0];
reset_mask |= reset_red_mask;
break;
case NotificationMessageTypeLedGreen:
// store and send on delay or after seq
led_active = true;
led_values[1] = notification_message->data.led.value;
app->led[1].value_last[LayerNotification] = led_values[1];
reset_mask |= reset_green_mask;
break;
case NotificationMessageTypeLedBlue:
// store and send on delay or after seq
led_active = true;
led_values[2] = notification_message->data.led.value;
app->led[2].value_last[LayerNotification] = led_values[2];
reset_mask |= reset_blue_mask;
break;
case NotificationMessageTypeVibro:
@@ -273,6 +276,16 @@ void notification_process_notification_message(
case NotificationMessageTypeForceDisplayBrightnessSetting:
display_brightness_setting =
notification_message->data.forced_settings.display_brightness;
break;
case NotificationMessageTypeLedBrightnessSettingApply:
led_active = true;
for(uint8_t i = 0; i < NOTIFICATION_LED_COUNT; i++) {
led_values[i] = app->led[i].value_last[LayerNotification];
}
reset_mask |= reset_red_mask;
reset_mask |= reset_green_mask;
reset_mask |= reset_blue_mask;
break;
}
notification_message_index++;
notification_message = (*message->sequence)[notification_message_index];
@@ -316,23 +329,33 @@ void notification_process_internal_message(NotificationApp* app, NotificationApp
app, notification_message->data.led.value));
break;
case NotificationMessageTypeLedRed:
app->led[0].value_last[LayerInternal] = notification_message->data.led.value;
notification_apply_internal_led_layer(
&app->led[0],
notification_settings_get_rgb_led_brightness(
app, notification_message->data.led.value));
break;
case NotificationMessageTypeLedGreen:
app->led[1].value_last[LayerInternal] = notification_message->data.led.value;
notification_apply_internal_led_layer(
&app->led[1],
notification_settings_get_rgb_led_brightness(
app, notification_message->data.led.value));
break;
case NotificationMessageTypeLedBlue:
app->led[2].value_last[LayerInternal] = notification_message->data.led.value;
notification_apply_internal_led_layer(
&app->led[2],
notification_settings_get_rgb_led_brightness(
app, notification_message->data.led.value));
break;
case NotificationMessageTypeLedBrightnessSettingApply:
for(uint8_t i = 0; i < NOTIFICATION_LED_COUNT; i++) {
uint8_t new_val = notification_settings_get_rgb_led_brightness(
app, app->led[i].value_last[LayerInternal]);
notification_apply_internal_led_layer(&app->led[i], new_val);
}
break;
default:
break;
}

View File

@@ -25,6 +25,7 @@ typedef enum {
} NotificationLedLayerIndex;
typedef struct {
uint8_t value_last[LayerMAX];
uint8_t value[LayerMAX];
NotificationLedLayerIndex index;
Light light;

View File

@@ -82,12 +82,22 @@ static void screen_changed(VariableItem* item) {
notification_message(app->notification, &sequence_display_on);
}
const NotificationMessage apply_message = {
.type = NotificationMessageTypeLedBrightnessSettingApply,
};
const NotificationSequence apply_sequence = {
&apply_message,
NULL,
};
static void led_changed(VariableItem* item) {
NotificationAppSettings* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, backlight_text[index]);
app->notification->settings.led_brightness = backlight_value[index];
notification_message(app->notification, &apply_sequence);
notification_internal_message(app->notification, &apply_sequence);
notification_message(app->notification, &sequence_blink_white_100);
}