mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 04:34:43 +04:00
LCD Inversion refactoring
This commit is contained in:
@@ -94,16 +94,6 @@ size_t canvas_get_buffer_size(const Canvas* canvas) {
|
||||
return u8g2_GetBufferTileWidth(&canvas->fb) * u8g2_GetBufferTileHeight(&canvas->fb) * 8;
|
||||
}
|
||||
|
||||
bool canvas_is_inverted_lcd(Canvas* canvas) {
|
||||
furi_assert(canvas);
|
||||
return canvas->lcd_inversion;
|
||||
}
|
||||
|
||||
void canvas_set_inverted_lcd(Canvas* canvas, bool inverted) {
|
||||
furi_assert(canvas);
|
||||
canvas->lcd_inversion = inverted;
|
||||
}
|
||||
|
||||
void canvas_frame_set(
|
||||
Canvas* canvas,
|
||||
int32_t offset_x,
|
||||
@@ -151,24 +141,11 @@ const CanvasFontParameters* canvas_get_font_params(const Canvas* canvas, Font fo
|
||||
|
||||
void canvas_clear(Canvas* canvas) {
|
||||
furi_check(canvas);
|
||||
|
||||
if(canvas->lcd_inversion) {
|
||||
u8g2_FillBuffer(&canvas->fb);
|
||||
} else {
|
||||
u8g2_ClearBuffer(&canvas->fb);
|
||||
}
|
||||
u8g2_ClearBuffer(&canvas->fb);
|
||||
}
|
||||
|
||||
void canvas_set_color(Canvas* canvas, Color color) {
|
||||
furi_check(canvas);
|
||||
|
||||
if(canvas->lcd_inversion) {
|
||||
if(color == ColorBlack) {
|
||||
color = ColorWhite;
|
||||
} else if(color == ColorWhite) {
|
||||
color = ColorBlack;
|
||||
}
|
||||
}
|
||||
u8g2_SetDrawColor(&canvas->fb, color);
|
||||
}
|
||||
|
||||
@@ -178,14 +155,7 @@ void canvas_set_font_direction(Canvas* canvas, CanvasDirection dir) {
|
||||
}
|
||||
|
||||
void canvas_invert_color(Canvas* canvas) {
|
||||
if((canvas->fb.draw_color == ColorXOR) && canvas->lcd_inversion) {
|
||||
// ColorXOR = 0x02, inversion change it to White = 0x00
|
||||
// but if we have lcd_inversion 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;
|
||||
}
|
||||
canvas->fb.draw_color = !canvas->fb.draw_color;
|
||||
}
|
||||
|
||||
void canvas_set_font(Canvas* canvas, Font font) {
|
||||
|
||||
@@ -447,9 +447,6 @@ void canvas_draw_icon_bitmap(
|
||||
int16_t h,
|
||||
const Icon* icon);
|
||||
|
||||
bool canvas_is_inverted_lcd(Canvas* canvas);
|
||||
|
||||
void canvas_set_inverted_lcd(Canvas* canvas, bool inverted);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -835,12 +835,8 @@ static NotificationApp* notification_app_alloc(void) {
|
||||
app->settings.rgb.rainbow_saturation = 255;
|
||||
app->settings.rgb.rainbow_wide = 50;
|
||||
|
||||
// use RECORD for setup init values to canvas lcd_inverted
|
||||
Gui* tmp_gui = furi_record_open(RECORD_GUI);
|
||||
Canvas* tmp_canvas = gui_direct_draw_acquire(tmp_gui);
|
||||
canvas_set_inverted_lcd(tmp_canvas, false);
|
||||
gui_direct_draw_release(tmp_gui);
|
||||
furi_record_close(RECORD_GUI);
|
||||
// set inital value, later it will be rewriten by loading settings from file
|
||||
app->settings.lcd_inversion = false;
|
||||
|
||||
return app;
|
||||
}
|
||||
@@ -873,12 +869,12 @@ static void notification_apply_settings(NotificationApp* app) {
|
||||
}
|
||||
// --- NIGHT SHIFT END ---
|
||||
|
||||
//setup canvas variable "inversion" by settings value;
|
||||
Gui* tmp_gui = furi_record_open(RECORD_GUI);
|
||||
Canvas* tmp_canvas = gui_direct_draw_acquire(tmp_gui);
|
||||
canvas_set_inverted_lcd(tmp_canvas, app->settings.lcd_inversion);
|
||||
gui_direct_draw_release(tmp_gui);
|
||||
furi_record_close(RECORD_GUI);
|
||||
// check RECORD_GUI is exist (insurance on boot time) then use it to setup lcd inversion mode from loaded settings;
|
||||
if(furi_record_exists(RECORD_GUI)) {
|
||||
Gui* gui = furi_record_open(RECORD_GUI);
|
||||
u8x8_d_st756x_set_inversion(&gui->canvas->fb.u8x8, app->settings.lcd_inversion);
|
||||
furi_record_close(RECORD_GUI);
|
||||
}
|
||||
}
|
||||
|
||||
static void notification_init_settings(NotificationApp* app) {
|
||||
|
||||
Reference in New Issue
Block a user