Start working with LCD color inversion

This commit is contained in:
Dmitry422
2025-04-08 18:00:10 +07:00
parent 33fa903f7a
commit 7507058870
6 changed files with 83 additions and 11 deletions

View File

@@ -6,6 +6,8 @@
#include <stdint.h>
#include <u8g2_glue.h>
#include <notification/notification_app.h>
const CanvasFontParameters canvas_font_params[FontTotalNumber] = {
[FontPrimary] = {.leading_default = 12, .leading_min = 11, .height = 8, .descender = 2},
[FontSecondary] = {.leading_default = 11, .leading_min = 9, .height = 7, .descender = 2},
@@ -141,11 +143,39 @@ 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) {
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(color == ColorBlack) {
color = ColorWhite;
} else if(color == ColorWhite) {
color = ColorBlack;
}
}
u8g2_SetDrawColor(&canvas->fb, color);
}
@@ -155,6 +185,23 @@ 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;
}