mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-19 04:44:47 -07:00
Start working with LCD color inversion
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 ---
|
||||
|
||||
@@ -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,8 +48,11 @@ typedef struct {
|
||||
float night_shift;
|
||||
uint32_t night_shift_start;
|
||||
uint32_t night_shift_end;
|
||||
bool lcd_inverse;
|
||||
} NotificationSettings;
|
||||
|
||||
//extern NotificationSettings settings;
|
||||
|
||||
struct NotificationApp {
|
||||
FuriMessageQueue* queue;
|
||||
FuriPubSub* event_record;
|
||||
|
||||
Reference in New Issue
Block a user