mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-02 22:00:42 +08:00
Some refactoring for SD support
put SPI SD divider in EEPROM
This commit is contained in:
parent
7384b4f28e
commit
9fe3c1a615
@ -107,7 +107,7 @@
|
|||||||
//ESP_SD_NATIVE 1 //esp32 only
|
//ESP_SD_NATIVE 1 //esp32 only
|
||||||
//ESP_SDIO 2 //Not available yet
|
//ESP_SDIO 2 //Not available yet
|
||||||
//ESP_SDFAT 3 //Not available yet
|
//ESP_SDFAT 3 //Not available yet
|
||||||
//#define SD_DEVICE ESP_SD_NATIVE
|
#define SD_DEVICE ESP_SD_NATIVE
|
||||||
|
|
||||||
//pin if reader has insert detection feature
|
//pin if reader has insert detection feature
|
||||||
//let -1 or comment if none
|
//let -1 or comment if none
|
||||||
@ -175,7 +175,7 @@
|
|||||||
//ESP_AUTOSTART_SCRIPT : to do some actions / send GCODE at start, need ESP_GCODE_HOST_FEATURE enabled
|
//ESP_AUTOSTART_SCRIPT : to do some actions / send GCODE at start, need ESP_GCODE_HOST_FEATURE enabled
|
||||||
//can be a line od several GCODES separated by `\n` e.g. "M21\nM117 SD mounted\n"
|
//can be a line od several GCODES separated by `\n` e.g. "M21\nM117 SD mounted\n"
|
||||||
//can be a file name, if exists, commands inside will be processed, e.g "/FS:/autostart.esp"
|
//can be a file name, if exists, commands inside will be processed, e.g "/FS:/autostart.esp"
|
||||||
#define ESP_AUTOSTART_SCRIPT "M117 Mouning SD\nM21\n"
|
//#define ESP_AUTOSTART_SCRIPT "M117 Mouning SD\nM21\n"
|
||||||
|
|
||||||
//ESP_LUA_INTERPRETER_FEATURE : add lua scripting feature
|
//ESP_LUA_INTERPRETER_FEATURE : add lua scripting feature
|
||||||
//#define ESP_LUA_INTERPRETER_FEATURE
|
//#define ESP_LUA_INTERPRETER_FEATURE
|
||||||
|
@ -463,14 +463,21 @@ bool Commands::ESP400(const char* cmd_params, level_authenticate_type auth_type,
|
|||||||
output->printf (",{\"Telnet\":\"%d\"}", ESP_TELNET_CLIENT);
|
output->printf (",{\"Telnet\":\"%d\"}", ESP_TELNET_CLIENT);
|
||||||
#endif //TELNET_FEATURE
|
#endif //TELNET_FEATURE
|
||||||
output->printLN ("]}");
|
output->printLN ("]}");
|
||||||
#ifdef SDCARD_FEATURE
|
#ifdef SD_DEVICE
|
||||||
//Direct SD
|
//Direct SD
|
||||||
output->print(",{\"F\":\"printer\",\"P\":\"");
|
output->print(",{\"F\":\"printer\",\"P\":\"");
|
||||||
output->print(ESP_IS_DIRECT_SD);
|
output->print(ESP_SD_DEVICE_TYPE);
|
||||||
output->print("\",\"T\":\"B\",\"V\":\"");
|
output->print("\",\"T\":\"B\",\"V\":\"");
|
||||||
output->print (Settings_ESP3D::read_byte(ESP_IS_DIRECT_SD));
|
output->print (Settings_ESP3D::read_byte(ESP_SD_DEVICE_TYPE));
|
||||||
output->print("\",\"H\":\"Direct SD access\",\"O\":[{\"No\":\"0\"},{\"Yes\":\"1\"}]}");
|
//hard coded for readibility but should use ESP_NO_SD / ESP_DIRECT_SD / ESP_SHARED_SD
|
||||||
#endif //SDCARD_FEATURE
|
output->printLN("\",\"H\":\"SD Device\",\"O\":[{\"None\":\"0\"},{\"Direct\":\"1\"},{\"Shared\":\"2\"}]}");
|
||||||
|
//SPI SD Divider
|
||||||
|
output->print(",{\"F\":\"printer\",\"P\":\"");
|
||||||
|
output->print(ESP_SD_SPEED_DIV);
|
||||||
|
output->print("\",\"T\":\"B\",\"V\":\"");
|
||||||
|
output->print (Settings_ESP3D::read_byte(ESP_SD_SPEED_DIV));
|
||||||
|
output->print("\",\"H\":\"SD speed divider\",\"O\":[{\"1\":\"1\"},{\"2\":\"2\"},{\"3\":\"3\"},{\"4\":\"4\"},{\"6\":\"6\"},{\"8\":\"8\"},{\"16\":\"16\"},{\"32\":\"32\"}]}");
|
||||||
|
#endif //SD_DEVICE
|
||||||
|
|
||||||
output->printLN ("]}");
|
output->printLN ("]}");
|
||||||
|
|
||||||
|
@ -37,6 +37,9 @@
|
|||||||
#ifdef NOTIFICATION_FEATURE
|
#ifdef NOTIFICATION_FEATURE
|
||||||
#include "../../modules/notifications/notifications_service.h"
|
#include "../../modules/notifications/notifications_service.h"
|
||||||
#endif //NOTIFICATION_FEATURE
|
#endif //NOTIFICATION_FEATURE
|
||||||
|
#ifdef SD_DEVICE
|
||||||
|
#include "../../modules/filesystem/esp_sd.h"
|
||||||
|
#endif //SD_DEVICE
|
||||||
//Set EEPROM setting
|
//Set EEPROM setting
|
||||||
//[ESP401]P=<position> T=<type> V=<value> pwd=<user/admin password>
|
//[ESP401]P=<position> T=<type> V=<value> pwd=<user/admin password>
|
||||||
bool Commands::ESP401(const char* cmd_params, level_authenticate_type auth_type, ESP3DOutput * output)
|
bool Commands::ESP401(const char* cmd_params, level_authenticate_type auth_type, ESP3DOutput * output)
|
||||||
@ -73,6 +76,14 @@ bool Commands::ESP401(const char* cmd_params, level_authenticate_type auth_type,
|
|||||||
case ESP_TARGET_FW:
|
case ESP_TARGET_FW:
|
||||||
Settings_ESP3D::GetFirmwareTarget(true);
|
Settings_ESP3D::GetFirmwareTarget(true);
|
||||||
break;
|
break;
|
||||||
|
#ifdef SD_DEVICE
|
||||||
|
case ESP_SD_DEVICE_TYPE:
|
||||||
|
Settings_ESP3D::GetSDDevice(true);
|
||||||
|
break;
|
||||||
|
case ESP_SD_SPEED_DIV:
|
||||||
|
ESP_SD::setSPISpeedDivider(sval.toInt());
|
||||||
|
break;
|
||||||
|
#endif //SD_DEVICE
|
||||||
#ifdef TIMESTAMP_FEATURE
|
#ifdef TIMESTAMP_FEATURE
|
||||||
case ESP_INTERNET_TIME:
|
case ESP_INTERNET_TIME:
|
||||||
timeserver.begin();
|
timeserver.begin();
|
||||||
|
@ -62,6 +62,9 @@
|
|||||||
#ifdef CAMERA_DEVICE
|
#ifdef CAMERA_DEVICE
|
||||||
#include "../../modules/camera/camera.h"
|
#include "../../modules/camera/camera.h"
|
||||||
#endif //CAMERA_DEVICE
|
#endif //CAMERA_DEVICE
|
||||||
|
#ifdef SD_DEVICE
|
||||||
|
#include "../../modules/filesystem/esp_sd.h"
|
||||||
|
#endif //SD_DEVICE
|
||||||
|
|
||||||
//Get ESP current status
|
//Get ESP current status
|
||||||
//output is JSON or plain text according parameter
|
//output is JSON or plain text according parameter
|
||||||
@ -1055,6 +1058,26 @@ bool Commands::ESP420(const char* cmd_params, level_authenticate_type auth_type,
|
|||||||
output->printLN("");
|
output->printLN("");
|
||||||
}
|
}
|
||||||
#endif //NOTIFICATION_FEATURE
|
#endif //NOTIFICATION_FEATURE
|
||||||
|
#ifdef SD_DEVICE
|
||||||
|
if (!plain) {
|
||||||
|
output->print (",{\"id\":\"");
|
||||||
|
}
|
||||||
|
output->print ("SD Card");
|
||||||
|
if (!plain) {
|
||||||
|
output->print ("\",\"value\":\"");
|
||||||
|
} else {
|
||||||
|
output->print (": ");
|
||||||
|
}
|
||||||
|
output->print ((Settings_ESP3D::GetSDDevice() == ESP_DIRECT_SD)?"Direct":(Settings_ESP3D::GetSDDevice() == ESP_SHARED_SD)?"Shared":"None");
|
||||||
|
output->print ("(");
|
||||||
|
output->print (ESP_SD::FilesystemName());
|
||||||
|
output->print (")");
|
||||||
|
if (!plain) {
|
||||||
|
output->print ("\"}");
|
||||||
|
} else {
|
||||||
|
output->printLN("");
|
||||||
|
}
|
||||||
|
#endif //SD_DEVICE
|
||||||
#if defined (DHT_DEVICE)
|
#if defined (DHT_DEVICE)
|
||||||
if (!plain) {
|
if (!plain) {
|
||||||
output->print (",{\"id\":\"");
|
output->print (",{\"id\":\"");
|
||||||
|
@ -43,8 +43,8 @@ bool Commands::ESP740(const char* cmd_params, level_authenticate_type auth_type,
|
|||||||
parameter = "/";
|
parameter = "/";
|
||||||
}
|
}
|
||||||
int8_t state = ESP_SD::getState(false);
|
int8_t state = ESP_SD::getState(false);
|
||||||
if (state != ESP_SDCARD_IDLE){
|
if (state != ESP_SDCARD_IDLE) {
|
||||||
state = ESP_SD::getState(true);
|
state = ESP_SD::getState(true);
|
||||||
}
|
}
|
||||||
if (state == ESP_SDCARD_NOT_PRESENT) {
|
if (state == ESP_SDCARD_NOT_PRESENT) {
|
||||||
output->printERROR ("No SD card");
|
output->printERROR ("No SD card");
|
||||||
|
@ -41,8 +41,8 @@ bool Commands::ESP750(const char* cmd_params, level_authenticate_type auth_type,
|
|||||||
(void)auth_type;
|
(void)auth_type;
|
||||||
#endif //AUTHENTICATION_FEATURE
|
#endif //AUTHENTICATION_FEATURE
|
||||||
int8_t state = ESP_SD::getState(false);
|
int8_t state = ESP_SD::getState(false);
|
||||||
if (state != ESP_SDCARD_IDLE){
|
if (state != ESP_SDCARD_IDLE) {
|
||||||
state = ESP_SD::getState(true);
|
state = ESP_SD::getState(true);
|
||||||
}
|
}
|
||||||
if (state == ESP_SDCARD_NOT_PRESENT) {
|
if (state == ESP_SDCARD_NOT_PRESENT) {
|
||||||
output->printERROR ("No SD card");
|
output->printERROR ("No SD card");
|
||||||
|
@ -102,19 +102,18 @@ bool Commands::ESP800(const char* cmd_params, level_authenticate_type auth_type,
|
|||||||
} else {
|
} else {
|
||||||
output->print(",\"SDConnection\":\"");
|
output->print(",\"SDConnection\":\"");
|
||||||
}
|
}
|
||||||
output->print((Settings_ESP3D::isDirectSD())?"Direct":"Serial");
|
if (Settings_ESP3D::GetSDDevice() == ESP_DIRECT_SD) {
|
||||||
|
output->print("direct");
|
||||||
|
} else if (Settings_ESP3D::GetSDDevice() == ESP_SHARED_SD) {
|
||||||
|
output->print("shared");
|
||||||
|
} else {
|
||||||
|
output->print("None");
|
||||||
|
}
|
||||||
if(plain) {
|
if(plain) {
|
||||||
output->printLN("");
|
output->printLN("");
|
||||||
} else {
|
} else {
|
||||||
output->print("\"");
|
output->print("\"");
|
||||||
}
|
}
|
||||||
if (Settings_ESP3D::isDirectSD()) {
|
|
||||||
//TODO
|
|
||||||
//Primary SD
|
|
||||||
|
|
||||||
//TODO
|
|
||||||
//Secondary SD
|
|
||||||
}
|
|
||||||
//Authentication
|
//Authentication
|
||||||
if (plain) {
|
if (plain) {
|
||||||
output->print("Authentication:");
|
output->print("Authentication:");
|
||||||
|
@ -97,12 +97,11 @@
|
|||||||
#define DEFAULT_FW UNKNOWN_FW
|
#define DEFAULT_FW UNKNOWN_FW
|
||||||
#define DEFAULT_TIME_ZONE 0
|
#define DEFAULT_TIME_ZONE 0
|
||||||
#define DEFAULT_TIME_DST 0
|
#define DEFAULT_TIME_DST 0
|
||||||
#define DEFAULT_PRIMARY_SD 2
|
#define DEFAULT_SD_MOUNT ESP_SD_ROOT
|
||||||
#define DEFAULT_SECONDARY_SD 1
|
|
||||||
#define DEFAULT_DIRECT_SD_CHECK 0
|
#define DEFAULT_DIRECT_SD_CHECK 0
|
||||||
#define DEFAULT_SD_CHECK_UPDATE_AT_BOOT 1
|
#define DEFAULT_SD_CHECK_UPDATE_AT_BOOT 1
|
||||||
#define DEFAULT_DHT_TYPE 0
|
#define DEFAULT_DHT_TYPE NO_DHT_DEVICE
|
||||||
#define DEFAULT_IS_DIRECT_SD 0
|
#define DEFAULT_SD_DEVICE_TYPE ESP_NO_SD
|
||||||
#define DEFAULT_HTTP_ON 1
|
#define DEFAULT_HTTP_ON 1
|
||||||
#define DEFAULT_TELNET_ON 1
|
#define DEFAULT_TELNET_ON 1
|
||||||
#define DEFAULT_WEBSOCKET_ON 1
|
#define DEFAULT_WEBSOCKET_ON 1
|
||||||
@ -156,7 +155,7 @@ const uint8_t DEFAULT_ADDRESS_VALUE[] = {0, 0, 0, 0};
|
|||||||
#endif //WIFI_FEATURE || ETH_FEATURE
|
#endif //WIFI_FEATURE || ETH_FEATURE
|
||||||
|
|
||||||
uint8_t Settings_ESP3D::_FirmwareTarget = UNKNOWN_FW;
|
uint8_t Settings_ESP3D::_FirmwareTarget = UNKNOWN_FW;
|
||||||
bool Settings_ESP3D::_directSD = false;
|
bool Settings_ESP3D::_SDdevice = ESP_NO_SD;
|
||||||
|
|
||||||
Settings_ESP3D::Settings_ESP3D()
|
Settings_ESP3D::Settings_ESP3D()
|
||||||
{
|
{
|
||||||
@ -172,8 +171,8 @@ bool Settings_ESP3D::begin()
|
|||||||
}
|
}
|
||||||
//get target FW
|
//get target FW
|
||||||
Settings_ESP3D::GetFirmwareTarget(true);
|
Settings_ESP3D::GetFirmwareTarget(true);
|
||||||
//is direct SD
|
//get SD device if any
|
||||||
Settings_ESP3D::isDirectSD(true);
|
Settings_ESP3D::GetSDDevice(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,16 +184,16 @@ uint8_t Settings_ESP3D::GetFirmwareTarget(bool fromsettings)
|
|||||||
return _FirmwareTarget;
|
return _FirmwareTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings_ESP3D::isDirectSD(bool fromsettings)
|
uint8_t Settings_ESP3D::GetSDDevice(bool fromsettings)
|
||||||
{
|
{
|
||||||
if(fromsettings) {
|
if(fromsettings) {
|
||||||
#ifdef SDCARD_FEATURE
|
#ifdef SD_DEVICE
|
||||||
_directSD = read_byte (ESP_IS_DIRECT_SD);
|
_SDdevice = read_byte (ESP_SD_DEVICE_TYPE);
|
||||||
#else // !SDCARD_FEATURE
|
#else // !SD_DEVICE
|
||||||
_directSD = false;
|
_SDdevice = ESP_NO_SD;
|
||||||
#endif //SDCARD_FEATURE
|
#endif //SD_DEVICE
|
||||||
}
|
}
|
||||||
return _directSD;
|
return _SDdevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Settings_ESP3D::GetFirmwareTargetShortName()
|
const char* Settings_ESP3D::GetFirmwareTargetShortName()
|
||||||
@ -285,15 +284,12 @@ uint8_t Settings_ESP3D::get_default_byte_value(int pos)
|
|||||||
res = DEFAULT_WEBSOCKET_ON;
|
res = DEFAULT_WEBSOCKET_ON;
|
||||||
break;
|
break;
|
||||||
#endif //WS_DATA_FEATURE
|
#endif //WS_DATA_FEATURE
|
||||||
#ifdef SDCARD_FEATURE
|
#ifdef SD_DEVICE
|
||||||
case ESP_SD_SPEED_DIV:
|
case ESP_SD_SPEED_DIV:
|
||||||
res = DEFAULT_SDREADER_SPEED;
|
res = DEFAULT_SDREADER_SPEED;
|
||||||
break;
|
break;
|
||||||
case ESP_PRIMARY_SD:
|
case ESP_SD_MOUNT:
|
||||||
res = DEFAULT_PRIMARY_SD;
|
res = DEFAULT_SD_MOUNT;
|
||||||
break;
|
|
||||||
case ESP_SECONDARY_SD:
|
|
||||||
res = DEFAULT_SECONDARY_SD;
|
|
||||||
break;
|
break;
|
||||||
case ESP_DIRECT_SD_CHECK:
|
case ESP_DIRECT_SD_CHECK:
|
||||||
res = DEFAULT_DIRECT_SD_CHECK;
|
res = DEFAULT_DIRECT_SD_CHECK;
|
||||||
@ -301,10 +297,10 @@ uint8_t Settings_ESP3D::get_default_byte_value(int pos)
|
|||||||
case ESP_SD_CHECK_UPDATE_AT_BOOT:
|
case ESP_SD_CHECK_UPDATE_AT_BOOT:
|
||||||
res = DEFAULT_SD_CHECK_UPDATE_AT_BOOT;
|
res = DEFAULT_SD_CHECK_UPDATE_AT_BOOT;
|
||||||
break;
|
break;
|
||||||
case ESP_IS_DIRECT_SD:
|
case ESP_SD_DEVICE_TYPE:
|
||||||
res = DEFAULT_IS_DIRECT_SD;
|
res = DEFAULT_SD_DEVICE_TYPE;
|
||||||
break;
|
break;
|
||||||
#endif //SDCARD_FEATURE
|
#endif //SD_DEVICE
|
||||||
case ESP_TARGET_FW:
|
case ESP_TARGET_FW:
|
||||||
res = DEFAULT_FW;
|
res = DEFAULT_FW;
|
||||||
break;
|
break;
|
||||||
@ -1100,10 +1096,12 @@ bool Settings_ESP3D::reset()
|
|||||||
Settings_ESP3D::write_byte(ESP_TARGET_FW,Settings_ESP3D::get_default_byte_value(ESP_TARGET_FW));
|
Settings_ESP3D::write_byte(ESP_TARGET_FW,Settings_ESP3D::get_default_byte_value(ESP_TARGET_FW));
|
||||||
//Output flag
|
//Output flag
|
||||||
Settings_ESP3D::write_byte(ESP_OUTPUT_FLAG,Settings_ESP3D::get_default_byte_value(ESP_OUTPUT_FLAG));
|
Settings_ESP3D::write_byte(ESP_OUTPUT_FLAG,Settings_ESP3D::get_default_byte_value(ESP_OUTPUT_FLAG));
|
||||||
#ifdef SDCARD_FEATURE
|
#ifdef SD_DEVICE
|
||||||
//Direct SD
|
//Direct SD
|
||||||
Settings_ESP3D::write_byte(ESP_IS_DIRECT_SD,Settings_ESP3D::get_default_byte_value(ESP_IS_DIRECT_SD));
|
Settings_ESP3D::write_byte(ESP_SD_DEVICE_TYPE,Settings_ESP3D::get_default_byte_value(ESP_SD_DEVICE_TYPE));
|
||||||
#endif //SDCARD_FEATURE
|
//SPI SD Divider
|
||||||
|
Settings_ESP3D::write_byte(ESP_SD_SPEED_DIV,Settings_ESP3D::get_default_byte_value(ESP_SD_SPEED_DIV));
|
||||||
|
#endif //SD_DEVICE
|
||||||
|
|
||||||
#ifdef TIMESTAMP_FEATURE
|
#ifdef TIMESTAMP_FEATURE
|
||||||
//Internet time
|
//Internet time
|
||||||
|
@ -75,9 +75,9 @@
|
|||||||
#define ESP_TIME_SERVER1 464 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese
|
#define ESP_TIME_SERVER1 464 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese
|
||||||
#define ESP_TIME_SERVER2 593 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese
|
#define ESP_TIME_SERVER2 593 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese
|
||||||
#define ESP_TIME_SERVER3 722 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese
|
#define ESP_TIME_SERVER3 722 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese
|
||||||
#define ESP_IS_DIRECT_SD 850 //1 bytes = flag
|
#define ESP_SD_DEVICE_TYPE 850 //1 bytes = flag
|
||||||
#define ESP_PRIMARY_SD 851 //1 bytes = flag
|
#define ESP_SD_MOUNT 851 //1 bytes = flag
|
||||||
#define ESP_SECONDARY_SD 852 //1 bytes = flag
|
#define ESP_FREE_BYTE 852 //1 bytes = flag
|
||||||
#define ESP_DIRECT_SD_CHECK 853 //1 bytes = flag
|
#define ESP_DIRECT_SD_CHECK 853 //1 bytes = flag
|
||||||
#define ESP_SD_CHECK_UPDATE_AT_BOOT 854//1 bytes = flag
|
#define ESP_SD_CHECK_UPDATE_AT_BOOT 854//1 bytes = flag
|
||||||
#define ESP_NOTIFICATION_SETTINGS 855 //128 bytes 127+1 = string ; warning does not support multibyte char like chinese
|
#define ESP_NOTIFICATION_SETTINGS 855 //128 bytes 127+1 = string ; warning does not support multibyte char like chinese
|
||||||
@ -124,7 +124,7 @@ public:
|
|||||||
static bool reset();
|
static bool reset();
|
||||||
static int8_t GetSettingsVersion();
|
static int8_t GetSettingsVersion();
|
||||||
static uint8_t GetFirmwareTarget(bool fromsettings = false);
|
static uint8_t GetFirmwareTarget(bool fromsettings = false);
|
||||||
static bool isDirectSD(bool fromsettings = false);
|
static uint8_t GetSDDevice(bool fromsettings = false);
|
||||||
static const char* GetFirmwareTargetShortName();
|
static const char* GetFirmwareTargetShortName();
|
||||||
static String IPtoString(uint32_t ip_int);
|
static String IPtoString(uint32_t ip_int);
|
||||||
static uint32_t StringtoIP(const char *s);
|
static uint32_t StringtoIP(const char *s);
|
||||||
@ -133,7 +133,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
static bool is_string(const char * s, uint len);
|
static bool is_string(const char * s, uint len);
|
||||||
static uint8_t _FirmwareTarget;
|
static uint8_t _FirmwareTarget;
|
||||||
static bool _directSD;
|
static bool _SDdevice;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,6 +50,15 @@
|
|||||||
#define UI_COLORED 1
|
#define UI_COLORED 1
|
||||||
#define UI_MONOCHROME 2
|
#define UI_MONOCHROME 2
|
||||||
|
|
||||||
|
//SD connection
|
||||||
|
#define ESP_NO_SD 0
|
||||||
|
#define ESP_DIRECT_SD 1
|
||||||
|
#define ESP_SHARED_SD 2
|
||||||
|
|
||||||
|
//SD mount point
|
||||||
|
#define ESP_SD_ROOT 1
|
||||||
|
#define ESP_SD_SUB_SD 2
|
||||||
|
#define ESP_SD_SUB_EXT 3
|
||||||
|
|
||||||
//Touch
|
//Touch
|
||||||
#define XPT2046_SPI 1
|
#define XPT2046_SPI 1
|
||||||
@ -78,6 +87,7 @@
|
|||||||
#define ESP_LINE_NOTIFICATION 3
|
#define ESP_LINE_NOTIFICATION 3
|
||||||
|
|
||||||
//DHT
|
//DHT
|
||||||
|
#define NO_DHT_DEVICE 0
|
||||||
#define DHT11_DEVICE 1
|
#define DHT11_DEVICE 1
|
||||||
#define DHT22_DEVICE 2
|
#define DHT22_DEVICE 2
|
||||||
#define USE_CELSIUS 1
|
#define USE_CELSIUS 1
|
||||||
|
@ -32,6 +32,7 @@ File tSDFile_handle[ESP_MAX_SD_OPENHANDLE];
|
|||||||
|
|
||||||
bool ESP_SD::_started = false;
|
bool ESP_SD::_started = false;
|
||||||
uint8_t ESP_SD::_state = ESP_SDCARD_NOT_PRESENT;
|
uint8_t ESP_SD::_state = ESP_SDCARD_NOT_PRESENT;
|
||||||
|
uint8_t ESP_SD::_spi_speed_divider = 1;
|
||||||
|
|
||||||
uint8_t ESP_SD::setState(uint8_t flag)
|
uint8_t ESP_SD::setState(uint8_t flag)
|
||||||
{
|
{
|
||||||
@ -198,4 +199,13 @@ ESP_SDFile& ESP_SDFile::operator=(const ESP_SDFile & other)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ESP_SD::setSPISpeedDivider(uint8_t speeddivider)
|
||||||
|
{
|
||||||
|
if (speeddivider > 0) {
|
||||||
|
_spi_speed_divider = speeddivider;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#endif //SD_DEVICE
|
#endif //SD_DEVICE
|
||||||
|
@ -92,9 +92,15 @@ public:
|
|||||||
static bool mkdir(const char *path);
|
static bool mkdir(const char *path);
|
||||||
static bool rmdir(const char *path);
|
static bool rmdir(const char *path);
|
||||||
static void closeAll();
|
static void closeAll();
|
||||||
|
static uint8_t getSPISpeedDivider()
|
||||||
|
{
|
||||||
|
return _spi_speed_divider;
|
||||||
|
}
|
||||||
|
static bool setSPISpeedDivider(uint8_t speeddivider);
|
||||||
private:
|
private:
|
||||||
static bool _started;
|
static bool _started;
|
||||||
static uint8_t _state;
|
static uint8_t _state;
|
||||||
|
static uint8_t _spi_speed_divider;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,14 +22,12 @@ sd_native_esp32.cpp - ESP3D sd support class
|
|||||||
#if (SD_DEVICE == ESP_SD_NATIVE)
|
#if (SD_DEVICE == ESP_SD_NATIVE)
|
||||||
#include "../esp_sd.h"
|
#include "../esp_sd.h"
|
||||||
#include "../../../core/genLinkedList.h"
|
#include "../../../core/genLinkedList.h"
|
||||||
|
#include "../../../core/settings_esp3d.h"
|
||||||
#include "FS.h"
|
#include "FS.h"
|
||||||
#include "SD.h"
|
#include "SD.h"
|
||||||
|
|
||||||
#define ESP_SPI_FREQ 4000000
|
#define ESP_SPI_FREQ 4000000
|
||||||
|
|
||||||
//TODO read this from EEPROM/Preferences
|
|
||||||
#define ESP_SD_SPEED_DIVIDER 1
|
|
||||||
|
|
||||||
extern File tSDFile_handle[ESP_MAX_SD_OPENHANDLE];
|
extern File tSDFile_handle[ESP_MAX_SD_OPENHANDLE];
|
||||||
|
|
||||||
uint8_t ESP_SD::getState(bool refresh)
|
uint8_t ESP_SD::getState(bool refresh)
|
||||||
@ -54,7 +52,7 @@ uint8_t ESP_SD::getState(bool refresh)
|
|||||||
_state = ESP_SDCARD_NOT_PRESENT;
|
_state = ESP_SDCARD_NOT_PRESENT;
|
||||||
//using default value for speed ? should be parameter
|
//using default value for speed ? should be parameter
|
||||||
//refresh content if card was removed
|
//refresh content if card was removed
|
||||||
if (SD.begin((ESP_SD_CS_PIN == -1)?SS:ESP_SD_CS_PIN, SPI, ESP_SPI_FREQ / ESP_SD_SPEED_DIVIDER)) {
|
if (SD.begin((ESP_SD_CS_PIN == -1)?SS:ESP_SD_CS_PIN, SPI, ESP_SPI_FREQ / _spi_speed_divider)) {
|
||||||
if ( SD.cardSize() > 0 ) {
|
if ( SD.cardSize() > 0 ) {
|
||||||
_state = ESP_SDCARD_IDLE;
|
_state = ESP_SDCARD_IDLE;
|
||||||
}
|
}
|
||||||
@ -69,6 +67,11 @@ bool ESP_SD::begin()
|
|||||||
#endif
|
#endif
|
||||||
_started = true;
|
_started = true;
|
||||||
_state = ESP_SDCARD_NOT_PRESENT;
|
_state = ESP_SDCARD_NOT_PRESENT;
|
||||||
|
_spi_speed_divider = Settings_ESP3D::read_byte(ESP_SD_SPEED_DIV);
|
||||||
|
//sanity check
|
||||||
|
if (_spi_speed_divider <= 0) {
|
||||||
|
_spi_speed_divider = 1;
|
||||||
|
}
|
||||||
return _started;
|
return _started;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,11 +97,6 @@ uint64_t ESP_SD::freeBytes()
|
|||||||
return (SD.totalBytes() - SD.usedBytes());
|
return (SD.totalBytes() - SD.usedBytes());
|
||||||
};
|
};
|
||||||
|
|
||||||
const char * ESP_SD::FilesystemName()
|
|
||||||
{
|
|
||||||
return "SD Native";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ESP_SD::format()
|
bool ESP_SD::format()
|
||||||
{
|
{
|
||||||
//not available yet
|
//not available yet
|
||||||
@ -336,6 +334,10 @@ ESP_SDFile ESP_SDFile::openNextFile()
|
|||||||
return ESP_SDFile();
|
return ESP_SDFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char * ESP_SD::FilesystemName()
|
||||||
|
{
|
||||||
|
return "SD native";
|
||||||
|
}
|
||||||
|
|
||||||
#endif //SD_DEVICE == ESP_SD_NATIVE
|
#endif //SD_DEVICE == ESP_SD_NATIVE
|
||||||
#endif //ARCH_ESP32 && SD_DEVICE
|
#endif //ARCH_ESP32 && SD_DEVICE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user