sim: LittleVgl: update s.t. LVGL-FS driver is initialized by LittleVgl
InfiniTime moved the LVGL-FS driver initialization to the LittleVgl constructor and passed the FS member to do that. Update the simulator copy of LittleVgl to do just that. Fixes: https://github.com/InfiniTimeOrg/InfiniSim/issues/89
This commit is contained in:
parent
44452ccdf6
commit
02f980f278
|
@ -211,18 +211,10 @@ target_sources(infinisim PUBLIC
|
|||
${InfiniTime_DIR}/src/systemtask/SystemMonitor.cpp
|
||||
)
|
||||
|
||||
if(EXISTS ${InfiniTime_DIR}/src/displayapp/InfiniTimeTheme.cpp)
|
||||
target_compile_definitions(infinisim PUBLIC INFINITIME_THEME_CPP)
|
||||
target_sources(infinisim PUBLIC
|
||||
${InfiniTime_DIR}/src/displayapp/InfiniTimeTheme.cpp
|
||||
${InfiniTime_DIR}/src/displayapp/InfiniTimeTheme.h
|
||||
)
|
||||
else()
|
||||
target_sources(infinisim PUBLIC
|
||||
${InfiniTime_DIR}/src/displayapp/lv_pinetime_theme.h
|
||||
${InfiniTime_DIR}/src/displayapp/lv_pinetime_theme.c
|
||||
)
|
||||
endif()
|
||||
|
||||
# littlefs
|
||||
add_library(littlefs STATIC
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit ce2277cbcac0f28b27c1483fba09921f43d590cd
|
||||
Subproject commit 9bbd2ddbc4e44742913e35e25b21b80d80efe36b
|
8
main.cpp
8
main.cpp
|
@ -21,11 +21,7 @@
|
|||
#include "lv_drivers/indev/mousewheel.h"
|
||||
|
||||
// get PineTime header
|
||||
#if defined(INFINITIME_THEME_CPP)
|
||||
#include "displayapp/InfiniTimeTheme.h"
|
||||
#else
|
||||
#include "displayapp/lv_pinetime_theme.h"
|
||||
#endif
|
||||
#include <drivers/Hrs3300.h>
|
||||
#include <drivers/Bma421.h>
|
||||
|
||||
|
@ -330,8 +326,6 @@ Pinetime::Drivers::Cst816S touchPanel; // {twiMaster, touchPanelTwiAddress};
|
|||
// #include "displayapp/LittleVgl.h"
|
||||
// #include "displayapp/DisplayApp.h"
|
||||
//#endif
|
||||
Pinetime::Components::LittleVgl lvgl {lcd};
|
||||
|
||||
Pinetime::Drivers::Bma421 motionSensor {twiMaster, motionSensorTwiAddress};
|
||||
Pinetime::Drivers::Hrs3300 heartRateSensor {twiMaster, heartRateSensorTwiAddress};
|
||||
|
||||
|
@ -347,6 +341,8 @@ Pinetime::Controllers::FS fs {spiNorFlash};
|
|||
Pinetime::Controllers::Settings settingsController {fs};
|
||||
Pinetime::Controllers::MotorController motorController {};
|
||||
|
||||
Pinetime::Components::LittleVgl lvgl {lcd, fs};
|
||||
|
||||
Pinetime::Controllers::DateTime dateTimeController {settingsController};
|
||||
Pinetime::Drivers::Watchdog watchdog;
|
||||
Pinetime::Controllers::NotificationManager notificationManager;
|
||||
|
|
|
@ -1,20 +1,17 @@
|
|||
#include "displayapp/LittleVgl.h"
|
||||
#if defined(INFINITIME_THEME_CPP)
|
||||
#include "displayapp/InfiniTimeTheme.h"
|
||||
#else
|
||||
#include "displayapp/lv_pinetime_theme.h"
|
||||
#endif
|
||||
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
#include <timers.h>
|
||||
////#include <projdefs.h>
|
||||
#include "drivers/Cst816s.h"
|
||||
#include "drivers/St7789.h"
|
||||
#include "littlefs/lfs.h"
|
||||
#include "components/fs/FS.h"
|
||||
|
||||
// lv-sim monitor display driver for monitor_flush() function
|
||||
#include "lv_drivers/display/monitor.h"
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <array>
|
||||
|
||||
using namespace Pinetime::Components;
|
||||
|
@ -24,8 +21,44 @@ namespace {
|
|||
lv_theme_t* theme = lv_pinetime_theme_init();
|
||||
lv_theme_set_act(theme);
|
||||
}
|
||||
|
||||
lv_fs_res_t lvglOpen(lv_fs_drv_t* drv, void* file_p, const char* path, lv_fs_mode_t /*mode*/) {
|
||||
lfs_file_t* file = static_cast<lfs_file_t*>(file_p);
|
||||
Pinetime::Controllers::FS* filesys = static_cast<Pinetime::Controllers::FS*>(drv->user_data);
|
||||
int res = filesys->FileOpen(file, path, LFS_O_RDONLY);
|
||||
if (res == 0) {
|
||||
if (file->type == 0) {
|
||||
return LV_FS_RES_FS_ERR;
|
||||
} else {
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
}
|
||||
return LV_FS_RES_NOT_EX;
|
||||
}
|
||||
|
||||
lv_fs_res_t lvglClose(lv_fs_drv_t* drv, void* file_p) {
|
||||
Pinetime::Controllers::FS* filesys = static_cast<Pinetime::Controllers::FS*>(drv->user_data);
|
||||
lfs_file_t* file = static_cast<lfs_file_t*>(file_p);
|
||||
filesys->FileClose(file);
|
||||
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
lv_fs_res_t lvglRead(lv_fs_drv_t* drv, void* file_p, void* buf, uint32_t btr, uint32_t* br) {
|
||||
Pinetime::Controllers::FS* filesys = static_cast<Pinetime::Controllers::FS*>(drv->user_data);
|
||||
lfs_file_t* file = static_cast<lfs_file_t*>(file_p);
|
||||
filesys->FileRead(file, static_cast<uint8_t*>(buf), btr);
|
||||
*br = btr;
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
lv_fs_res_t lvglSeek(lv_fs_drv_t* drv, void* file_p, uint32_t pos) {
|
||||
Pinetime::Controllers::FS* filesys = static_cast<Pinetime::Controllers::FS*>(drv->user_data);
|
||||
lfs_file_t* file = static_cast<lfs_file_t*>(file_p);
|
||||
filesys->FileSeek(file, pos);
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
}
|
||||
lv_style_t* LabelBigStyle = nullptr;
|
||||
|
||||
static void disp_flush(lv_disp_drv_t* disp_drv, const lv_area_t* area, lv_color_t* color_p) {
|
||||
auto* lvgl = static_cast<LittleVgl*>(disp_drv->user_data);
|
||||
|
@ -47,7 +80,7 @@ bool touchpad_read(lv_indev_drv_t* indev_drv, lv_indev_data_t* data) {
|
|||
return lvgl->GetTouchPadInfo(data);
|
||||
}
|
||||
|
||||
LittleVgl::LittleVgl(Pinetime::Drivers::St7789& lcd) : lcd {lcd} {
|
||||
LittleVgl::LittleVgl(Pinetime::Drivers::St7789& lcd, Pinetime::Controllers::FS& filesystem) : lcd {lcd}, filesystem {filesystem} {
|
||||
}
|
||||
|
||||
void LittleVgl::Init() {
|
||||
|
@ -55,6 +88,7 @@ void LittleVgl::Init() {
|
|||
InitTheme();
|
||||
InitDisplay();
|
||||
InitTouchpad();
|
||||
InitFileSystem();
|
||||
}
|
||||
|
||||
void LittleVgl::InitDisplay() {
|
||||
|
@ -88,6 +122,22 @@ void LittleVgl::InitTouchpad() {
|
|||
lv_indev_drv_register(&indev_drv);
|
||||
}
|
||||
|
||||
void LittleVgl::InitFileSystem() {
|
||||
lv_fs_drv_t fs_drv;
|
||||
lv_fs_drv_init(&fs_drv);
|
||||
|
||||
fs_drv.file_size = sizeof(lfs_file_t);
|
||||
fs_drv.letter = 'F';
|
||||
fs_drv.open_cb = lvglOpen;
|
||||
fs_drv.close_cb = lvglClose;
|
||||
fs_drv.read_cb = lvglRead;
|
||||
fs_drv.seek_cb = lvglSeek;
|
||||
|
||||
fs_drv.user_data = &filesystem;
|
||||
|
||||
lv_fs_drv_register(&fs_drv);
|
||||
}
|
||||
|
||||
void LittleVgl::SetFullRefresh(FullRefreshDirections direction) {
|
||||
if (scrollDirection == FullRefreshDirections::None) {
|
||||
scrollDirection = direction;
|
||||
|
@ -204,7 +254,6 @@ void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) {
|
|||
scrollOffset = (totalNbLines) -toScroll;
|
||||
}
|
||||
lcd.VerticalScrollStartAddress(scrollOffset);
|
||||
|
||||
}
|
||||
// move the whole screen down and draw the new screen at the top of the display
|
||||
MoveScreen(&disp_drv, static_cast<int16_t>(height));
|
||||
|
@ -298,7 +347,6 @@ void LittleVgl::CancelTap() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
bool LittleVgl::GetTouchPadInfo(lv_indev_data_t* ptr) {
|
||||
ptr->point.x = touchPoint.x;
|
||||
ptr->point.y = touchPoint.y;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <components/fs/FS.h>
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Drivers {
|
||||
|
@ -11,7 +12,7 @@ namespace Pinetime {
|
|||
class LittleVgl {
|
||||
public:
|
||||
enum class FullRefreshDirections { None, Up, Down, Left, Right, LeftAnim, RightAnim };
|
||||
LittleVgl(Pinetime::Drivers::St7789& lcd);
|
||||
LittleVgl(Pinetime::Drivers::St7789& lcd, Pinetime::Controllers::FS& filesystem);
|
||||
|
||||
LittleVgl(const LittleVgl&) = delete;
|
||||
LittleVgl& operator=(const LittleVgl&) = delete;
|
||||
|
@ -37,8 +38,10 @@ namespace Pinetime {
|
|||
private:
|
||||
void InitDisplay();
|
||||
void InitTouchpad();
|
||||
void InitFileSystem();
|
||||
|
||||
Pinetime::Drivers::St7789& lcd;
|
||||
Pinetime::Controllers::FS& filesystem;
|
||||
|
||||
lv_disp_buf_t disp_buf_2;
|
||||
lv_color_t buf2_1[LV_HOR_RES_MAX * 4];
|
||||
|
|
Loading…
Reference in New Issue
Block a user