Merge develop into main branch (#137)

* SdCard HAL refactored (#135)

- Refactor SdCard HAL
- introduce Lockable

* Screenshot and FatFS improvements (#136)

- Fix screenshots on ESP32
- Improve Screenshot service
- Convert Screenshot app to class-based instead of structs
- Screenshot app now automatically updates when task is finished
- Enable FatFS long filename support

* Re-use common log messages (#138)

For consistency and binary size reduction

* Toolbar spinner should get margin to the right

* More TactilityC features (#139)

* Rewrote Loader

- Simplified Loader by removing custom threa
- Created DispatcherThread
- Move auto-starting apps to Boot app
- Fixed Dispatcher bug where it could get stuck not processing new
messages

* Hide AP settings if the AP is not saved

* Missing from previous commit

* Replace LV_EVENT_CLICKED with LV_EVENT_SHORT_CLICKED

* Refactored files app and created InputDialog (#140)

- Changed Files app so that it has a View and State
- Files app now allows for long-pressing on files to perform actions
- Files app now has rename and delete actions
- Created InputDialog app
- Improved AlertDialog app layout
This commit is contained in:
Ken Van Hoeylandt
2024-12-27 22:12:39 +00:00
committed by GitHub
parent 9033daa6dd
commit 50bd6e8bf6
144 changed files with 3244 additions and 2038 deletions
+7 -8
View File
@@ -5,18 +5,17 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if (DEFINED ENV{ESP_IDF_VERSION})
file(GLOB_RECURSE SOURCE_FILES Source/*.c*) # TODO: Fix
idf_component_register(
SRCS ${SOURCE_FILES}
INCLUDE_DIRS "src/"
SRC_DIRS "Source/"
INCLUDE_DIRS "Source/"
PRIV_INCLUDE_DIRS "Private/"
REQUIRES lvgl
)
add_definitions(-DESP_PLATFORM)
else()
file(GLOB SOURCES "src/*.c*")
file(GLOB HEADERS "src/*.h*")
file(GLOB SOURCES "Source/*.c*")
file(GLOB HEADERS "Source/*.h*")
add_library(lv_screenshot STATIC)
@@ -26,8 +25,8 @@ else()
)
target_include_directories(lv_screenshot
PRIVATE private
PUBLIC src
PRIVATE Private
PUBLIC Source
)
target_link_libraries(lv_screenshot
@@ -1,25 +1,29 @@
#include "lv_screenshot.h"
#include "save_png.h"
#include "save_bmp.h"
#ifdef __cplusplus
extern "C" {
#endif
static void data_pre_processing(lv_draw_buf_t* snapshot, uint16_t bpp, lv_100ask_screenshot_sv_t screenshot_sv);
bool lv_screenshot_create(lv_obj_t* obj, lv_color_format_t cf, lv_100ask_screenshot_sv_t screenshot_sv, const char* filename) {
lv_draw_buf_t* snapshot = lv_snapshot_take(obj, cf);
bool lv_screenshot_create(lv_obj_t* obj, lv_100ask_screenshot_sv_t screenshot_sv, const char* filename) {
lv_draw_buf_t* snapshot = lv_snapshot_take(obj, LV_COLOR_FORMAT_RGB888);
if (snapshot) {
data_pre_processing(snapshot, LV_COLOR_DEPTH, screenshot_sv);
bool success = false;
if (screenshot_sv == LV_100ASK_SCREENSHOT_SV_PNG) {
if (LV_COLOR_DEPTH == 16) {
lv_screenshot_save_png_file(snapshot->data, snapshot->header.w, snapshot->header.h, 24, filename);
} else if (LV_COLOR_DEPTH == 32) {
lv_screenshot_save_png_file(snapshot->data, snapshot->header.w, snapshot->header.h, 32, filename);
}
data_pre_processing(snapshot, 24, screenshot_sv);
success = lv_screenshot_save_png_file(snapshot->data, snapshot->header.w, snapshot->header.h, 24, filename);
} else if (screenshot_sv == LV_100ASK_SCREENSHOT_SV_BMP) {
data_pre_processing(snapshot, 24, screenshot_sv);
success = lve_screenshot_save_bmp_file(snapshot->data, snapshot->header.w, snapshot->header.h, 24, filename);
}
lv_draw_buf_destroy(snapshot);
return true;
return success;
}
return false;
@@ -45,16 +49,21 @@ static void data_pre_processing(lv_draw_buf_t* snapshot, uint16_t bpp, lv_100ask
count += 3;
}
}
} else if ((screenshot_sv == LV_100ASK_SCREENSHOT_SV_PNG) && (bpp == 32)) {
} else if ((screenshot_sv == LV_100ASK_SCREENSHOT_SV_PNG) && (bpp == 32 || bpp == 24)) {
uint8_t tmp_data = 0;
uint32_t count = 0;
uint32_t pixel_byte_gap = bpp / 8;
for (int w = 0; w < snapshot->header.w; w++) {
for (int h = 0; h < snapshot->header.h; h++) {
tmp_data = *(snapshot->data + count);
*(uint8_t*)(snapshot->data + count) = *(snapshot->data + count + 2);
*(uint8_t*)(snapshot->data + count + 2) = tmp_data;
count += 4;
count += pixel_byte_gap;
}
}
}
}
#ifdef __cplusplus
}
#endif
@@ -1,8 +1,6 @@
#pragma once
#include "lvgl.h"
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
@@ -14,7 +12,7 @@ typedef enum {
LV_100ASK_SCREENSHOT_SV_LAST
} lv_100ask_screenshot_sv_t;
bool lv_screenshot_create(lv_obj_t* obj, lv_color_format_t cf, lv_100ask_screenshot_sv_t screenshot_sv, const char* filename);
bool lv_screenshot_create(lv_obj_t* obj, lv_100ask_screenshot_sv_t screenshot_sv, const char* filename);
#ifdef __cplusplus
} /*extern "C"*/
+96
View File
@@ -0,0 +1,96 @@
#include <memory.h>
#include <stdint.h>
#include <stdbool.h>
#include "lvgl.h"
typedef struct tagBITMAPFILEHEADER {
uint16_t bfType;
uint32_t bfSize;
uint16_t bfReserved1;
uint16_t bfReserved2;
uint32_t bfOffBits;
} __attribute__((packed)) BITMAPFILEHEADER, *PBITMAPFILEHEADER;
typedef struct tagBITMAPINFOHEADER {
uint32_t biSize;
uint32_t biwidth;
uint32_t biheight;
uint16_t biPlanes;
uint16_t biBitCount;
uint32_t biCompression;
uint32_t biSizeImage;
uint32_t biXPelsPerMeter;
uint32_t biYPelsPerMeter;
uint32_t biClrUsed;
uint32_t biClrImportant;
} __attribute__((packed)) BITMAPINFOHEADER, *PBITMAPINFOHEADER;
typedef struct tagRGBQUAD {
uint8_t rgbBlue;
uint8_t rgbGreen;
uint8_t rgbRed;
uint8_t rgbReserved;
} __attribute__((packed)) RGBQUAD;
bool lve_screenshot_save_bmp_file(const uint8_t* image, uint32_t w, uint32_t h, uint32_t bpp, const char* filename) {
BITMAPFILEHEADER tBmpFileHead;
BITMAPINFOHEADER tBmpInfoHead;
uint32_t dwSize;
uint32_t bw;
lv_fs_file_t f;
memset(&tBmpFileHead, 0, sizeof(BITMAPFILEHEADER));
memset(&tBmpInfoHead, 0, sizeof(BITMAPINFOHEADER));
lv_fs_res_t res = lv_fs_open(&f, filename, LV_FS_MODE_WR);
if (res != LV_FS_RES_OK) {
LV_LOG_USER("Can't create output file %s", filename);
return false;
}
tBmpFileHead.bfType = 0x4d42;
tBmpFileHead.bfSize = 0x36 + w * h * (bpp / 8);
tBmpFileHead.bfOffBits = 0x00000036;
tBmpInfoHead.biSize = 0x00000028;
tBmpInfoHead.biwidth = w;
tBmpInfoHead.biheight = h;
tBmpInfoHead.biPlanes = 0x0001;
tBmpInfoHead.biBitCount = bpp;
tBmpInfoHead.biCompression = 0;
tBmpInfoHead.biSizeImage = w * h * (bpp / 8);
tBmpInfoHead.biXPelsPerMeter = 0;
tBmpInfoHead.biYPelsPerMeter = 0;
tBmpInfoHead.biClrUsed = 0;
tBmpInfoHead.biClrImportant = 0;
res = lv_fs_write(&f, &tBmpFileHead, sizeof(tBmpFileHead), &bw);
if (bw != sizeof(tBmpFileHead)) {
LV_LOG_USER("Can't write BMP File Head to %s", filename);
return false;
}
res = lv_fs_write(&f, &tBmpInfoHead, sizeof(tBmpInfoHead), &bw);
if (bw != sizeof(tBmpInfoHead)) {
LV_LOG_USER("Can't write BMP File Info Head to %s", filename);
return false;
}
dwSize = w * bpp / 8;
const uint8_t* pPos = image + (h - 1) * dwSize;
while (pPos >= image) {
res = lv_fs_write(&f, pPos, dwSize, &bw);
if (bw != dwSize) {
LV_LOG_USER("Can't write date to BMP File %s", filename);
return false;
}
pPos -= dwSize;
}
lv_fs_close(&f);
return true;
}
@@ -1,11 +1,11 @@
#include "save_png.h"
#include "src/libs/lodepng/lodepng.h"
bool lv_screenshot_save_png_file(const uint8_t* image, uint32_t w, uint32_t h, uint32_t bpp, const char* filename) {
if (bpp == 32) {
return lodepng_encode32_file(filename, image, w, h);
return lodepng_encode32_file(filename, image, w, h) == 0;
} else if (bpp == 24) {
return lodepng_encode24_file(filename, image, w, h);
return lodepng_encode24_file(filename, image, w, h) == 0;
} else {
return false;
}
return false;
}