mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-19 04:44:47 -07: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();
|
||||
|
||||
Reference in New Issue
Block a user