Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .claude/settings.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"Bash(pio)",
"Bash(pio run)",
"Bash(cpplint:*)",
"Bash(grep:*)"
"Bash(grep:*)",
"Bash(pio test:*)",
"Bash(pio run:*)"
],
"deny": []
}
Expand Down
181 changes: 47 additions & 134 deletions inc/sp140/lvgl/lv_conf.h
Original file line number Diff line number Diff line change
@@ -1,88 +1,46 @@
/**
* @file lv_conf.h
* Configuration file for LVGL
* Configuration file for LVGL v9
*/

#ifndef LV_CONF_H // NOLINT(build/header_guard)
#define LV_CONF_H // NOLINT(build/header_guard)

#include <stdint.h>

/*====================
COLOR SETTINGS
*====================*/

/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/
/*Color depth: 8 (A8), 16 (RGB565), 24 (RGB888), 32 (XRGB8888)*/
#define LV_COLOR_DEPTH 16

/*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface*/
#define LV_COLOR_16_SWAP 0

/*Enable features to draw on transparent background*/
#define LV_COLOR_SCREEN_TRANSP 0

/*Images pixels with this color will not be drawn if they are chroma keyed)*/
#define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00) /*pure green*/

/*=========================
MEMORY SETTINGS
STDLIB SETTINGS
*=========================*/

/*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/
#define LV_MEM_CUSTOM 0
#if LV_MEM_CUSTOM == 0
/*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/
#define LV_MEM_SIZE (48U * 1024U) /*[bytes]*/

/*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/
#define LV_MEM_ADR 0 /*0: unused*/
/*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/
#if LV_MEM_ADR == 0
/*Use LVGL's built-in memory manager*/
#define LV_USE_STDLIB_MALLOC LV_STDLIB_BUILTIN

#endif
/*Size of the memory available for `lv_malloc()` in bytes (>= 2kB)*/
#define LV_MEM_SIZE (48U * 1024U)

#else /*LV_MEM_CUSTOM*/
#define LV_MEM_CUSTOM_INCLUDE <stdlib.h> /*Header for the dynamic memory function*/
#define LV_MEM_CUSTOM_ALLOC malloc
#define LV_MEM_CUSTOM_FREE free
#define LV_MEM_CUSTOM_REALLOC realloc
#endif /*LV_MEM_CUSTOM*/
#define LV_USE_STDLIB_STRING LV_STDLIB_BUILTIN
#define LV_USE_STDLIB_SPRINTF LV_STDLIB_BUILTIN

/*Number of the intermediate memory buffer used during rendering and other internal processing mechanisms.
*You will see an error log message if there wasn't enough buffers. */
#define LV_MEM_BUF_MAX_NUM 16
/*=========================
OS SETTINGS
*=========================*/

/*Use the standard `memcpy` and `memset` instead of LVGL's own functions. (Might or might not be faster).*/
#define LV_MEMCPY_MEMSET_STD 0
/*Use no OS - keep existing lvglMutex for now*/
#define LV_USE_OS LV_OS_NONE

/*====================
HAL SETTINGS
*====================*/

/*Default display refresh period. LVG will redraw changed areas with this period time*/
#define LV_DISP_DEF_REFR_PERIOD 30 /*[ms]*/

/*Input device read period in milliseconds*/
#define LV_INDEV_DEF_READ_PERIOD 30 /*[ms]*/

/*Disable input devices to save resources*/
#define LV_USE_INDEV_TOUCHSCREEN 0 /*Disable touchscreen support*/
#define LV_USE_INDEV_TOUCHPAD 0 /*Disable touchpad support*/
#define LV_USE_INDEV_MOUSE 0 /*Disable mouse support*/
#define LV_USE_INDEV_KEYPAD 0 /*Disable keypad support*/
#define LV_USE_INDEV_ENCODER 0 /*Disable encoder support*/
#define LV_USE_INDEV_BUTTON 0 /*Disable button input device emulation*/

/*Use a custom tick source that tells the elapsed time in milliseconds.
*It removes the need to manually update the tick with `lv_tick_inc()`)*/
#define LV_TICK_CUSTOM 0
#if LV_TICK_CUSTOM
#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/
#endif /*LV_TICK_CUSTOM*/

/*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings.
*(Not so important, you can adjust it to modify default sizes and spaces)*/
/*Default display refresh, period. LVGL will redraw changed areas with this period time*/
#define LV_DEF_REFR_PERIOD 30 /*[ms]*/

/*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings.*/
#define LV_DPI_DEF 130 /*[px/inch]*/

/*=======================
Expand All @@ -93,67 +51,27 @@
* Drawing
*-----------*/

/*Enable complex draw engine.
*Required to draw shadow, gradient, rounded corners, circles, arc, skew lines, image transformations or any masks*/
#define LV_DRAW_COMPLEX 1
#if LV_DRAW_COMPLEX != 0
/*Enable complex draw engine*/
#define LV_DRAW_SW_COMPLEX 1

/*Allow buffering some shadow calculation.
*LV_SHADOW_CACHE_SIZE is the max. shadow size to buffer, where shadow size is `shadow_width + radius`
*Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost*/
#define LV_SHADOW_CACHE_SIZE 0
/*Allow buffering some shadow calculation.
*LV_DRAW_SW_SHADOW_CACHE_SIZE is the max. shadow size to buffer*/
#define LV_DRAW_SW_SHADOW_CACHE_SIZE 0

/* Set number of maximally cached circle data.
* The circumference of 1/4 circle are saved for anti-aliasing
* radius * 4 bytes are used per circle (the most often used radiuses are saved)
* 0: to disable caching */
#define LV_CIRCLE_CACHE_SIZE 4
#endif /*LV_DRAW_COMPLEX*/
/*Set number of maximally cached circle data*/
#define LV_DRAW_SW_CIRCLE_CACHE_SIZE 4

/**
* "Simple layers" are used when a widget has `style_opa < 255` to buffer the widget into a layer
* and blend it as an image with the given opacity.
* Note that `bg_opa`, `text_opa` etc don't require buffering into layer)
* The widget can be buffered in smaller chunks to avoid using large buffers.
*
* - LV_LAYER_SIMPLE_BUF_SIZE: [bytes] the optimal target buffer size. LVGL will try to allocate it
* - LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE: [bytes] used if `LV_LAYER_SIMPLE_BUF_SIZE` couldn't be allocated.
*
* Both buffer sizes are in bytes.
* "Transformed layers" (where transform_angle/zoom properties are used) use larger buffers
* and can't be drawn in chunks. So these settings affects only widgets with opacity.
*/
#define LV_LAYER_SIMPLE_BUF_SIZE (24 * 1024)
#define LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE (3 * 1024)

/*Default image cache size. Image caching keeps the images opened.
*If only the built-in image formats are used there is no real advantage of caching. (I.e. if no new image decoder is added)
*With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images.
*However the opened images might consume additional RAM.
*0: to disable caching*/
#define LV_IMG_CACHE_DEF_SIZE 0

/*Number of stops allowed per gradient. Increase this to allow more stops.
*This adds (sizeof(lv_color_t) + 1) bytes per additional stop*/
/*Buffer size for simple layers*/
#define LV_DRAW_LAYER_SIMPLE_BUF_SIZE (24 * 1024)

/*Default image cache size*/
#define LV_IMAGE_CACHE_DEF_SIZE 0

/*Number of stops allowed per gradient*/
#define LV_GRADIENT_MAX_STOPS 2

/*Default gradient buffer size.
*When LVGL calculates the gradient "maps" it can save them into a cache to avoid calculating them again.
*LV_GRAD_CACHE_DEF_SIZE sets the size of this cache in bytes.
*If the cache is too small the map will be allocated only while it's required for the drawing.
*0 mean no caching.*/
#define LV_GRAD_CACHE_DEF_SIZE 0

/*Allow dithering the gradients (to achieve visual smooth color gradients on limited color depth display)
*LV_DITHER_GRADIENT implies allocating one or two more lines of the object's rendering surface
*The increase in memory consumption is (32 bits * object width) plus 24 bits * object width if using error diffusion */
#define LV_DITHER_GRADIENT 0
#if LV_DITHER_GRADIENT
/*Add support for error diffusion dithering.
*Error diffusion dithering gets a much better visual result, but implies more CPU consumption and memory when drawing.
*The increase in memory consumption is (24 bits * object's width)*/
#define LV_DITHER_ERROR_DIFFUSION 0
#endif
/*Number of parallel draw units (1 = single threaded)*/
#define LV_DRAW_THREAD_COUNT 1

/*-------------
* Fonts
Expand Down Expand Up @@ -191,8 +109,6 @@

/**
* Enable handling large font and/or fonts with a lot of characters.
* The limit depends on the font size, font face and bpp.
* Compiler error will be triggered if a font needs it.
*/
#define LV_FONT_FMT_TXT_LARGE 0

Expand All @@ -208,9 +124,6 @@

/**
* Select a character encoding for strings.
* Your IDE or editor should have the same character encoding
* - LV_TXT_ENC_UTF8
* - LV_TXT_ENC_ASCII
*/
#define LV_TXT_ENC LV_TXT_ENC_UTF8

Expand All @@ -221,19 +134,15 @@
* WIDGET USAGE
*=================*/

/*
Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html
*/

#define LV_USE_ANIMIMG 0
#define LV_USE_ANIMIMAGE 0

#define LV_USE_ARC 1

#define LV_USE_BAR 1

#define LV_USE_BTN 1
#define LV_USE_BUTTON 1

#define LV_USE_BTNMATRIX 1 /* Required by other components */
#define LV_USE_BUTTONMATRIX 1 /* Required by other components */

#define LV_USE_CANVAS 0 /* Don't need canvas */

Expand All @@ -243,7 +152,7 @@ Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.

#define LV_USE_DROPDOWN 0 /* Don't need dropdown */

#define LV_USE_IMG 1 /*Requires: lv_label*/
#define LV_USE_IMAGE 1 /*Requires: lv_label*/

#define LV_USE_LABEL 1
#if LV_USE_LABEL
Expand Down Expand Up @@ -272,6 +181,9 @@ Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.
/* keyboard widget (set to 0 since we don't use it) */
#define LV_USE_KEYBOARD 0

/*Extra widgets*/
#define LV_USE_LED 1

/*==================
* THEMES
*==================*/
Expand Down Expand Up @@ -305,10 +217,11 @@ Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.
*====================*/

#define LV_USE_FS_STDIO 0
#if LV_USE_FS_STDIO
#define LV_FS_STDIO_LETTER 'A' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
#define LV_FS_STDIO_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/
#define LV_FS_STDIO_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
#endif

/*====================
* DEMOS & EXAMPLES
*====================*/

#define LV_BUILD_EXAMPLES 0

#endif /*LV_CONF_H*/
13 changes: 5 additions & 8 deletions inc/sp140/lvgl/lvgl_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,16 @@
#define SCREEN_WIDTH 160
#define SCREEN_HEIGHT 128

// LVGL buffer size - optimize for our display
// Use half screen size for single flush to balance performance and memory usage
#define LVGL_BUFFER_SIZE (SCREEN_WIDTH * SCREEN_HEIGHT / 2)
// LVGL buffer size in bytes - half screen for partial rendering
// v9 uses byte-based buffers: width * height * bytes_per_pixel / 2
#define LVGL_BUF_BYTES (SCREEN_WIDTH * SCREEN_HEIGHT * 2 / 2)

// LVGL refresh time in ms - match the config file setting
#define LVGL_REFRESH_TIME 40

// Core LVGL globals
extern int8_t displayCS; // Display chip select pin
extern lv_disp_drv_t disp_drv;
extern lv_disp_draw_buf_t draw_buf;
extern lv_color_t buf[LVGL_BUFFER_SIZE];
extern lv_color_t buf2[LVGL_BUFFER_SIZE]; // Second buffer for double buffering
extern lv_display_t* main_display;
extern Adafruit_ST7735* tft_driver;
extern uint32_t lvgl_last_update;
// Shared SPI bus mutex (guards TFT + MCP2515 access)
Expand All @@ -33,7 +30,7 @@ extern SemaphoreHandle_t spiBusMutex;
// Core function declarations
void setupLvglBuffer();
void setupLvglDisplay(const STR_DEVICE_DATA_140_V1& deviceData, int8_t dc_pin, int8_t rst_pin, SPIClass* spi);
void lvgl_flush_cb(lv_disp_drv_t* disp, const lv_area_t* area, lv_color_t* color_p);
void lvgl_flush_cb(lv_display_t* disp, const lv_area_t* area, uint8_t* px_map);
void lv_tick_handler();
void updateLvgl();
void displayLvglSplash(const STR_DEVICE_DATA_140_V1& deviceData, int duration);
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ lib_deps =
https://github.com/rlogiacco/CircularBuffer@1.4.0
https://github.com/openppg/SINE-ESC-CAN#8caa93996b5d000fe10ca5265bd1c472dfdf885b
https://github.com/openppg/ANT-BMS-CAN#fd54852bc6f1c9608e37af9ca7c13ea4135c095b
lvgl/lvgl@^8.4.0
lvgl/lvgl@^9.5.0
h2zero/NimBLE-Arduino@^2.3.9
lib_ignore =
Adafruit SleepyDog Library
Expand Down
21 changes: 12 additions & 9 deletions src/assets/img/cruise-control-340255-30.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,17 @@ const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_CRUISE_CO
0x00, 0x00, 0x00, 0x00,
};

const lv_img_dsc_t cruise_control_340255_30 = {
{
LV_IMG_CF_ALPHA_1BIT,
0,
0,
30,
30,
const lv_image_dsc_t cruise_control_340255_30 = {
.header = {
.magic = LV_IMAGE_HEADER_MAGIC,
.cf = LV_COLOR_FORMAT_A1,
.flags = 0,
.w = 30,
.h = 30,
.stride = 4, /* ceil(30/8) = 4 bytes per row */
.reserved_2 = 0,
},
120,
cruise_control_340255_30_map,
.data_size = 120,
.data = cruise_control_340255_30_map,
.reserved = NULL,
};
22 changes: 12 additions & 10 deletions src/assets/img/energy-539741-26.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,17 @@ const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_ENERGY_53
0x00, 0x00, 0x00,
};

const lv_img_dsc_t energy_539741_26 = {
// Header struct (lv_img_header_t)
{
LV_IMG_CF_ALPHA_1BIT, // Color format
0, // Always zero
0, // Reserved
24, // Width
26, // Height
const lv_image_dsc_t energy_539741_26 = {
.header = {
.magic = LV_IMAGE_HEADER_MAGIC,
.cf = LV_COLOR_FORMAT_A1,
.flags = 0,
.w = 24,
.h = 26,
.stride = 3, /* ceil(24/8) = 3 bytes per row */
.reserved_2 = 0,
},
78, // Data size
energy_539741_26_map, // Pointer to image data
.data_size = 78,
.data = energy_539741_26_map,
.reserved = NULL,
};
Loading