mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-28 13:46:36 +00:00
Add lvfs config
This commit is contained in:
parent
da00c41a21
commit
80052140f3
@ -183,14 +183,14 @@ typedef void* lv_group_user_data_t;
|
|||||||
typedef void* lv_fs_drv_user_data_t;
|
typedef void* lv_fs_drv_user_data_t;
|
||||||
|
|
||||||
/*File system interface*/
|
/*File system interface*/
|
||||||
#define LV_USE_FS_IF 0
|
#define LV_USE_FS_IF 1
|
||||||
#if LV_USE_FS_IF
|
#if LV_USE_FS_IF
|
||||||
# define LV_FS_IF_FATFS '\0'
|
# define LV_FS_IF_FATFS '\0'
|
||||||
#if defined(ARDUINO_ARCH_ESP32) // || defined(ARDUINO_ARCH_ESP8266)
|
#if defined(STM32F4xx) // || defined(ARDUINO_ARCH_ESP8266)
|
||||||
# define LV_FS_IF_PC 'S'
|
# define LV_FS_IF_PC '\0'
|
||||||
# define LV_FS_IF_SPIFFS '\0' // internal esp Flash
|
# define LV_FS_IF_SPIFFS '\0' // internal esp Flash
|
||||||
#else
|
#else
|
||||||
# define LV_FS_IF_PC '\0'
|
# define LV_FS_IF_PC 'S'
|
||||||
# define LV_FS_IF_SPIFFS '\0' // no internal esp Flash
|
# define LV_FS_IF_SPIFFS '\0' // no internal esp Flash
|
||||||
#endif
|
#endif
|
||||||
#endif /*LV_USE_FS_IF*/
|
#endif /*LV_USE_FS_IF*/
|
||||||
|
@ -12,8 +12,10 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <dirent.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#if !defined(ARDUINO_ARCH_ESP8266) && !defined(STM32F4xx)
|
||||||
|
#include <dirent.h>
|
||||||
|
#endif
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
@ -37,10 +39,12 @@
|
|||||||
typedef FILE* file_t;
|
typedef FILE* file_t;
|
||||||
|
|
||||||
/*Similarly to `file_t` create a type for directory reading too */
|
/*Similarly to `file_t` create a type for directory reading too */
|
||||||
#ifndef WIN32
|
#if defined(WIN32)
|
||||||
typedef DIR * dir_t;
|
|
||||||
#else
|
|
||||||
typedef HANDLE dir_t;
|
typedef HANDLE dir_t;
|
||||||
|
#elif defined(ARDUINO_ARCH_ESP8266) || defined(STM32F4xx)
|
||||||
|
typedef FILE* dir_t;
|
||||||
|
#else
|
||||||
|
typedef DIR* dir_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
@ -316,12 +320,14 @@ static lv_fs_res_t fs_rename(lv_fs_drv_t * drv, const char * oldname, const char
|
|||||||
sprintf(old, LV_FS_PC_PATH "/%s", oldname);
|
sprintf(old, LV_FS_PC_PATH "/%s", oldname);
|
||||||
sprintf(new, LV_FS_PC_PATH "/%s", newname);
|
sprintf(new, LV_FS_PC_PATH "/%s", newname);
|
||||||
|
|
||||||
int r = rename(old, new);
|
|
||||||
|
|
||||||
if(r == 0)
|
|
||||||
return LV_FS_RES_OK;
|
|
||||||
else
|
|
||||||
return LV_FS_RES_UNKNOWN;
|
return LV_FS_RES_UNKNOWN;
|
||||||
|
|
||||||
|
// int r = rename(old, new);
|
||||||
|
|
||||||
|
// if(r == 0)
|
||||||
|
// return LV_FS_RES_OK;
|
||||||
|
// else
|
||||||
|
// return LV_FS_RES_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -357,7 +363,10 @@ static lv_fs_res_t fs_dir_open(lv_fs_drv_t * drv, void * dir_p, const char * pat
|
|||||||
{
|
{
|
||||||
(void)drv; /*Unused*/
|
(void)drv; /*Unused*/
|
||||||
dir_t d;
|
dir_t d;
|
||||||
#ifndef WIN32
|
#if defined(ARDUINO_ARCH_ESP8266) || defined(STM32F4xx)
|
||||||
|
return LV_FS_RES_UNKNOWN;
|
||||||
|
|
||||||
|
#elif !defined(WIN32)
|
||||||
/*Make the path relative to the current directory (the projects root folder)*/
|
/*Make the path relative to the current directory (the projects root folder)*/
|
||||||
char buf[256];
|
char buf[256];
|
||||||
sprintf(buf, LV_FS_PC_PATH "/%s", path);
|
sprintf(buf, LV_FS_PC_PATH "/%s", path);
|
||||||
@ -414,12 +423,13 @@ static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn)
|
|||||||
(void)drv; /*Unused*/
|
(void)drv; /*Unused*/
|
||||||
dir_t* dp = dir_p; /*Just avoid the confusing casings*/
|
dir_t* dp = dir_p; /*Just avoid the confusing casings*/
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
struct dirent* entry;
|
struct dirent* entry;
|
||||||
do {
|
do {
|
||||||
entry = readdir(*dp);
|
entry = readdir(*dp);
|
||||||
|
|
||||||
if(entry) {
|
if(entry) {
|
||||||
|
|
||||||
if(entry->d_type == DT_DIR)
|
if(entry->d_type == DT_DIR)
|
||||||
sprintf(fn, "/%s", entry->d_name);
|
sprintf(fn, "/%s", entry->d_name);
|
||||||
else
|
else
|
||||||
@ -428,7 +438,9 @@ static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn)
|
|||||||
strcpy(fn, "");
|
strcpy(fn, "");
|
||||||
}
|
}
|
||||||
} while(strcmp(fn, "/.") == 0 || strcmp(fn, "/..") == 0);
|
} while(strcmp(fn, "/.") == 0 || strcmp(fn, "/..") == 0);
|
||||||
#else
|
#endif
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
strcpy(fn, next_fn);
|
strcpy(fn, next_fn);
|
||||||
|
|
||||||
strcpy(next_fn, "");
|
strcpy(next_fn, "");
|
||||||
@ -463,7 +475,10 @@ static lv_fs_res_t fs_dir_close(lv_fs_drv_t * drv, void * dir_p)
|
|||||||
{
|
{
|
||||||
(void)drv; /*Unused*/
|
(void)drv; /*Unused*/
|
||||||
dir_t* dp = dir_p;
|
dir_t* dp = dir_p;
|
||||||
#ifndef WIN32
|
#if defined(ARDUINO_ARCH_ESP8266) || defined(STM32F4xx)
|
||||||
|
return LV_FS_RES_UNKNOWN;
|
||||||
|
|
||||||
|
#elif !defined(WIN32)
|
||||||
closedir(*dp);
|
closedir(*dp);
|
||||||
#else
|
#else
|
||||||
FindClose(*dp);
|
FindClose(*dp);
|
||||||
|
36
src/hasp/hasp_lvfs.cpp
Normal file
36
src/hasp/hasp_lvfs.cpp
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/* MIT License - Copyright (c) 2019-2021 Francis Van Roie
|
||||||
|
For full license information read the LICENSE file in the project folder */
|
||||||
|
|
||||||
|
#include "lv_fs_if.h"
|
||||||
|
|
||||||
|
#include "hasp_conf.h" // include first
|
||||||
|
#include "hasp_debug.h"
|
||||||
|
|
||||||
|
void filesystem_list_path(const char* path)
|
||||||
|
{
|
||||||
|
lv_fs_dir_t dir;
|
||||||
|
lv_fs_res_t res;
|
||||||
|
res = lv_fs_dir_open(&dir, path);
|
||||||
|
if(res != LV_FS_RES_OK) {
|
||||||
|
LOG_ERROR(TAG_LVFS, "Error opening directory %s", path);
|
||||||
|
} else {
|
||||||
|
char fn[256];
|
||||||
|
while(1) {
|
||||||
|
res = lv_fs_dir_read(&dir, fn);
|
||||||
|
if(res != LV_FS_RES_OK) {
|
||||||
|
LOG_ERROR(TAG_LVFS, "Directory %s can not be read", path);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*fn is empty, if not more files to read*/
|
||||||
|
if(strlen(fn) == 0) {
|
||||||
|
LOG_WARNING(TAG_LVFS, "Directory %s listing complete", path);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_VERBOSE(TAG_LVFS, D_BULLET "%s", fn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_fs_dir_close(&dir);
|
||||||
|
}
|
9
src/hasp/hasp_lvfs.h
Normal file
9
src/hasp/hasp_lvfs.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/* MIT License - Copyright (c) 2019-2021 Francis Van Roie
|
||||||
|
For full license information read the LICENSE file in the project folder */
|
||||||
|
|
||||||
|
#ifndef HASP_LVFS_H
|
||||||
|
#define HASP_LVFS_H
|
||||||
|
|
||||||
|
void filesystem_list_path(const char* path);
|
||||||
|
|
||||||
|
#endif
|
@ -23,8 +23,7 @@
|
|||||||
#include "hasp_gui.h"
|
#include "hasp_gui.h"
|
||||||
#include "hasp_oobe.h"
|
#include "hasp_oobe.h"
|
||||||
|
|
||||||
#include "hasp/hasp_dispatch.h"
|
#include "hasplib.h"
|
||||||
#include "hasp/hasp.h"
|
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
#include "display/monitor.h"
|
#include "display/monitor.h"
|
||||||
@ -194,8 +193,12 @@ void guiSetup(void)
|
|||||||
|
|
||||||
/* Initialize Filesystems */
|
/* Initialize Filesystems */
|
||||||
#if LV_USE_FS_IF != 0
|
#if LV_USE_FS_IF != 0
|
||||||
_lv_fs_init(); // lvgl File System
|
// _lv_fs_init(); // lvgl File System -- not neaded, it done in lv_init() when LV_USE_FILESYSTEM is set
|
||||||
|
LOG_VERBOSE(TAG_LVGL, F("Filesystem : Enabled"));
|
||||||
lv_fs_if_init(); // auxilary file system drivers
|
lv_fs_if_init(); // auxilary file system drivers
|
||||||
|
filesystem_list_path("S:/");
|
||||||
|
#else
|
||||||
|
LOG_VERBOSE(TAG_LVGL, F("Filesystem : Disabled"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Initialize PNG decoder */
|
/* Initialize PNG decoder */
|
||||||
|
@ -6,5 +6,6 @@
|
|||||||
#include "hasp/hasp_object.h"
|
#include "hasp/hasp_object.h"
|
||||||
#include "hasp/hasp_parser.h"
|
#include "hasp/hasp_parser.h"
|
||||||
#include "hasp/hasp_utilities.h"
|
#include "hasp/hasp_utilities.h"
|
||||||
|
#include "hasp/hasp_lvfs.h"
|
||||||
|
|
||||||
#include "hasp/lv_theme_hasp.h"
|
#include "hasp/lv_theme_hasp.h"
|
@ -80,7 +80,6 @@ lib_ignore =
|
|||||||
paho
|
paho
|
||||||
AXP192
|
AXP192
|
||||||
ArduinoLog
|
ArduinoLog
|
||||||
lv_fs_if
|
|
||||||
|
|
||||||
src_filter =
|
src_filter =
|
||||||
+<*>
|
+<*>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user