mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 20:49:49 +04:00
@@ -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,10 +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
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -47,7 +47,6 @@ struct Canvas {
|
||||
CompressIcon* compress_icon;
|
||||
CanvasCallbackPairArray_t canvas_callback_pair;
|
||||
FuriMutex* mutex;
|
||||
bool lcd_inversion;
|
||||
};
|
||||
|
||||
/** Allocate memory and initialize canvas
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <gui/modules/variable_item_list.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <lib/toolbox/value_index.h>
|
||||
#include <gui/gui_i.h>
|
||||
#include <u8g2_glue.h>
|
||||
|
||||
#define MAX_NOTIFICATION_SETTINGS 5
|
||||
|
||||
@@ -348,11 +350,11 @@ static void lcd_inversion_changed(VariableItem* item) {
|
||||
variable_item_set_current_value_text(item, lcd_inversion_text[index]);
|
||||
app->notification->settings.lcd_inversion = lcd_inversion_value[index];
|
||||
|
||||
Canvas* tmp_canvas = gui_direct_draw_acquire(app->gui);
|
||||
canvas_set_inverted_lcd(tmp_canvas, lcd_inversion_value[index]);
|
||||
gui_direct_draw_release(app->gui);
|
||||
Gui* gui = furi_record_open(RECORD_GUI);
|
||||
u8x8_d_st756x_set_inversion(&gui->canvas->fb.u8x8, lcd_inversion_value[index]);
|
||||
furi_record_close(RECORD_GUI);
|
||||
|
||||
notification_message(app->notification, &sequence_display_backlight_on);
|
||||
notification_message_save_settings(app->notification);
|
||||
}
|
||||
|
||||
//--- RGB BACKLIGHT ---
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <string.h>
|
||||
|
||||
/*============================================*/
|
||||
|
||||
void u8g2_ClearBuffer(u8g2_t* u8g2) {
|
||||
size_t cnt;
|
||||
cnt = u8g2_GetU8x8(u8g2)->display_info->tile_width;
|
||||
@@ -45,13 +46,6 @@ void u8g2_ClearBuffer(u8g2_t* u8g2) {
|
||||
memset(u8g2->tile_buf_ptr, 0, cnt);
|
||||
}
|
||||
|
||||
void u8g2_FillBuffer(u8g2_t* u8g2) {
|
||||
size_t cnt;
|
||||
cnt = u8g2_GetU8x8(u8g2)->display_info->tile_width;
|
||||
cnt *= u8g2->tile_buf_height;
|
||||
cnt *= 8;
|
||||
memset(u8g2->tile_buf_ptr, 255, cnt);
|
||||
}
|
||||
/*============================================*/
|
||||
|
||||
static void u8g2_send_tile_row(u8g2_t* u8g2, uint8_t src_tile_row, uint8_t dest_tile_row) {
|
||||
|
||||
@@ -280,3 +280,17 @@ void u8g2_Setup_st756x_flipper(
|
||||
buf = u8g2_m_16_8_f(&tile_buf_height);
|
||||
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation);
|
||||
}
|
||||
|
||||
void u8x8_d_st756x_set_inversion(u8x8_t* u8x8, bool arg) {
|
||||
// if arg is true - set last bit to 1 (inversion ON)
|
||||
if(arg) {
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, ST756X_CMD_INVERSE_DISPLAY | 0b01);
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
// else use standart command with 0 in last bit
|
||||
} else {
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
u8x8_cad_SendCmd(u8x8, ST756X_CMD_INVERSE_DISPLAY);
|
||||
u8x8_cad_EndTransfer(u8x8);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,3 +16,5 @@ void u8g2_Setup_st756x_flipper(
|
||||
void u8x8_d_st756x_init(u8x8_t* u8x8, uint8_t contrast, uint8_t regulation_ratio, bool bias);
|
||||
|
||||
void u8x8_d_st756x_set_contrast(u8x8_t* u8x8, int8_t contrast_offset);
|
||||
|
||||
void u8x8_d_st756x_set_inversion(u8x8_t* u8x8, bool arg);
|
||||
|
||||
@@ -848,14 +848,12 @@ Function,+,canvas_get_font_params,const CanvasFontParameters*,"const Canvas*, Fo
|
||||
Function,+,canvas_glyph_width,size_t,"Canvas*, uint16_t"
|
||||
Function,+,canvas_height,size_t,const Canvas*
|
||||
Function,+,canvas_invert_color,void,Canvas*
|
||||
Function,+,canvas_is_inverted_lcd,_Bool,Canvas*
|
||||
Function,+,canvas_reset,void,Canvas*
|
||||
Function,+,canvas_set_bitmap_mode,void,"Canvas*, _Bool"
|
||||
Function,+,canvas_set_color,void,"Canvas*, Color"
|
||||
Function,+,canvas_set_custom_u8g2_font,void,"Canvas*, const uint8_t*"
|
||||
Function,+,canvas_set_font,void,"Canvas*, Font"
|
||||
Function,+,canvas_set_font_direction,void,"Canvas*, CanvasDirection"
|
||||
Function,+,canvas_set_inverted_lcd,void,"Canvas*, _Bool"
|
||||
Function,+,canvas_string_width,uint16_t,"Canvas*, const char*"
|
||||
Function,+,canvas_width,size_t,const Canvas*
|
||||
Function,-,cbrt,double,double
|
||||
|
||||
|
Reference in New Issue
Block a user