mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-13 05:06:30 +04:00
@@ -94,6 +94,16 @@ 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,
|
||||
@@ -141,11 +151,24 @@ const CanvasFontParameters* canvas_get_font_params(const Canvas* canvas, Font fo
|
||||
|
||||
void canvas_clear(Canvas* canvas) {
|
||||
furi_check(canvas);
|
||||
u8g2_ClearBuffer(&canvas->fb);
|
||||
|
||||
if(canvas->lcd_inversion) {
|
||||
u8g2_FillBuffer(&canvas->fb);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -155,7 +178,14 @@ void canvas_set_font_direction(Canvas* canvas, CanvasDirection dir) {
|
||||
}
|
||||
|
||||
void canvas_invert_color(Canvas* canvas) {
|
||||
canvas->fb.draw_color = !canvas->fb.draw_color;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
void canvas_set_font(Canvas* canvas, Font font) {
|
||||
|
||||
@@ -447,6 +447,10 @@ 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,6 +47,7 @@ struct Canvas {
|
||||
CompressIcon* compress_icon;
|
||||
CanvasCallbackPairArray_t canvas_callback_pair;
|
||||
FuriMutex* mutex;
|
||||
bool lcd_inversion;
|
||||
};
|
||||
|
||||
/** Allocate memory and initialize canvas
|
||||
|
||||
@@ -56,10 +56,6 @@ void night_shift_timer_callback(void* context) {
|
||||
NotificationApp* app = context;
|
||||
DateTime current_date_time;
|
||||
|
||||
// IN DEVELOPMENT
|
||||
// // save current night_shift;
|
||||
// float old_night_shift = app->current_night_shift;
|
||||
|
||||
// take system time and convert to minutes
|
||||
furi_hal_rtc_get_datetime(¤t_date_time);
|
||||
uint32_t time = current_date_time.hour * 60 + current_date_time.minute;
|
||||
@@ -73,12 +69,6 @@ void night_shift_timer_callback(void* context) {
|
||||
app->current_night_shift = app->settings.night_shift;
|
||||
app->rgb_srv->current_night_shift = app->settings.night_shift;
|
||||
}
|
||||
|
||||
// IN DEVELOPMENT
|
||||
// // if night shift was changed then update stock and rgb backlight to new value
|
||||
// if(old_night_shift != app->current_night_shift) {
|
||||
// notification_message(app, &sequence_display_backlight_on);
|
||||
// }
|
||||
}
|
||||
|
||||
// --- NIGHT SHIFT END ---
|
||||
@@ -630,6 +620,12 @@ static NotificationApp* notification_app_alloc(void) {
|
||||
furi_timer_alloc(night_shift_timer_callback, FuriTimerTypePeriodic, app);
|
||||
// --- NIGHT SHIFT END ---
|
||||
|
||||
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);
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
@@ -660,6 +656,13 @@ static void notification_apply_settings(NotificationApp* app) {
|
||||
night_shift_timer_start(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);
|
||||
}
|
||||
|
||||
static void notification_init_settings(NotificationApp* app) {
|
||||
|
||||
@@ -34,7 +34,7 @@ typedef struct {
|
||||
Light light;
|
||||
} NotificationLedLayer;
|
||||
|
||||
#define NOTIFICATION_SETTINGS_VERSION 0x03
|
||||
#define NOTIFICATION_SETTINGS_VERSION 0x04
|
||||
#define NOTIFICATION_SETTINGS_PATH INT_PATH(NOTIFICATION_SETTINGS_FILE_NAME)
|
||||
|
||||
typedef struct {
|
||||
@@ -48,6 +48,7 @@ typedef struct {
|
||||
float night_shift;
|
||||
uint32_t night_shift_start;
|
||||
uint32_t night_shift_end;
|
||||
bool lcd_inversion;
|
||||
} NotificationSettings;
|
||||
|
||||
struct NotificationApp {
|
||||
|
||||
@@ -270,6 +270,13 @@ const uint32_t night_shift_end_value[NIGHT_SHIFT_END_COUNT] = {
|
||||
|
||||
// --- NIGHT SHIFT END ---
|
||||
|
||||
#define LCD_INVERSION_COUNT 2
|
||||
const char* const lcd_inversion_text[LCD_INVERSION_COUNT] = {
|
||||
"OFF",
|
||||
"ON",
|
||||
};
|
||||
const bool lcd_inversion_value[LCD_INVERSION_COUNT] = {false, true};
|
||||
|
||||
static void contrast_changed(VariableItem* item) {
|
||||
NotificationAppSettings* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
@@ -341,6 +348,20 @@ static void vibro_changed(VariableItem* item) {
|
||||
notification_message(app->notification, &sequence_single_vibro);
|
||||
}
|
||||
|
||||
static void lcd_inversion_changed(VariableItem* item) {
|
||||
NotificationAppSettings* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(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);
|
||||
|
||||
notification_message(app->notification, &sequence_display_backlight_on);
|
||||
}
|
||||
|
||||
//--- RGB BACKLIGHT ---
|
||||
|
||||
static void rgb_backlight_installed_changed(VariableItem* item) {
|
||||
@@ -721,6 +742,13 @@ static NotificationAppSettings* alloc_settings(void) {
|
||||
variable_item_set_current_value_text(item, vibro_text[value_index]);
|
||||
}
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list,"LCD inversion",LCD_INVERSION_COUNT,lcd_inversion_changed,app);
|
||||
value_index = value_index_bool(
|
||||
app->notification->settings.lcd_inversion, lcd_inversion_value, LCD_INVERSION_COUNT);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, lcd_inversion_text[value_index]);
|
||||
|
||||
//--- RGB BACKLIGHT ---
|
||||
|
||||
app->variable_item_list_rgb = variable_item_list_alloc();
|
||||
|
||||
@@ -3548,6 +3548,7 @@ void u8g2_Setup_a2printer_384x240_f(
|
||||
|
||||
void u8g2_SendBuffer(u8g2_t* u8g2);
|
||||
void u8g2_ClearBuffer(u8g2_t* u8g2);
|
||||
void u8g2_FillBuffer(u8g2_t* u8g2);
|
||||
|
||||
void u8g2_SetBufferCurrTileRow(u8g2_t* u8g2, uint8_t row) U8G2_NOINLINE;
|
||||
|
||||
|
||||
@@ -45,6 +45,13 @@ 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) {
|
||||
|
||||
@@ -852,12 +852,14 @@ 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
|
||||
@@ -3663,8 +3665,8 @@ Function,+,subghz_worker_set_pair_callback,void,"SubGhzWorker*, SubGhzWorkerPair
|
||||
Function,+,subghz_worker_start,void,SubGhzWorker*
|
||||
Function,+,subghz_worker_stop,void,SubGhzWorker*
|
||||
Function,+,submenu_add_item,void,"Submenu*, const char*, uint32_t, SubmenuItemCallback, void*"
|
||||
Function,+,submenu_add_lockable_item,void,"Submenu*, const char*, uint32_t, SubmenuItemCallback, void*, _Bool, const char*"
|
||||
Function,+,submenu_add_item_ex,void,"Submenu*, const char*, uint32_t, SubmenuItemCallbackEx, void*"
|
||||
Function,+,submenu_add_lockable_item,void,"Submenu*, const char*, uint32_t, SubmenuItemCallback, void*, _Bool, const char*"
|
||||
Function,+,submenu_alloc,Submenu*,
|
||||
Function,+,submenu_change_item_label,void,"Submenu*, uint32_t, const char*"
|
||||
Function,+,submenu_free,void,Submenu*
|
||||
|
||||
|
Reference in New Issue
Block a user