diff --git a/applications/services/gui/canvas.c b/applications/services/gui/canvas.c index 22addd9ff..33402ab3c 100644 --- a/applications/services/gui/canvas.c +++ b/applications/services/gui/canvas.c @@ -143,33 +143,18 @@ const CanvasFontParameters* canvas_get_font_params(const Canvas* canvas, Font fo void canvas_clear(Canvas* canvas) { furi_check(canvas); - furi_delay_ms (500); - NotificationApp* app = malloc (sizeof(NotificationApp)); - app = furi_record_open(RECORD_NOTIFICATION); - - // open Notification record for access to NotificationApp settings - // NotificationApp* app = malloc (sizeof(NotificationApp)); - // app = furi_record_open(RECORD_NOTIFICATION); - if(app->settings.lcd_inverse) { + if(lcd_inverted) { u8g2_FillBuffer(&canvas->fb); } else { u8g2_ClearBuffer(&canvas->fb); } - - u8g2_ClearBuffer(&canvas->fb); - // furi_record_close (RECORD_NOTIFICATION); - // free (app); } void canvas_set_color(Canvas* canvas, Color color) { furi_check(canvas); - furi_delay_ms (500); - // open Notification record for access to NotificationApp settings - NotificationApp* app = malloc (sizeof(NotificationApp)); - app = furi_record_open(RECORD_NOTIFICATION); - if(app->settings.lcd_inverse) { + if(lcd_inverted) { if(color == ColorBlack) { color = ColorWhite; } else if(color == ColorWhite) { @@ -185,24 +170,14 @@ void canvas_set_font_direction(Canvas* canvas, CanvasDirection dir) { } void canvas_invert_color(Canvas* canvas) { - - // // open Notification record for access to NotificationApp settings - // NotificationApp* app = malloc (sizeof(NotificationApp)); - // app = furi_record_open(RECORD_NOTIFICATION); - - // if((canvas->fb.draw_color == ColorXOR) && app->settings.lcd_inverse) { - // // ColorXOR = 0x02, inversion change it to White = 0x00 - // // but if we have lcd_inverse ON then we need Black =0x01 instead White 0x00 - // // so we force changing color to black - // canvas->fb.draw_color = ColorBlack; - // } else { - // canvas->fb.draw_color = !canvas->fb.draw_color; - // } - - // furi_record_close (RECORD_NOTIFICATION); - // free (app); - - canvas->fb.draw_color = !canvas->fb.draw_color; + if((canvas->fb.draw_color == ColorXOR) && lcd_inverted) { + // ColorXOR = 0x02, inversion change it to White = 0x00 + // but if we have lcd_inverse ON then we need Black =0x01 instead White 0x00 + // so we force changing color to black + canvas->fb.draw_color = ColorBlack; + } else { + canvas->fb.draw_color = !canvas->fb.draw_color; + } } void canvas_set_font(Canvas* canvas, Font font) { diff --git a/applications/services/notification/notification_app.c b/applications/services/notification/notification_app.c index 9a6b4a3da..8a059586d 100644 --- a/applications/services/notification/notification_app.c +++ b/applications/services/notification/notification_app.c @@ -620,6 +620,8 @@ static NotificationApp* notification_app_alloc(void) { furi_timer_alloc(night_shift_timer_callback, FuriTimerTypePeriodic, app); // --- NIGHT SHIFT END --- + lcd_inverted = false; + return app; } @@ -650,6 +652,9 @@ static void notification_apply_settings(NotificationApp* app) { night_shift_timer_start(app); } // --- NIGHT SHIFT END --- + + //setup global variable "inverted" by settings value; + lcd_inverted = app->settings.lcd_inverse; } static void notification_init_settings(NotificationApp* app) { diff --git a/applications/services/notification/notification_app.h b/applications/services/notification/notification_app.h index d027bf200..30673f470 100644 --- a/applications/services/notification/notification_app.h +++ b/applications/services/notification/notification_app.h @@ -51,8 +51,6 @@ typedef struct { bool lcd_inverse; } NotificationSettings; -//extern NotificationSettings settings; - struct NotificationApp { FuriMessageQueue* queue; FuriPubSub* event_record; @@ -72,3 +70,6 @@ struct NotificationApp { void notification_message_save_settings(NotificationApp* app); void night_shift_timer_start(NotificationApp* app); void night_shift_timer_stop(NotificationApp* app); + +//global variable for using in canvac.c +extern bool lcd_inverted; diff --git a/applications/settings/notification_settings/notification_settings_app.c b/applications/settings/notification_settings/notification_settings_app.c index 7b239a077..25fc264f8 100644 --- a/applications/settings/notification_settings/notification_settings_app.c +++ b/applications/settings/notification_settings/notification_settings_app.c @@ -354,6 +354,10 @@ static void lcd_inverse_changed(VariableItem* item) { variable_item_set_current_value_text(item, lcd_inverse_text[index]); app->notification->settings.lcd_inverse = lcd_inverse_value[index]; + + //setup global variable for using in canvas.c + lcd_inverted = lcd_inverse_value[index]; + notification_message(app->notification, &sequence_display_backlight_on); }