From 216baf19582d228226b6c04014c590f87b846124 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Wed, 14 Feb 2024 18:03:47 +0000 Subject: [PATCH] Some NotificationSrv optimizations --- .../services/notification/notification_app.c | 43 ++++++++----------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/applications/services/notification/notification_app.c b/applications/services/notification/notification_app.c index 9f4a790db..b257041c2 100644 --- a/applications/services/notification/notification_app.c +++ b/applications/services/notification/notification_app.c @@ -400,23 +400,12 @@ static void 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; + uint8_t i = notification_message->type - NotificationMessageTypeLedRed; + app->led[i].value_last[LayerInternal] = notification_message->data.led.value; notification_apply_internal_led_layer( - &app->led[2], + &app->led[i], notification_settings_get_rgb_led_brightness( app, notification_message->data.led.value)); break; @@ -483,24 +472,26 @@ static NotificationApp* notification_app_alloc() { app->settings.display_off_delay_ms = 30000; app->settings.vibro_on = true; - app->display.value[LayerInternal] = 0x00; - app->display.value[LayerNotification] = 0x00; - app->display.index = LayerInternal; + // malloc() also does memset(0), no need to init 0 values + _Static_assert(LayerInternal == 0, "need to init layer values"); + // app->display.value[LayerInternal] = 0x00; + // app->display.value[LayerNotification] = 0x00; + // app->display.index = LayerInternal; app->display.light = LightBacklight; - app->led[0].value[LayerInternal] = 0x00; - app->led[0].value[LayerNotification] = 0x00; - app->led[0].index = LayerInternal; + // app->led[0].value[LayerInternal] = 0x00; + // app->led[0].value[LayerNotification] = 0x00; + // app->led[0].index = LayerInternal; app->led[0].light = LightRed; - app->led[1].value[LayerInternal] = 0x00; - app->led[1].value[LayerNotification] = 0x00; - app->led[1].index = LayerInternal; + // app->led[1].value[LayerInternal] = 0x00; + // app->led[1].value[LayerNotification] = 0x00; + // app->led[1].index = LayerInternal; app->led[1].light = LightGreen; - app->led[2].value[LayerInternal] = 0x00; - app->led[2].value[LayerNotification] = 0x00; - app->led[2].index = LayerInternal; + // app->led[2].value[LayerInternal] = 0x00; + // app->led[2].value[LayerNotification] = 0x00; + // app->led[2].index = LayerInternal; app->led[2].light = LightBlue; app->settings.version = NOTIFICATION_SETTINGS_VERSION;