mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 04:34:43 +04: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;
|
||||
|
||||
@@ -270,6 +270,13 @@ const uint32_t night_shift_end_value[NIGHT_SHIFT_END_COUNT] = {
|
||||
|
||||
// --- NIGHT SHIFT END ---
|
||||
|
||||
#define LCD_INVERSE_COUNT 2
|
||||
const char* const lcd_inverse_text[LCD_INVERSE_COUNT] = {
|
||||
"OFF",
|
||||
"ON",
|
||||
};
|
||||
const bool lcd_inverse_value[LCD_INVERSE_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,16 @@ static void vibro_changed(VariableItem* item) {
|
||||
notification_message(app->notification, &sequence_single_vibro);
|
||||
}
|
||||
|
||||
static void lcd_inverse_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_inverse_text[index]);
|
||||
app->notification->settings.lcd_inverse = lcd_inverse_value[index];
|
||||
notification_message(app->notification, &sequence_display_backlight_on);
|
||||
|
||||
}
|
||||
|
||||
//--- RGB BACKLIGHT ---
|
||||
|
||||
static void rgb_backlight_installed_changed(VariableItem* item) {
|
||||
@@ -721,6 +738,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 Inverse", LCD_INVERSE_COUNT, lcd_inverse_changed, app);
|
||||
value_index = value_index_bool(
|
||||
app->notification->settings.lcd_inverse, lcd_inverse_value, LCD_INVERSE_COUNT);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, lcd_inverse_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) {
|
||||
|
||||
Reference in New Issue
Block a user