Skip to content

Commit

Permalink
Fix wrong inverse color handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Apehaenger committed Sep 12, 2023
1 parent 0004dc0 commit 3a68a87
Show file tree
Hide file tree
Showing 14 changed files with 190 additions and 202 deletions.
12 changes: 6 additions & 6 deletions Firmware/CoverUI/YardForce/UC1698.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ namespace display
this->writeCommand(0x24 | 1); // 0x24 = temperature control (-0.05%/C)
this->setLCDMappingControl(0, 1);
// this->setVBiasPotentiometer(127);
this->writeCommand(0b10100110 | 0); // Set Inverse Display
this->writeCommand(0b11010001); // [20] Set Color Pattern to R-G-B
this->writeCommand(0b10100110 | 1); // [16] Set Inverse Display. Will save inversion logic in LVGL's flush_cb()
this->writeCommand(0b11010000 | 1); // [20] Set Color Pattern to R-G-B
this->writeCommand(0b11010110); // [21] Set Color Mode to RRRRR-GGGGGG-BBBBB, 64k-color

this->fillScreen(false); // Clear Screen
Expand Down Expand Up @@ -228,11 +228,11 @@ namespace display
(uint8_t)(0x60 | ((uint8_t)t_y1 & 0b00001111)), // Set Row LSB Address

// Set Windows Program
(0xf5), (t_y1), // Starting Row Address
(0xf7), (t_y2), // Ending Row Address
(0xf4), (uint8_t)(t_x1 / 3), // Starting Column Address
(0xf5), (t_y1), // Starting Row Address
(0xf7), (t_y2), // Ending Row Address
(0xf4), (uint8_t)(t_x1 / 3), // Starting Column Address
(0xf6), (uint8_t)((int8_t)((t_x2 + 1) / 3) - 1), // Ending Column Address
(uint8_t)(0xf8 | t_outside_mode) // Windows Program Mode (0 = inside, 1 = outside)
(uint8_t)(0xf8 | t_outside_mode) // Windows Program Mode (0 = inside, 1 = outside)
};
writeCommand(data, sizeof(data) / sizeof(uint8_t));
}
Expand Down
34 changes: 12 additions & 22 deletions Firmware/CoverUI/YardForce/WYM240128K1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#include "WidgetTextTicker.hpp"

// C images
LV_IMG_DECLARE(OM_Logo_Inv_120x54x1);
LV_IMG_DECLARE(OM_Wordmark_Inv_240x35x1);
LV_IMG_DECLARE(OM_Logo_120x54x1);
LV_IMG_DECLARE(OM_Wordmark_240x35x1);

namespace display
{
Expand Down Expand Up @@ -73,9 +73,9 @@ namespace display

for (y = area->y1; y <= area->y2; y++)
{
// color_p = t_color_p + (y * UC1698_DISPLAY_WIDTH) + area->x1;
for (x = area->x1; x <= area->x2; x += 3) // FIXME: Might overflow buffer if area->x2 is not dividable by 3
{
// Color is inverted (0 = black but pixel off / >0 = white but pixel on) but UC1698 "[16] Set Inverse Display" is set
uc1698.drawPixelTriplet(t_color_p->full, (t_color_p + 1)->full, (t_color_p + 2)->full);
t_color_p += 3;
}
Expand All @@ -93,7 +93,7 @@ namespace display
bar_bat = new WidgetBar(FA_SYMBOL_BATTERY " %d %%", LV_ALIGN_TOP_MID, 0, 60, UC1698_DISPLAY_WIDTH, 21);
// Mower status text (ticker)
text_ticker_status = new WidgetTextTicker(LV_ALIGN_TOP_MID, 0, 95, UC1698_DISPLAY_WIDTH);
text_ticker_status->set_text("Bla bla");
text_ticker_status->set_text("Long text should ticker: Lorem Ipsum Bla bla bla");
}

static void anim_x_cb(void *var, int32_t v)
Expand All @@ -105,19 +105,19 @@ namespace display
{
// Mower Logo - img_logo
lv_obj_t *img_logo = lv_img_create(lv_scr_act());
lv_img_set_src(img_logo, &OM_Logo_Inv_120x54x1);
lv_img_set_src(img_logo, &OM_Logo_120x54x1);
lv_obj_align(img_logo, LV_ALIGN_CENTER, 0, -25);

// OpenMower Wordmark - img_wordmark
lv_obj_t *img_wordmark = lv_img_create(lv_scr_act());
lv_img_set_src(img_wordmark, &OM_Wordmark_Inv_240x35x1);
lv_img_set_src(img_wordmark, &OM_Wordmark_240x35x1);
lv_obj_align(img_wordmark, LV_ALIGN_CENTER, 0, 25);

// Anim of logo
lv_anim_t al;
lv_anim_init(&al);
lv_anim_set_var(&al, img_logo);
lv_anim_set_values(&al, 0, -((UC1698_DISPLAY_WIDTH / 2) + (OM_Logo_Inv_120x54x1.header.w / 2)));
lv_anim_set_values(&al, 0, -((UC1698_DISPLAY_WIDTH / 2) + (OM_Logo_120x54x1.header.w / 2)));
lv_anim_set_time(&al, 2000);
lv_anim_set_delay(&al, 1000);
lv_anim_set_exec_cb(&al, (lv_anim_exec_xcb_t)anim_x_cb);
Expand All @@ -128,7 +128,7 @@ namespace display
lv_anim_t aw;
lv_anim_init(&aw);
lv_anim_set_var(&aw, img_wordmark);
lv_anim_set_values(&aw, 0, (UC1698_DISPLAY_WIDTH / 2) + (OM_Wordmark_Inv_240x35x1.header.w / 2) + 20);
lv_anim_set_values(&aw, 0, (UC1698_DISPLAY_WIDTH / 2) + (OM_Wordmark_240x35x1.header.w / 2) + 20);
lv_anim_set_time(&aw, 2500);
lv_anim_set_delay(&aw, 1700);
lv_anim_set_exec_cb(&aw, (lv_anim_exec_xcb_t)anim_x_cb);
Expand All @@ -137,14 +137,6 @@ namespace display
lv_anim_start(&aw);
}

static void test1()
{
lv_obj_t *label = lv_label_create(lv_scr_act());
lv_label_set_text(label, "test1() " FA_SYMBOL_GPS1 " " FA_SYMBOL_GPS2 " " FA_SYMBOL_BATTERY);
lv_obj_set_style_text_color(lv_scr_act(), lv_color_hex(0xffffff), LV_PART_MAIN);
lv_obj_align(label, LV_ALIGN_CENTER, 0, -20);
}

bool init()
{
// Init UC1698 display controller
Expand All @@ -163,11 +155,11 @@ namespace display
lv_disp_drv.ver_res = UC1698_DISPLAY_HEIGHT; // Set the vertical resolution in pixels
lv_disp_draw_buf_init(&lv_disp_buf, lv_buf_1, lv_buf_2, UC1698_DISPLAY_WIDTH * LVGL_BUFFER_MULTIPLIER); // Initialize `disp_buf` with the buffer(s)
lv_disp_t *disp;
disp = lv_disp_drv_register(&lv_disp_drv); // Register the driver and save the created display objects
lv_obj_set_style_bg_color(lv_scr_act(), lv_color_hex(0x000000), LV_PART_MAIN); // No background color
disp = lv_disp_drv_register(&lv_disp_drv); // Register the driver and save the created display objects
lv_obj_set_style_bg_color(lv_scr_act(), lv_color_white(), LV_PART_MAIN); // No background color

//openmower_anim();
mainStatusScreen();
openmower_anim();
//mainStatusScreen();
// test1();
// testCanvas();

Expand Down Expand Up @@ -223,7 +215,6 @@ namespace display
gps_perc += 25; // One LED represents 25%
}
}
//lv_bar_set_value(gps_bar, gps_perc, LV_ANIM_OFF);
bar_gps->set_value(gps_perc);
}

Expand All @@ -237,7 +228,6 @@ namespace display
continue;
bat_perc += 15; // One LED represents 14.3%
}
//lv_bar_set_value(bat_bar, bat_perc, LV_ANIM_OFF);
bar_bat->set_value(bat_perc);
}

Expand Down
11 changes: 5 additions & 6 deletions Firmware/CoverUI/YardForce/WidgetBar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ namespace display
{
// Init bar style settings for custom (labeled) bar graph
lv_style_init(&bar_style_bg);
lv_style_set_border_color(&bar_style_bg, lv_color_white());
lv_style_set_border_color(&bar_style_bg, lv_color_black());
lv_style_set_border_width(&bar_style_bg, 2);
lv_style_set_pad_all(&bar_style_bg, 3); // To make the indicator smaller
lv_style_set_radius(&bar_style_bg, 4);

lv_style_init(&bar_style_indic);
lv_style_set_bg_opa(&bar_style_indic, LV_OPA_COVER);
lv_style_set_bg_color(&bar_style_indic, lv_color_white());
lv_style_set_bg_color(&bar_style_indic, lv_color_black());
lv_style_set_radius(&bar_style_indic, 1);

// Draw bar
Expand Down Expand Up @@ -71,23 +71,22 @@ namespace display
lv_snprintf(buf, sizeof(buf), (const char *)lv_obj_get_user_data(obj), bar_value);

lv_point_t txt_size;
lv_txt_get_size(&txt_size, buf, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX,
label_dsc.flag);
lv_txt_get_size(&txt_size, buf, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, label_dsc.flag);

lv_area_t txt_area;
// If the indicator is long enough put the text inside on the right
if (lv_area_get_width(dsc->draw_area) > txt_size.x + 20)
{
txt_area.x2 = dsc->draw_area->x2 - 5;
txt_area.x1 = txt_area.x2 - txt_size.x + 1;
label_dsc.color = lv_color_black();
label_dsc.color = lv_color_white();
}
// If the indicator is still short put the text out of it on the right
else
{
txt_area.x1 = dsc->draw_area->x2 + 5;
txt_area.x2 = txt_area.x1 + txt_size.x - 1;
label_dsc.color = lv_color_white();
label_dsc.color = lv_color_black();
}

txt_area.y1 = (dsc->draw_area->y1 + (lv_area_get_height(dsc->draw_area) - txt_size.y) / 2) + 1;
Expand Down
2 changes: 1 addition & 1 deletion Firmware/CoverUI/YardForce/WidgetLedSymbol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace display
{
label = lv_label_create(lv_scr_act());
lv_label_set_text(label, symbol_str.c_str());
lv_obj_set_style_text_color(lv_scr_act(), lv_color_hex(0xffffff), LV_PART_MAIN);
lv_obj_set_style_text_color(lv_scr_act(), lv_color_black(), LV_PART_MAIN);
lv_obj_align(label, align, x_ofs, y_ofs);
}

Expand Down
1 change: 0 additions & 1 deletion Firmware/CoverUI/YardForce/WidgetTextTicker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ namespace display
WidgetTextTicker(lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs, lv_coord_t w)
{
label = lv_label_create(lv_scr_act());
//lv_obj_set_style_text_color(lv_scr_act(), lv_color_hex(0xffffff), LV_PART_MAIN);
lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_set_style_text_font(label, &PerfectPixel_20, LV_PART_MAIN);
lv_obj_align(label, align, x_ofs, y_ofs);
Expand Down
92 changes: 92 additions & 0 deletions Firmware/CoverUI/YardForce/assets/OM_Logo_120x54x1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#ifdef __has_include
#if __has_include("lvgl.h")
#ifndef LV_LVGL_H_INCLUDE_SIMPLE
#define LV_LVGL_H_INCLUDE_SIMPLE
#endif
#endif
#endif

#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
#include "lvgl.h"
#else
#include "lvgl/lvgl.h"
#endif


#ifndef LV_ATTRIBUTE_MEM_ALIGN
#define LV_ATTRIBUTE_MEM_ALIGN
#endif

#ifndef LV_ATTRIBUTE_IMG_OM_LOGO_120X54X1
#define LV_ATTRIBUTE_IMG_OM_LOGO_120X54X1
#endif

const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_OM_LOGO_120X54X1 uint8_t OM_Logo_120x54x1_map[] = {
0xff, 0xff, 0xff, 0xff, /*Color of index 0*/
0x00, 0x00, 0x00, 0xff, /*Color of index 1*/

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xaa, 0xaa, 0xab, 0xfc, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf5, 0xff, 0xff, 0xfd, 0x57, 0xe0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x5d, 0x55, 0x55, 0x57, 0xfa, 0xbc, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xea, 0xef, 0xff, 0xff, 0xfa, 0xaf, 0xd7, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xbf, 0x6a, 0xaa, 0xaa, 0xaf, 0xf5, 0x7a, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0xd5, 0xdf, 0xff, 0xff, 0xf5, 0x5f, 0xaf, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xee, 0xff, 0x75, 0x55, 0x55, 0x5f, 0xf0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x07, 0x5b, 0xaa, 0xdf, 0xff, 0x0f, 0xea, 0x80, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1d, 0xee, 0xfe, 0xea, 0xaa, 0x02, 0xbe, 0x01, 0xf0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x6b, 0x75, 0xa0, 0x00, 0x00, 0x07, 0xd0, 0x01, 0xf0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xbb, 0x5e, 0xc0, 0x00, 0x00, 0x05, 0x60, 0x1f, 0xff, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0xde, 0xeb, 0x87, 0xff, 0xfc, 0x07, 0xc0, 0x7f, 0xff, 0xc0, 0x00,
0x00, 0x00, 0x00, 0x0a, 0xeb, 0xbd, 0x05, 0x55, 0x57, 0x0a, 0x81, 0xff, 0xff, 0xf0, 0x00,
0x00, 0x00, 0x00, 0x1f, 0x5d, 0x6e, 0x1f, 0xff, 0xfb, 0xf7, 0x37, 0xff, 0xff, 0xfd, 0x80,
0x00, 0x00, 0x00, 0x55, 0xf7, 0x74, 0x35, 0x55, 0x5a, 0xba, 0x7f, 0xff, 0xff, 0xff, 0xc0,
0x00, 0x00, 0x00, 0xfe, 0xad, 0xd8, 0x5f, 0xff, 0xef, 0xdc, 0xff, 0xff, 0xff, 0xff, 0xc0,
0x00, 0x00, 0x00, 0xab, 0xee, 0xd0, 0xea, 0xaa, 0xba, 0xd4, 0xff, 0xff, 0xff, 0xff, 0xc0,
0x00, 0x00, 0x03, 0xfd, 0x77, 0x61, 0x7c, 0x7f, 0xd7, 0xb8, 0x7f, 0xff, 0xff, 0xff, 0xc0,
0x00, 0x00, 0x05, 0x57, 0x5b, 0x43, 0xa8, 0x15, 0x7d, 0xd0, 0xff, 0xff, 0xff, 0xff, 0xc0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xab, 0x70, 0xff, 0xff, 0xff, 0xff, 0xe0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xfb, 0xa1, 0xff, 0xff, 0xff, 0xff, 0xf0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x5d, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xf0,
0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x15, 0xd6, 0xa3, 0xff, 0xfe, 0x0f, 0xff, 0xf8,
0x00, 0x06, 0xaa, 0xaa, 0xaa, 0xaa, 0xae, 0xfe, 0xfd, 0xc3, 0xff, 0xf8, 0x03, 0xff, 0xf8,
0x00, 0x1b, 0xff, 0xff, 0xff, 0xff, 0xfb, 0x57, 0x57, 0x43, 0xff, 0xf0, 0x01, 0xff, 0xf8,
0x00, 0x16, 0xaa, 0xaa, 0xaa, 0xaa, 0xae, 0xfa, 0xfa, 0xc7, 0xff, 0xe0, 0x00, 0xff, 0xfc,
0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xeb, 0xaf, 0xae, 0xc7, 0xff, 0xc0, 0x00, 0x7f, 0xfc,
0x00, 0x00, 0x02, 0xaa, 0xaa, 0xaa, 0xbd, 0x75, 0x77, 0x07, 0xff, 0xc0, 0x00, 0x7f, 0xfc,
0x0f, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xd7, 0xdf, 0xbb, 0x9f, 0xff, 0xc0, 0x00, 0x7f, 0xff,
0x15, 0x55, 0x62, 0xaa, 0xaa, 0xaa, 0xfa, 0xb5, 0xd6, 0x9f, 0xff, 0x80, 0x00, 0x3f, 0xff,
0x7f, 0xff, 0xb1, 0xff, 0xff, 0xe2, 0xaf, 0xdd, 0x7b, 0x9f, 0xff, 0x80, 0x00, 0x3f, 0xff,
0xaa, 0xaa, 0xe8, 0x55, 0x55, 0x41, 0xf5, 0x77, 0xae, 0x9f, 0xff, 0x80, 0x00, 0x7f, 0xff,
0xff, 0xff, 0xbc, 0x00, 0x00, 0x01, 0x5f, 0xba, 0xfb, 0x9f, 0xff, 0xc0, 0x00,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 0xdf, 0xfb, 0xef, 0xab, 0x7d, 0x50, 0x7f, 0xff, 0xff, 0xff, 0xc0,
0x35, 0xaa, 0xfe, 0xaa, 0xea, 0xad, 0x6a, 0xfb, 0xd7, 0xf0, 0x3f, 0xff, 0xff, 0xff, 0x80,
0x5e, 0xff, 0x55, 0xff, 0x7f, 0xfb, 0xdf, 0x5d, 0x7a, 0xa0, 0x03, 0xff, 0xff, 0xf9, 0x00,
0x57, 0x55, 0xfe, 0xab, 0x55, 0x5d, 0x75, 0xd7, 0xaf, 0xe0, 0x01, 0xff, 0xff, 0xf0, 0x00,
0x7b, 0xfe, 0xab, 0xfd, 0xff, 0xef, 0xae, 0xfa, 0xf5, 0x40, 0x00, 0x7f, 0xff, 0xc0, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xfe, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x00,
};

const lv_img_dsc_t OM_Logo_120x54x1 = {
.header.cf = LV_IMG_CF_INDEXED_1BIT,
.header.always_zero = 0,
.header.reserved = 0,
.header.w = 120,
.header.h = 54,
.data_size = 818,
.data = OM_Logo_120x54x1_map,
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 3a68a87

Please sign in to comment.