diff --git a/esp3d/src/include/defines.h b/esp3d/src/include/defines.h index 9988e32f..12a0cc66 100644 --- a/esp3d/src/include/defines.h +++ b/esp3d/src/include/defines.h @@ -21,22 +21,22 @@ #ifndef _DEFINES_ESP3D_H #define _DEFINES_ESP3D_H -//Settings +// Settings #define SETTINGS_IN_EEPROM 1 #define SETTINGS_IN_PREFERENCES 2 -//Supported FW ///////////////////////////////////////////////////////////// -#define UNKNOWN_FW 0 -#define GRBL 10 -#define MARLIN 20 +// Supported FW ///////////////////////////////////////////////////////////// +#define UNKNOWN_FW 0 +#define GRBL 10 +#define MARLIN 20 #define MARLIN_EMBEDDED 30 -#define SMOOTHIEWARE 40 -#define REPETIER 50 -#define REPRAP 70 -#define GRBLHAL 80 -#define HP_GL 90 +#define SMOOTHIEWARE 40 +#define REPETIER 50 +#define REPRAP 70 +#define GRBLHAL 80 +#define HP_GL 90 -//Default flags +// Default flags #define DEFAULT_SERIAL_OUTPUT_FLAG 1 #define DEFAULT_REMOTE_SCREEN_FLAG 1 #define DEFAULT_WEBSOCKET_FLAG 1 @@ -45,253 +45,282 @@ #define DEFAULT_SCREEN_FLAG 1 #define DEFAULT_SERIAL_BRIDGE_FLAG 1 -//position in EEPROM / preferences will use `P_` + to make a string : P_0 for 0 -#define ESP_RADIO_MODE 0 //1 byte = flag -#define ESP_STA_SSID 1 //33 bytes 32+1 = string ; warning does not support multibyte char like chinese -#define ESP_STA_PASSWORD 34 //65 bytes 64 +1 = string ;warning does not support multibyte char like chinese -#define ESP_STA_IP_MODE 99 //1 byte = flag -#define ESP_STA_IP_VALUE 100 //4 bytes xxx.xxx.xxx.xxx -#define ESP_STA_MASK_VALUE 104 //4 bytes xxx.xxx.xxx.xxx -#define ESP_STA_GATEWAY_VALUE 108 //4 bytes xxx.xxx.xxx.xxx -#define ESP_BAUD_RATE 112 //4 bytes = int -#define ESP_NOTIFICATION_TYPE 116 //1 byte = flag -#define ESP_CALIBRATION 117 //1 byte = flag -#define ESP_AP_CHANNEL 118 //1 byte = flag -#define ESP_BUZZER 119 //1 byte = flag -#define ESP_INTERNET_TIME 120 //1 byte = flag -#define ESP_HTTP_PORT 121 //4 bytes = int -#define ESP_TELNET_PORT 125 //4 bytes = int -#define ESP_SERIAL_FLAG 129 //1 bytes = flag -#define ESP_HOSTNAME 130 //33 bytes 32+1 = string ; warning does not support multibyte char like chinese -#define ESP_SENSOR_INTERVAL 164 //4 bytes = int -#define ESP_SETTINGS_VERSION 168 //8 bytes = 7+1 = string ESP3D + 2 digits -#define ESP_ADMIN_PWD 176 //21 bytes 20+1 = string ; warning does not support multibyte char like chinese -#define ESP_USER_PWD 197 //21 bytes 20+1 = string ; warning does not support multibyte char like chinese -#define ESP_AP_SSID 218 //33 bytes 32+1 = string ; warning does not support multibyte char like chinese -#define ESP_AP_PASSWORD 251 //65 bytes 64 +1 = string ;warning does not support multibyte char like chinese -#define ESP_AP_IP_VALUE 316 //4 bytes xxx.xxx.xxx.xxx -#define ESP_BOOT_DELAY 320 //4 bytes = int -#define ESP_WEBSOCKET_PORT 324 //4 bytes= int -#define ESP_HTTP_ON 328 //1 byte = flag -#define ESP_TELNET_ON 329 //1 byte = flag -#define ESP_WEBSOCKET_ON 330 //1 byte = flag -#define ESP_SD_SPEED_DIV 331 //1 byte = flag -#define ESP_NOTIFICATION_TOKEN1 332 //64 bytes 63+1 = string ; warning does not support multibyte char like chinese -#define ESP_NOTIFICATION_TOKEN2 396 //64 bytes 63+1 = string ; warning does not support multibyte char like chinese -#define ESP_SENSOR_TYPE 460 //1 bytes = flag -#define ESP_TARGET_FW 461 //1 bytes = flag -#define ESP_TIMEZONE 462 //1 bytes = flag -#define ESP_TIME_IS_DST 463 //1 bytes = flag -#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_SERVER3 722 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese -#define ESP_REMOTE_SCREEN_FLAG 851 //1 bytes = flag -#define ESP_SD_MOUNT 852 //1 bytes = flag -#define ESP_SESSION_TIMEOUT 853 //1 bytes = flag -#define ESP_WEBSOCKET_FLAG 854 //1 bytes = flag -#define ESP_SD_CHECK_UPDATE_AT_BOOT 855//1 bytes = flag -#define ESP_NOTIFICATION_SETTINGS 856 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese -#define ESP_CALIBRATION_1 985 //4 bytes = int -#define ESP_CALIBRATION_2 989 //4 bytes = int -#define ESP_CALIBRATION_3 993 //4 bytes = int -#define ESP_CALIBRATION_4 997 //4 bytes = int -#define ESP_CALIBRATION_5 1001 //4 bytes = int -#define ESP_SETUP 1005 //1 byte = flag -#define ESP_TELNET_FLAG 1006 //1 byte = flag -#define ESP_BT_FLAG 1007 //1 byte = flag -#define ESP_SCREEN_FLAG 1008 //1 byte = flag -#define ESP_FTP_CTRL_PORT 1009 //4 bytes = int -#define ESP_FTP_DATA_ACTIVE_PORT 1013 //4 bytes = int -#define ESP_FTP_DATA_PASSIVE_PORT 1017 //4 bytes = int -#define ESP_FTP_ON 1021 //1 byte = flag -#define ESP_AUTO_NOTIFICATION 1022 //1 byte = flag -#define ESP_VERBOSE_BOOT 1023 //1 byte = flag -#define ESP_WEBDAV_ON 1024 //1 byte = flag -#define ESP_WEBDAV_PORT 1025 //4 bytes= int -#define ESP_STA_DNS_VALUE 1029 //4 bytes= int -#define ESP_SECURE_SERIAL 1033 //1 byte = flag -#define ESP_BOOT_RADIO_STATE 1034 //1 byte = flag -#define ESP_STA_FALLBACK_MODE 1035 //1 byte = flag -#define ESP_SERIAL_BRIDGE_ON 1036 //1 byte = flag -#define ESP_SERIAL_BRIDGE_FLAG 1037 //1 byte = flag -#define ESP_SERIAL_BRIDGE_BAUD 1038 //4 bytes= int +// position in EEPROM / preferences will use `P_` + to make a string +// : P_0 for 0 +#define ESP_RADIO_MODE 0 // 1 byte = flag +#define ESP_STA_SSID \ + 1 // 33 bytes 32+1 = string ; warning does not support multibyte char like + // chinese +#define ESP_STA_PASSWORD \ + 34 // 65 bytes 64 +1 = string ;warning does not support multibyte char like + // chinese +#define ESP_STA_IP_MODE 99 // 1 byte = flag +#define ESP_STA_IP_VALUE 100 // 4 bytes xxx.xxx.xxx.xxx +#define ESP_STA_MASK_VALUE 104 // 4 bytes xxx.xxx.xxx.xxx +#define ESP_STA_GATEWAY_VALUE 108 // 4 bytes xxx.xxx.xxx.xxx +#define ESP_BAUD_RATE 112 // 4 bytes = int +#define ESP_NOTIFICATION_TYPE 116 // 1 byte = flag +#define ESP_CALIBRATION 117 // 1 byte = flag +#define ESP_AP_CHANNEL 118 // 1 byte = flag +#define ESP_BUZZER 119 // 1 byte = flag +#define ESP_INTERNET_TIME 120 // 1 byte = flag +#define ESP_HTTP_PORT 121 // 4 bytes = int +#define ESP_TELNET_PORT 125 // 4 bytes = int +#define ESP_SERIAL_FLAG 129 // 1 bytes = flag +#define ESP_HOSTNAME \ + 130 // 33 bytes 32+1 = string ; warning does not support multibyte char like + // chinese +#define ESP_SENSOR_INTERVAL 164 // 4 bytes = int +#define ESP_SETTINGS_VERSION 168 // 8 bytes = 7+1 = string ESP3D + 2 digits +#define ESP_ADMIN_PWD \ + 176 // 21 bytes 20+1 = string ; warning does not support multibyte char + // like chinese +#define ESP_USER_PWD \ + 197 // 21 bytes 20+1 = string ; warning does not support multibyte char + // like chinese +#define ESP_AP_SSID \ + 218 // 33 bytes 32+1 = string ; warning does not support multibyte char like + // chinese +#define ESP_AP_PASSWORD \ + 251 // 65 bytes 64 +1 = string ;warning does not support multibyte char like + // chinese +#define ESP_AP_IP_VALUE 316 // 4 bytes xxx.xxx.xxx.xxx +#define ESP_BOOT_DELAY 320 // 4 bytes = int +#define ESP_WEBSOCKET_PORT 324 // 4 bytes= int +#define ESP_HTTP_ON 328 // 1 byte = flag +#define ESP_TELNET_ON 329 // 1 byte = flag +#define ESP_WEBSOCKET_ON 330 // 1 byte = flag +#define ESP_SD_SPEED_DIV 331 // 1 byte = flag +#define ESP_NOTIFICATION_TOKEN1 \ + 332 // 64 bytes 63+1 = string ; warning does not support multibyte char like + // chinese +#define ESP_NOTIFICATION_TOKEN2 \ + 396 // 64 bytes 63+1 = string ; warning does not support multibyte char like + // chinese +#define ESP_SENSOR_TYPE 460 // 1 bytes = flag +#define ESP_TARGET_FW 461 // 1 bytes = flag +#define ESP_TIMEZONE 462 // 1 bytes = flag +#define ESP_TIME_IS_DST 463 // 1 bytes = flag +#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_SERVER3 \ + 722 // 129 bytes 128+1 = string ; warning does not support multibyte char + // like chinese +#define ESP_REMOTE_SCREEN_FLAG 851 // 1 bytes = flag +#define ESP_SD_MOUNT 852 // 1 bytes = flag +#define ESP_SESSION_TIMEOUT 853 // 1 bytes = flag +#define ESP_WEBSOCKET_FLAG 854 // 1 bytes = flag +#define ESP_SD_CHECK_UPDATE_AT_BOOT 855 // 1 bytes = flag +#define ESP_NOTIFICATION_SETTINGS \ + 856 // 129 bytes 128+1 = string ; warning does not support multibyte char + // like chinese +#define ESP_CALIBRATION_1 985 // 4 bytes = int +#define ESP_CALIBRATION_2 989 // 4 bytes = int +#define ESP_CALIBRATION_3 993 // 4 bytes = int +#define ESP_CALIBRATION_4 997 // 4 bytes = int +#define ESP_CALIBRATION_5 1001 // 4 bytes = int +#define ESP_SETUP 1005 // 1 byte = flag +#define ESP_TELNET_FLAG 1006 // 1 byte = flag +#define ESP_BT_FLAG 1007 // 1 byte = flag +#define ESP_SCREEN_FLAG 1008 // 1 byte = flag +#define ESP_FTP_CTRL_PORT 1009 // 4 bytes = int +#define ESP_FTP_DATA_ACTIVE_PORT 1013 // 4 bytes = int +#define ESP_FTP_DATA_PASSIVE_PORT 1017 // 4 bytes = int +#define ESP_FTP_ON 1021 // 1 byte = flag +#define ESP_AUTO_NOTIFICATION 1022 // 1 byte = flag +#define ESP_VERBOSE_BOOT 1023 // 1 byte = flag +#define ESP_WEBDAV_ON 1024 // 1 byte = flag +#define ESP_WEBDAV_PORT 1025 // 4 bytes= int +#define ESP_STA_DNS_VALUE 1029 // 4 bytes= int +#define ESP_SECURE_SERIAL 1033 // 1 byte = flag +#define ESP_BOOT_RADIO_STATE 1034 // 1 byte = flag +#define ESP_STA_FALLBACK_MODE 1035 // 1 byte = flag +#define ESP_SERIAL_BRIDGE_ON 1036 // 1 byte = flag +#define ESP_SERIAL_BRIDGE_FLAG 1037 // 1 byte = flag +#define ESP_SERIAL_BRIDGE_BAUD 1038 // 4 bytes= int -//Hidden password +// Hidden password #define HIDDEN_PASSWORD "********" -//Debug -#define DEBUG_OUTPUT_SERIAL0 1 -#define DEBUG_OUTPUT_SERIAL1 2 -#define DEBUG_OUTPUT_SERIAL2 3 -#define DEBUG_OUTPUT_TELNET 4 -#define DEBUG_OUTPUT_WEBSOCKET 5 +// Debug +#define DEBUG_OUTPUT_SERIAL0 1 +#define DEBUG_OUTPUT_SERIAL1 2 +#define DEBUG_OUTPUT_SERIAL2 3 +#define DEBUG_OUTPUT_TELNET 4 +#define DEBUG_OUTPUT_WEBSOCKET 5 - -//Serial +// Serial #define USE_SERIAL_0 1 #define USE_SERIAL_1 2 #define USE_SERIAL_2 3 -//Serial service ID -#define MAIN_SERIAL 1 +// Serial service ID +#define MAIN_SERIAL 1 #define BRIDGE_SERIAL 2 - -//Communication protocols -#define RAW_SERIAL 0 -#define MKS_SERIAL 1 +// Communication protocols +#define RAW_SERIAL 0 +#define MKS_SERIAL 1 #define SOCKET_SERIAL 2 -//Display -#define OLED_I2C_SSD1306_128X64 1 -#define OLED_I2C_SSDSH1106_132X64 2 -#define TFT_SPI_ILI9341_320X240 3 -#define TFT_SPI_ILI9488_480X320 4 -#define TFT_SPI_ST7789_240X240 5 -#define TFT_SPI_ST7789_135X240 6 +// Display +#define OLED_I2C_SSD1306_128X64 1 +#define OLED_I2C_SSDSH1106_132X64 2 +#define TFT_SPI_ILI9341_320X240 3 +#define TFT_SPI_ILI9488_480X320 4 +#define TFT_SPI_ST7789_240X240 5 +#define TFT_SPI_ST7789_135X240 6 -//UI type for display -#define UI_TYPE_BASIC 1 -#define UI_TYPE_ADVANCED 2 -#define UI_COLORED 1 -#define UI_MONOCHROME 2 +// UI type for display +#define UI_TYPE_BASIC 1 +#define UI_TYPE_ADVANCED 2 +#define UI_COLORED 1 +#define UI_MONOCHROME 2 -//SD connection -#define ESP_NO_SD 0 -#define ESP_DIRECT_SD 1 -#define ESP_SHARED_SD 2 +// SD connection +#define ESP_NO_SD 0 +#define ESP_DIRECT_SD 1 +#define ESP_SHARED_SD 2 -//Upload type -#define ESP_UPLOAD_DIRECT_SD 1 -#define ESP_UPLOAD_SHARED_SD 2 -#define ESP_UPLOAD_SERIAL_SD 3 -#define ESP_UPLOAD_FAST_SERIAL_SD 4 +// SD Device type +#define ESP_NORMAL_SDCARD 0 +#define ESP_FYSETC_WIFI_PRO_SDCARD 1 + +// Upload type +#define ESP_UPLOAD_DIRECT_SD 1 +#define ESP_UPLOAD_SHARED_SD 2 +#define ESP_UPLOAD_SERIAL_SD 3 +#define ESP_UPLOAD_FAST_SERIAL_SD 4 #define ESP_UPLOAD_FAST_SERIAL_USB 5 -#define ESP_UPLOAD_DIRECT_USB 6 +#define ESP_UPLOAD_DIRECT_USB 6 -//IP mode -#define DHCP_MODE 1 -#define STATIC_IP_MODE 0 +// IP mode +#define DHCP_MODE 1 +#define STATIC_IP_MODE 0 -//Network Mode +// Network Mode #define ESP_NO_NETWORK 0 -#define ESP_WIFI_STA 1 -#define ESP_WIFI_AP 2 -#define ESP_BT 3 -#define ESP_ETH_STA 4 -#define ESP_AP_SETUP 5 -//#define ESP_ETH_SRV 5 +#define ESP_WIFI_STA 1 +#define ESP_WIFI_AP 2 +#define ESP_BT 3 +#define ESP_ETH_STA 4 +#define ESP_AP_SETUP 5 +// #define ESP_ETH_SRV 5 -//SD mount point -#define ESP_SD_ROOT 1 -#define ESP_SD_SUB_SD 2 -#define ESP_SD_SUB_EXT 3 +// SD mount point +#define ESP_SD_ROOT 1 +#define ESP_SD_SUB_SD 2 +#define ESP_SD_SUB_EXT 3 -//Touch -#define XPT2046_SPI 1 +// Touch +#define XPT2046_SPI 1 -//Input -#define ROTARY_ENCODER 1 +// Input +#define ROTARY_ENCODER 1 -//File systems -#define ESP_SPIFFS_FILESYSTEM 1 -#define ESP_FAT_FILESYSTEM 2 -#define ESP_LITTLEFS_FILESYSTEM 3 +// File systems +#define ESP_SPIFFS_FILESYSTEM 1 +#define ESP_FAT_FILESYSTEM 2 +#define ESP_LITTLEFS_FILESYSTEM 3 -//SD READER FS type supported -#define ESP_SD_NATIVE 1 -#define ESP_SDIO 2 -#define ESP_SDFAT2 3 +// SD READER FS type supported +#define ESP_SD_NATIVE 1 +#define ESP_SDIO 2 +#define ESP_SDFAT2 3 -//SDIO Mode -#define SD_ONE_BIT_MODE 1 -#define SD_FOUR_BIT_MODE 0 +// SDIO Mode +#define SD_ONE_BIT_MODE 1 +#define SD_FOUR_BIT_MODE 0 -//SD state -#define ESP_SDCARD_IDLE 0 -#define ESP_SDCARD_NOT_PRESENT 1 -#define ESP_SDCARD_BUSY 2 +// SD state +#define ESP_SDCARD_IDLE 0 +#define ESP_SDCARD_NOT_PRESENT 1 +#define ESP_SDCARD_BUSY 2 -//Notifications -#define ESP_NO_NOTIFICATION 0 -#define ESP_PUSHOVER_NOTIFICATION 1 -#define ESP_EMAIL_NOTIFICATION 2 -#define ESP_LINE_NOTIFICATION 3 -#define ESP_TELEGRAM_NOTIFICATION 4 -#define ESP_IFTTT_NOTIFICATION 5 +// Notifications +#define ESP_NO_NOTIFICATION 0 +#define ESP_PUSHOVER_NOTIFICATION 1 +#define ESP_EMAIL_NOTIFICATION 2 +#define ESP_LINE_NOTIFICATION 3 +#define ESP_TELEGRAM_NOTIFICATION 4 +#define ESP_IFTTT_NOTIFICATION 5 -//SENSOR -#define NO_SENSOR_DEVICE 0 -#define DHT11_DEVICE 1 -#define DHT22_DEVICE 2 -#define ANALOG_DEVICE 3 -#define BMP280_DEVICE 4 -#define BME280_DEVICE 5 +// SENSOR +#define NO_SENSOR_DEVICE 0 +#define DHT11_DEVICE 1 +#define DHT22_DEVICE 2 +#define ANALOG_DEVICE 3 +#define BMP280_DEVICE 4 +#define BME280_DEVICE 5 -#define USE_CELSIUS 1 -#define USE_FAHRENHEIT 2 +#define USE_CELSIUS 1 +#define USE_FAHRENHEIT 2 -//Camera -#define CAMERA_MODEL_CUSTOM 0 -#define CAMERA_MODEL_ESP_EYE 1 -#define CAMERA_MODEL_M5STACK_PSRAM 2 +// Camera +#define CAMERA_MODEL_CUSTOM 0 +#define CAMERA_MODEL_ESP_EYE 1 +#define CAMERA_MODEL_M5STACK_PSRAM 2 #define CAMERA_MODEL_M5STACK_V2_PSRAM 3 -#define CAMERA_MODEL_M5STACK_WIDE 4 -#define CAMERA_MODEL_AI_THINKER 7 -#define CAMERA_MODEL_WROVER_KIT 8 +#define CAMERA_MODEL_M5STACK_WIDE 4 +#define CAMERA_MODEL_AI_THINKER 7 +#define CAMERA_MODEL_WROVER_KIT 8 #define CAMERA_MODEL_ESP32_CAM_BOARD 10 #define CAMERA_MODEL_ESP32S2_CAM_BOARD 11 -#define CAMERA_MODEL_ESP32S3_CAM_LCD 12 -#define CAMERA_MODEL_ESP32S3_EYE 13 +#define CAMERA_MODEL_ESP32S3_CAM_LCD 12 +#define CAMERA_MODEL_ESP32S3_EYE 13 -//Errors code -#define ESP_ERROR_AUTHENTICATION 1 -#define ESP_ERROR_FILE_CREATION 2 -#define ESP_ERROR_FILE_WRITE 3 -#define ESP_ERROR_UPLOAD 4 -#define ESP_ERROR_NOT_ENOUGH_SPACE 5 -#define ESP_ERROR_UPLOAD_CANCELLED 6 -#define ESP_ERROR_FILE_CLOSE 7 -#define ESP_ERROR_NO_SD 8 -#define ESP_ERROR_MOUNT_SD 9 -#define ESP_ERROR_RESET_NUMBERING 10 -#define ESP_ERROR_BUFFER_OVERFLOW 11 -#define ESP_ERROR_START_UPLOAD 12 -#define ESP_ERROR_SIZE 13 -#define ESP_ERROR_UPDATE 14 +// Errors code +#define ESP_ERROR_AUTHENTICATION 1 +#define ESP_ERROR_FILE_CREATION 2 +#define ESP_ERROR_FILE_WRITE 3 +#define ESP_ERROR_UPLOAD 4 +#define ESP_ERROR_NOT_ENOUGH_SPACE 5 +#define ESP_ERROR_UPLOAD_CANCELLED 6 +#define ESP_ERROR_FILE_CLOSE 7 +#define ESP_ERROR_NO_SD 8 +#define ESP_ERROR_MOUNT_SD 9 +#define ESP_ERROR_RESET_NUMBERING 10 +#define ESP_ERROR_BUFFER_OVERFLOW 11 +#define ESP_ERROR_START_UPLOAD 12 +#define ESP_ERROR_SIZE 13 +#define ESP_ERROR_UPDATE 14 -//File system -#define ESP_FILE_READ 0 -#define ESP_FILE_WRITE 1 -#define ESP_FILE_APPEND 2 +// File system +#define ESP_FILE_READ 0 +#define ESP_FILE_WRITE 1 +#define ESP_FILE_APPEND 2 -#define ESP_SEEK_SET 0 -#define ESP_SEEK_CUR 1 -#define ESP_SEEK_END 2 +#define ESP_SEEK_SET 0 +#define ESP_SEEK_CUR 1 +#define ESP_SEEK_END 2 -#define FS_ROOT 0 -#define FS_FLASH 1 -#define FS_SD 2 -#define FS_USBDISK 3 -#define FS_UNKNOWN 254 +#define FS_ROOT 0 +#define FS_FLASH 1 +#define FS_SD 2 +#define FS_USBDISK 3 +#define FS_UNKNOWN 254 #define MAX_FS 3 -//ethernet clock modes (check ETH.h for eth_clock_mode_t) -#define MODE_ETH_CLOCK_GPIO0_IN 0 -#define MODE_ETH_CLOCK_GPIO0_OUT 1 +// ethernet clock modes (check ETH.h for eth_clock_mode_t) +#define MODE_ETH_CLOCK_GPIO0_IN 0 +#define MODE_ETH_CLOCK_GPIO0_OUT 1 #define MODE_ETH_CLOCK_GPIO16_OUT 2 #define MODE_ETH_CLOCK_GPIO17_OUT 3 -//Ethernet type (Check ETH.h eth_phy_type_t) +// Ethernet type (Check ETH.h eth_phy_type_t) #define TYPE_ETH_PHY_LAN8720 0 -#define TYPE_ETH_PHY_TLK110 1 +#define TYPE_ETH_PHY_TLK110 1 #define TYPE_ETH_PHY_RTL8201 2 #define TYPE_ETH_PHY_DP83848 3 -#define TYPE_ETH_PHY_DM9051 4 +#define TYPE_ETH_PHY_DM9051 4 #define TYPE_ETH_PHY_KSZ8041 5 #define TYPE_ETH_PHY_KSZ8081 6 -//Host path +// Host path #define ESP3D_HOST_PATH "/" -#endif //_DEFINES_ESP3D_H +#endif //_DEFINES_ESP3D_H diff --git a/esp3d/src/include/pins.h b/esp3d/src/include/pins.h index c54aa1ea..3907cd6d 100644 --- a/esp3d/src/include/pins.h +++ b/esp3d/src/include/pins.h @@ -18,349 +18,349 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -//Serial Pins +// Serial Pins //-1 means use default pins of your board what ever the serial you choose -// * UART 0 possible options are (1, 3), (2, 3) or (15, 13) -// * UART 1 allows only TX on 2 if UART 0 is not (2, 3) +// * UART 0 possible options are (1, 3), (2, 3) or (15, 13) +// * UART 1 allows only TX on 2 if UART 0 is not (2, 3) #ifndef ESP_RX_PIN #define ESP_RX_PIN -1 -#endif //ESP_RX_PIN +#endif // ESP_RX_PIN #ifndef ESP_TX_PIN #define ESP_TX_PIN -1 -#endif //ESP_TX_PIN +#endif // ESP_TX_PIN #if defined(ESP_SERIAL_BRIDGE_OUTPUT) #ifndef ESP_BRIDGE_RX_PIN #define ESP_BRIDGE_RX_PIN -1 -#endif //ESP_BRIDGE_RX_PIN +#endif // ESP_BRIDGE_RX_PIN #ifndef ESP_BRIDGE_TX_PIN #define ESP_BRIDGE_TX_PIN -1 -#endif //ESP_BRIDGE_TX_PIN -#endif //ESP_SERIAL_BRIDGE_OUTPUT +#endif // ESP_BRIDGE_TX_PIN +#endif // ESP_SERIAL_BRIDGE_OUTPUT #ifndef ESP_DEBUG_RX_PIN #define ESP_DEBUG_RX_PIN -1 -#endif //ESP_DEBUG_RX_PIN +#endif // ESP_DEBUG_RX_PIN #ifndef ESP_DEBUG_TX_PIN #define ESP_DEBUG_TX_PIN -1 -#endif //ESP_DEBUG_TX_PIN +#endif // ESP_DEBUG_TX_PIN -//I2C Pins +// I2C Pins #ifndef ESP_SDA_PIN #define ESP_SDA_PIN SDA -#endif //~ESP_SDA_PIN +#endif //~ESP_SDA_PIN #ifndef ESP_SCL_PIN #define ESP_SCL_PIN SCL -#endif //~ESP_SCL_PIN +#endif //~ESP_SCL_PIN -//Pins for the support of connected camera +// Pins for the support of connected camera #ifndef USE_BOARD_HEADER #define USE_BOARD_HEADER 0 -#endif //USE_BOARD_HEADER +#endif // USE_BOARD_HEADER -#if defined (CAMERA_DEVICE) +#if defined(CAMERA_DEVICE) #if CAMERA_DEVICE == CAMERA_MODEL_CUSTOM -#define CAM_LED_PIN 4 -#define CAM_PULLUP1 -1 -#define CAM_PULLUP2 -1 -#define PWDN_GPIO_NUM 32 -#define RESET_GPIO_NUM -1 -#define XCLK_GPIO_NUM 0 -#define SIOD_GPIO_NUM 26 -#define SIOC_GPIO_NUM 27 +#define CAM_LED_PIN 4 +#define CAM_PULLUP1 -1 +#define CAM_PULLUP2 -1 +#define PWDN_GPIO_NUM 32 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 0 +#define SIOD_GPIO_NUM 26 +#define SIOC_GPIO_NUM 27 -#define Y9_GPIO_NUM 35 -#define Y8_GPIO_NUM 34 -#define Y7_GPIO_NUM 39 -#define Y6_GPIO_NUM 36 -#define Y5_GPIO_NUM 21 -#define Y4_GPIO_NUM 19 -#define Y3_GPIO_NUM 18 -#define Y2_GPIO_NUM 5 -#define VSYNC_GPIO_NUM 25 -#define HREF_GPIO_NUM 23 -#define PCLK_GPIO_NUM 22 -#endif //CAMERA_MODEL_CUSTOM +#define Y9_GPIO_NUM 35 +#define Y8_GPIO_NUM 34 +#define Y7_GPIO_NUM 39 +#define Y6_GPIO_NUM 36 +#define Y5_GPIO_NUM 21 +#define Y4_GPIO_NUM 19 +#define Y3_GPIO_NUM 18 +#define Y2_GPIO_NUM 5 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 23 +#define PCLK_GPIO_NUM 22 +#endif // CAMERA_MODEL_CUSTOM #if CAMERA_DEVICE == CAMERA_MODEL_WROVER_KIT -#define CAM_LED_PIN -1 -#define CAM_PULLUP1 -1 -#define CAM_PULLUP2 -1 -#define PWDN_GPIO_NUM -1 -#define RESET_GPIO_NUM -1 -#define XCLK_GPIO_NUM 21 -#define SIOD_GPIO_NUM 26 -#define SIOC_GPIO_NUM 27 +#define CAM_LED_PIN -1 +#define CAM_PULLUP1 -1 +#define CAM_PULLUP2 -1 +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 21 +#define SIOD_GPIO_NUM 26 +#define SIOC_GPIO_NUM 27 -#define Y9_GPIO_NUM 35 -#define Y8_GPIO_NUM 34 -#define Y7_GPIO_NUM 39 -#define Y6_GPIO_NUM 36 -#define Y5_GPIO_NUM 19 -#define Y4_GPIO_NUM 18 -#define Y3_GPIO_NUM 5 -#define Y2_GPIO_NUM 4 -#define VSYNC_GPIO_NUM 25 -#define HREF_GPIO_NUM 23 -#define PCLK_GPIO_NUM 22 -#endif //CAMERA_MODEL_WROVER_KIT +#define Y9_GPIO_NUM 35 +#define Y8_GPIO_NUM 34 +#define Y7_GPIO_NUM 39 +#define Y6_GPIO_NUM 36 +#define Y5_GPIO_NUM 19 +#define Y4_GPIO_NUM 18 +#define Y3_GPIO_NUM 5 +#define Y2_GPIO_NUM 4 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 23 +#define PCLK_GPIO_NUM 22 +#endif // CAMERA_MODEL_WROVER_KIT #if CAMERA_DEVICE == CAMERA_MODEL_ESP_EYE -#define CAM_LED_PIN -1 -#define CAM_PULLUP1 13 -#define CAM_PULLUP2 14 -#define PWDN_GPIO_NUM -1 -#define RESET_GPIO_NUM -1 -#define XCLK_GPIO_NUM 4 -#define SIOD_GPIO_NUM 18 -#define SIOC_GPIO_NUM 23 +#define CAM_LED_PIN -1 +#define CAM_PULLUP1 13 +#define CAM_PULLUP2 14 +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 4 +#define SIOD_GPIO_NUM 18 +#define SIOC_GPIO_NUM 23 -#define Y9_GPIO_NUM 36 -#define Y8_GPIO_NUM 37 -#define Y7_GPIO_NUM 38 -#define Y6_GPIO_NUM 39 -#define Y5_GPIO_NUM 35 -#define Y4_GPIO_NUM 14 -#define Y3_GPIO_NUM 13 -#define Y2_GPIO_NUM 34 -#define VSYNC_GPIO_NUM 5 -#define HREF_GPIO_NUM 27 -#define PCLK_GPIO_NUM 25 -#endif //CAMERA_MODEL_ESP_EYE +#define Y9_GPIO_NUM 36 +#define Y8_GPIO_NUM 37 +#define Y7_GPIO_NUM 38 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 35 +#define Y4_GPIO_NUM 14 +#define Y3_GPIO_NUM 13 +#define Y2_GPIO_NUM 34 +#define VSYNC_GPIO_NUM 5 +#define HREF_GPIO_NUM 27 +#define PCLK_GPIO_NUM 25 +#endif // CAMERA_MODEL_ESP_EYE #if CAMERA_DEVICE == CAMERA_MODEL_M5STACK_PSRAM -#define CAM_LED_PIN -1 -#define CAM_PULLUP1 -1 -#define CAM_PULLUP2 -1 -#define PWDN_GPIO_NUM -1 -#define RESET_GPIO_NUM 15 -#define XCLK_GPIO_NUM 27 -#define SIOD_GPIO_NUM 25 -#define SIOC_GPIO_NUM 23 +#define CAM_LED_PIN -1 +#define CAM_PULLUP1 -1 +#define CAM_PULLUP2 -1 +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM 15 +#define XCLK_GPIO_NUM 27 +#define SIOD_GPIO_NUM 25 +#define SIOC_GPIO_NUM 23 -#define Y9_GPIO_NUM 19 -#define Y8_GPIO_NUM 36 -#define Y7_GPIO_NUM 18 -#define Y6_GPIO_NUM 39 -#define Y5_GPIO_NUM 5 -#define Y4_GPIO_NUM 34 -#define Y3_GPIO_NUM 35 -#define Y2_GPIO_NUM 32 -#define VSYNC_GPIO_NUM 22 -#define HREF_GPIO_NUM 26 -#define PCLK_GPIO_NUM 21 -#endif //CAMERA_MODEL_M5STACK_PSRAM +#define Y9_GPIO_NUM 19 +#define Y8_GPIO_NUM 36 +#define Y7_GPIO_NUM 18 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 5 +#define Y4_GPIO_NUM 34 +#define Y3_GPIO_NUM 35 +#define Y2_GPIO_NUM 32 +#define VSYNC_GPIO_NUM 22 +#define HREF_GPIO_NUM 26 +#define PCLK_GPIO_NUM 21 +#endif // CAMERA_MODEL_M5STACK_PSRAM #if CAMERA_DEVICE == CAMERA_MODEL_M5STACK_PSRAM_2 -#define CAM_LED_PIN -1 -#define CAM_PULLUP1 -1 -#define CAM_PULLUP2 -1 -#define PWDN_GPIO_NUM -1 -#define RESET_GPIO_NUM 15 -#define XCLK_GPIO_NUM 27 -#define SIOD_GPIO_NUM 22 -#define SIOC_GPIO_NUM 23 +#define CAM_LED_PIN -1 +#define CAM_PULLUP1 -1 +#define CAM_PULLUP2 -1 +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM 15 +#define XCLK_GPIO_NUM 27 +#define SIOD_GPIO_NUM 22 +#define SIOC_GPIO_NUM 23 -#define Y9_GPIO_NUM 19 -#define Y8_GPIO_NUM 36 -#define Y7_GPIO_NUM 18 -#define Y6_GPIO_NUM 39 -#define Y5_GPIO_NUM 5 -#define Y4_GPIO_NUM 34 -#define Y3_GPIO_NUM 35 -#define Y2_GPIO_NUM 32 -#define VSYNC_GPIO_NUM 25 -#define HREF_GPIO_NUM 26 -#define PCLK_GPIO_NUM 21 -#endif //CAMERA_MODEL_M5STACK_PSRAM_2 +#define Y9_GPIO_NUM 19 +#define Y8_GPIO_NUM 36 +#define Y7_GPIO_NUM 18 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 5 +#define Y4_GPIO_NUM 34 +#define Y3_GPIO_NUM 35 +#define Y2_GPIO_NUM 32 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 26 +#define PCLK_GPIO_NUM 21 +#endif // CAMERA_MODEL_M5STACK_PSRAM_2 #if CAMERA_DEVICE == CAMERA_MODEL_M5STACK_WIDE -#define CAM_LED_PIN -1 -#define CAM_PULLUP1 -1 -#define CAM_PULLUP2 -1 -#define PWDN_GPIO_NUM -1 -#define RESET_GPIO_NUM 15 -#define XCLK_GPIO_NUM 27 -#define SIOD_GPIO_NUM 22 -#define SIOC_GPIO_NUM 23 +#define CAM_LED_PIN -1 +#define CAM_PULLUP1 -1 +#define CAM_PULLUP2 -1 +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM 15 +#define XCLK_GPIO_NUM 27 +#define SIOD_GPIO_NUM 22 +#define SIOC_GPIO_NUM 23 -#define Y9_GPIO_NUM 19 -#define Y8_GPIO_NUM 36 -#define Y7_GPIO_NUM 18 -#define Y6_GPIO_NUM 39 -#define Y5_GPIO_NUM 5 -#define Y4_GPIO_NUM 34 -#define Y3_GPIO_NUM 35 -#define Y2_GPIO_NUM 32 -#define VSYNC_GPIO_NUM 25 -#define HREF_GPIO_NUM 26 -#define PCLK_GPIO_NUM 21 -#endif //CAMERA_MODEL_M5STACK_WIDE +#define Y9_GPIO_NUM 19 +#define Y8_GPIO_NUM 36 +#define Y7_GPIO_NUM 18 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 5 +#define Y4_GPIO_NUM 34 +#define Y3_GPIO_NUM 35 +#define Y2_GPIO_NUM 32 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 26 +#define PCLK_GPIO_NUM 21 +#endif // CAMERA_MODEL_M5STACK_WIDE #if CAMERA_DEVICE == CAMERA_MODEL_M5STACK_ESP32CAM -#define CAM_LED_PIN -1 -#define CAM_PULLUP1 -1 -#define CAM_PULLUP2 -1 -#define PWDN_GPIO_NUM -1 -#define RESET_GPIO_NUM 15 -#define XCLK_GPIO_NUM 27 -#define SIOD_GPIO_NUM 25 -#define SIOC_GPIO_NUM 23 +#define CAM_LED_PIN -1 +#define CAM_PULLUP1 -1 +#define CAM_PULLUP2 -1 +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM 15 +#define XCLK_GPIO_NUM 27 +#define SIOD_GPIO_NUM 25 +#define SIOC_GPIO_NUM 23 -#define Y9_GPIO_NUM 19 -#define Y8_GPIO_NUM 36 -#define Y7_GPIO_NUM 18 -#define Y6_GPIO_NUM 39 -#define Y5_GPIO_NUM 5 -#define Y4_GPIO_NUM 34 -#define Y3_GPIO_NUM 35 -#define Y2_GPIO_NUM 17 -#define VSYNC_GPIO_NUM 22 -#define HREF_GPIO_NUM 26 -#define PCLK_GPIO_NUM 21 +#define Y9_GPIO_NUM 19 +#define Y8_GPIO_NUM 36 +#define Y7_GPIO_NUM 18 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 5 +#define Y4_GPIO_NUM 34 +#define Y3_GPIO_NUM 35 +#define Y2_GPIO_NUM 17 +#define VSYNC_GPIO_NUM 22 +#define HREF_GPIO_NUM 26 +#define PCLK_GPIO_NUM 21 -#endif //CAMERA_MODEL_M5STACK_ESP32CAM +#endif // CAMERA_MODEL_M5STACK_ESP32CAM #if CAMERA_DEVICE == CAMERA_MODEL_M5STACK_UNITCAM -#define CAM_LED_PIN -1 -#define CAM_PULLUP1 -1 -#define CAM_PULLUP2 -1 -#define PWDN_GPIO_NUM -1 -#define RESET_GPIO_NUM 15 -#define XCLK_GPIO_NUM 27 -#define SIOD_GPIO_NUM 25 -#define SIOC_GPIO_NUM 23 +#define CAM_LED_PIN -1 +#define CAM_PULLUP1 -1 +#define CAM_PULLUP2 -1 +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM 15 +#define XCLK_GPIO_NUM 27 +#define SIOD_GPIO_NUM 25 +#define SIOC_GPIO_NUM 23 -#define Y9_GPIO_NUM 19 -#define Y8_GPIO_NUM 36 -#define Y7_GPIO_NUM 18 -#define Y6_GPIO_NUM 39 -#define Y5_GPIO_NUM 5 -#define Y4_GPIO_NUM 34 -#define Y3_GPIO_NUM 35 -#define Y2_GPIO_NUM 32 -#define VSYNC_GPIO_NUM 22 -#define HREF_GPIO_NUM 26 -#define PCLK_GPIO_NUM 21 -#endif //CAMERA_MODEL_M5STACK_UNITCAM +#define Y9_GPIO_NUM 19 +#define Y8_GPIO_NUM 36 +#define Y7_GPIO_NUM 18 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 5 +#define Y4_GPIO_NUM 34 +#define Y3_GPIO_NUM 35 +#define Y2_GPIO_NUM 32 +#define VSYNC_GPIO_NUM 22 +#define HREF_GPIO_NUM 26 +#define PCLK_GPIO_NUM 21 +#endif // CAMERA_MODEL_M5STACK_UNITCAM #if CAMERA_DEVICE == CAMERA_MODEL_AI_THINKER -#define CAM_LED_PIN -1 //used by SD so must left unset -#define CAM_PULLUP1 -1 -#define CAM_PULLUP2 -1 +#define CAM_LED_PIN -1 // used by SD so must left unset +#define CAM_PULLUP1 -1 +#define CAM_PULLUP2 -1 -#define PWDN_GPIO_NUM 32 -#define RESET_GPIO_NUM -1 -#define XCLK_GPIO_NUM 0 -#define SIOD_GPIO_NUM 26 -#define SIOC_GPIO_NUM 27 -#define Y9_GPIO_NUM 35 -#define Y8_GPIO_NUM 34 -#define Y7_GPIO_NUM 39 -#define Y6_GPIO_NUM 36 -#define Y5_GPIO_NUM 21 -#define Y4_GPIO_NUM 19 -#define Y3_GPIO_NUM 18 -#define Y2_GPIO_NUM 5 -#define VSYNC_GPIO_NUM 25 -#define HREF_GPIO_NUM 23 -#define PCLK_GPIO_NUM 22 -#endif //CAMERA_MODEL_AI_THINKER +#define PWDN_GPIO_NUM 32 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 0 +#define SIOD_GPIO_NUM 26 +#define SIOC_GPIO_NUM 27 +#define Y9_GPIO_NUM 35 +#define Y8_GPIO_NUM 34 +#define Y7_GPIO_NUM 39 +#define Y6_GPIO_NUM 36 +#define Y5_GPIO_NUM 21 +#define Y4_GPIO_NUM 19 +#define Y3_GPIO_NUM 18 +#define Y2_GPIO_NUM 5 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 23 +#define PCLK_GPIO_NUM 22 +#endif // CAMERA_MODEL_AI_THINKER #if CAMERA_DEVICE == CAMERA_MODEL_ESP32_CAM_BOARD -#define CAM_LED_PIN -1 -#define CAM_PULLUP1 -1 -#define CAM_PULLUP2 -1 +#define CAM_LED_PIN -1 +#define CAM_PULLUP1 -1 +#define CAM_PULLUP2 -1 // The 18 pin header on the board has Y5 and Y3 swapped #define USE_BOARD_HEADER 0 -#define PWDN_GPIO_NUM 32 -#define RESET_GPIO_NUM 33 -#define XCLK_GPIO_NUM 4 -#define SIOD_GPIO_NUM 18 -#define SIOC_GPIO_NUM 23 +#define PWDN_GPIO_NUM 32 +#define RESET_GPIO_NUM 33 +#define XCLK_GPIO_NUM 4 +#define SIOD_GPIO_NUM 18 +#define SIOC_GPIO_NUM 23 -#define Y9_GPIO_NUM 36 -#define Y8_GPIO_NUM 19 -#define Y7_GPIO_NUM 21 -#define Y6_GPIO_NUM 39 +#define Y9_GPIO_NUM 36 +#define Y8_GPIO_NUM 19 +#define Y7_GPIO_NUM 21 +#define Y6_GPIO_NUM 39 #if USE_BOARD_HEADER -#define Y5_GPIO_NUM 13 +#define Y5_GPIO_NUM 13 #else -#define Y5_GPIO_NUM 35 +#define Y5_GPIO_NUM 35 #endif -#define Y4_GPIO_NUM 14 +#define Y4_GPIO_NUM 14 #if USE_BOARD_HEADER -#define Y3_GPIO_NUM 35 +#define Y3_GPIO_NUM 35 #else -#define Y3_GPIO_NUM 13 +#define Y3_GPIO_NUM 13 #endif -#define Y2_GPIO_NUM 34 -#define VSYNC_GPIO_NUM 5 -#define HREF_GPIO_NUM 27 -#define PCLK_GPIO_NUM 25 -#endif //CAMERA_MODEL_ESP32_CAM_BOARD +#define Y2_GPIO_NUM 34 +#define VSYNC_GPIO_NUM 5 +#define HREF_GPIO_NUM 27 +#define PCLK_GPIO_NUM 25 +#endif // CAMERA_MODEL_ESP32_CAM_BOARD #if CAMERA_DEVICE == CAMERA_MODEL_ESP32S3_CAM_LCD -#define CAM_LED_PIN -1 -#define CAM_PULLUP1 -1 -#define CAM_PULLUP2 -1 -#define PWDN_GPIO_NUM -1 -#define RESET_GPIO_NUM -1 -#define XCLK_GPIO_NUM 40 -#define SIOD_GPIO_NUM 17 -#define SIOC_GPIO_NUM 18 +#define CAM_LED_PIN -1 +#define CAM_PULLUP1 -1 +#define CAM_PULLUP2 -1 +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 40 +#define SIOD_GPIO_NUM 17 +#define SIOC_GPIO_NUM 18 -#define Y9_GPIO_NUM 39 -#define Y8_GPIO_NUM 41 -#define Y7_GPIO_NUM 42 -#define Y6_GPIO_NUM 12 -#define Y5_GPIO_NUM 3 -#define Y4_GPIO_NUM 14 -#define Y3_GPIO_NUM 47 -#define Y2_GPIO_NUM 13 -#define VSYNC_GPIO_NUM 21 -#define HREF_GPIO_NUM 38 -#define PCLK_GPIO_NUM 11 -#endif //CAMERA_MODEL_ESP32S3_CAM_LCD +#define Y9_GPIO_NUM 39 +#define Y8_GPIO_NUM 41 +#define Y7_GPIO_NUM 42 +#define Y6_GPIO_NUM 12 +#define Y5_GPIO_NUM 3 +#define Y4_GPIO_NUM 14 +#define Y3_GPIO_NUM 47 +#define Y2_GPIO_NUM 13 +#define VSYNC_GPIO_NUM 21 +#define HREF_GPIO_NUM 38 +#define PCLK_GPIO_NUM 11 +#endif // CAMERA_MODEL_ESP32S3_CAM_LCD #if CAMERA_DEVICE == CAMERA_MODEL_ESP32S2_CAM_BOARD -#define CAM_LED_PIN -1 -#define CAM_PULLUP1 -1 -#define CAM_PULLUP2 -1 +#define CAM_LED_PIN -1 +#define CAM_PULLUP1 -1 +#define CAM_PULLUP2 -1 // The 18 pin header on the board has Y5 and Y3 swapped -#define PWDN_GPIO_NUM 1 -#define RESET_GPIO_NUM 2 -#define XCLK_GPIO_NUM 42 -#define SIOD_GPIO_NUM 41 -#define SIOC_GPIO_NUM 18 +#define PWDN_GPIO_NUM 1 +#define RESET_GPIO_NUM 2 +#define XCLK_GPIO_NUM 42 +#define SIOD_GPIO_NUM 41 +#define SIOC_GPIO_NUM 18 -#define Y9_GPIO_NUM 16 -#define Y8_GPIO_NUM 39 -#define Y7_GPIO_NUM 40 -#define Y6_GPIO_NUM 15 +#define Y9_GPIO_NUM 16 +#define Y8_GPIO_NUM 39 +#define Y7_GPIO_NUM 40 +#define Y6_GPIO_NUM 15 #if USE_BOARD_HEADER -#define Y5_GPIO_NUM 12 +#define Y5_GPIO_NUM 12 #else -#define Y5_GPIO_NUM 13 +#define Y5_GPIO_NUM 13 #endif -#define Y4_GPIO_NUM 5 +#define Y4_GPIO_NUM 5 #if USE_BOARD_HEADER -#define Y3_GPIO_NUM 13 +#define Y3_GPIO_NUM 13 #else -#define Y3_GPIO_NUM 12 +#define Y3_GPIO_NUM 12 #endif -#define Y2_GPIO_NUM 14 -#define VSYNC_GPIO_NUM 38 -#define HREF_GPIO_NUM 4 -#define PCLK_GPIO_NUM 3 -#endif //CAMERA_MODEL_ESP32S2_CAM_BOARD +#define Y2_GPIO_NUM 14 +#define VSYNC_GPIO_NUM 38 +#define HREF_GPIO_NUM 4 +#define PCLK_GPIO_NUM 3 +#endif // CAMERA_MODEL_ESP32S2_CAM_BOARD #if CAMERA_DEVICE == CAMERA_MODEL_ESP32S3_EYE -#define CAM_LED_PIN -1 -#define CAM_PULLUP1 -1 -#define CAM_PULLUP2 -1 +#define CAM_LED_PIN -1 +#define CAM_PULLUP1 -1 +#define CAM_PULLUP2 -1 #define PWDN_GPIO_NUM -1 #define RESET_GPIO_NUM -1 #define XCLK_GPIO_NUM 15 @@ -379,71 +379,98 @@ #define VSYNC_GPIO_NUM 6 #define HREF_GPIO_NUM 7 #define PCLK_GPIO_NUM 13 -#endif //CAMERA_MODEL_ESP32S3_EYE +#endif // CAMERA_MODEL_ESP32S3_EYE -#endif //CAMERA_DEVICE +#endif // CAMERA_DEVICE -//Pins for the support of SD Card Reader +// Pins for the support of SD Card Reader //-1 means use default pins of your board defined core -//this are overwrited if defined in configuration.h or myconfig.h +// this are overwrited if defined in configuration.h or myconfig.h #ifndef ESP_SDIO_CLK_PIN #define ESP_SDIO_CLK_PIN -1 #endif // ESP_SDIO_CLK_PIN #ifndef ESP_SDIO_CMD_PIN -#define ESP_SDIO_CMD_PIN -1 -#endif // ESP_SDIO_CMD_PIN +#define ESP_SDIO_CMD_PIN -1 +#endif // ESP_SDIO_CMD_PIN #ifndef ESP_SDIO_D0_PIN #define ESP_SDIO_D0_PIN -1 -#endif //ESP_SDIO_D0_PIN +#endif // ESP_SDIO_D0_PIN #ifndef ESP_SDIO_D1_PIN #define ESP_SDIO_D1_PIN -1 -#endif //ESP_SDIO_D1_PIN +#endif // ESP_SDIO_D1_PIN #ifndef ESP_SDIO_D2_PIN #define ESP_SDIO_D2_PIN -1 -#endif //ESP_SDIO_D2_PIN +#endif // ESP_SDIO_D2_PIN #ifndef ESP_SDIO_D3_PIN #define ESP_SDIO_D3_PIN -1 -#endif //ESP_SDIO_D3_PIN +#endif // ESP_SDIO_D3_PIN #ifndef ESP_SD_CS_PIN -#define ESP_SD_CS_PIN -1 -#endif //ESP_SD_CS_PIN -//These are hardcoded on ESP8266 to 12/13/14 -//so modifications are ignored on ESP8266 +#define ESP_SD_CS_PIN -1 +#endif // ESP_SD_CS_PIN +// These are hardcoded on ESP8266 to 12/13/14 +// so modifications are ignored on ESP8266 #ifndef ESP_SD_MISO_PIN -#define ESP_SD_MISO_PIN -1 -#endif //ESP_SD_MISO_PIN +#define ESP_SD_MISO_PIN -1 +#endif // ESP_SD_MISO_PIN #ifndef ESP_SD_MOSI_PIN -#define ESP_SD_MOSI_PIN -1 -#endif //ESP_SD_MOSI_PIN +#define ESP_SD_MOSI_PIN -1 +#endif // ESP_SD_MOSI_PIN #ifndef ESP_SD_SCK_PIN -#define ESP_SD_SCK_PIN -1 -#endif //ESP_SD_SCK_PIN +#define ESP_SD_SCK_PIN -1 +#endif // ESP_SD_SCK_PIN #ifndef ESP_SD_DETECT_PIN -#define ESP_SD_DETECT_PIN -1 -#endif //ESP_SD_DETECT_PIN +#define ESP_SD_DETECT_PIN -1 +#endif // ESP_SD_DETECT_PIN -#if defined (PIN_RESET_FEATURE) && !defined(ESP3D_RESET_PIN) +#if defined(PIN_RESET_FEATURE) && !defined(ESP3D_RESET_PIN) #define ESP3D_RESET_PIN -1 -#endif //PIN_RESET_FEATURE +#endif // PIN_RESET_FEATURE #ifdef SD_DEVICE_CONNECTION #ifndef ESP_SD_DETECT_VALUE #define ESP_SD_DETECT_VALUE LOW -#endif //ESP_SD_DETECT_VALUE +#endif // ESP_SD_DETECT_VALUE #if SD_DEVICE_CONNECTION == ESP_SHARED_SD + +#if SD_CARD_TYPE == ESP_FYSETC_WIFI_PRO_SDCARD +// #define all pins +// 1 - Undef all pins to be clear +#undef ESP_SD_CS_PIN +#undef ESP_SD_MISO_PIN +#undef ESP_SD_MOSI_PIN +#undef ESP_SD_SCK_PIN +#undef ESP_SD_DETECT_PIN +#undef ESP_FLAG_SHARED_SD_PIN +#undef ESP_FLAG_SHARED_SD_VALUE +// 2 - Define all pins / values for FYSETC_WIFI_PRO_SDCARD +#define ESP_SD_CS_PIN 13 // D3 +#define ESP_SD_MISO_PIN 2 // D0 +#define ESP_SD_MOSI_PIN 15 // CMD +#define ESP_SD_SCK_PIN 14 // CLK +#define ESP_SD_DETECT_PIN -1 +#define ESP_FLAG_SHARED_SD_PIN 26 +#define ESP_FLAG_SHARED_SD_VALUE LOW +#define ESP_SD_CS_SENSE 32 +#define ESP_SD_POWER_PIN 27 +#define ESP_POWER_SD_VALUE LOW +#define ESP_SD_D1_PIN 4 +#define ESP_SD_D2_PIN 12 +#else #ifndef ESP_FLAG_SHARED_SD_PIN #define ESP_FLAG_SHARED_SD_PIN -1 -#endif //ESP_PIN_SHARED_SD +#endif // ESP_PIN_SHARED_SD +#endif // SD_CARD_TYPE==ESP_FYSETC_WIFI_PRO_SDCARD + #ifndef ESP_FLAG_SHARED_SD_VALUE #define ESP_FLAG_SHARED_SD_VALUE 0 -#endif //ESP_FLAG_SHARED_SD_VALUE -#endif //SD_DEVICE_CONNECTION == ESP_SHARED_SD -#endif //SD_DEVICE_CONNECTION +#endif // ESP_FLAG_SHARED_SD_VALUE +#endif // SD_DEVICE_CONNECTION == ESP_SHARED_SD +#endif // SD_DEVICE_CONNECTION diff --git a/esp3d/src/include/sanity_esp3d.h b/esp3d/src/include/sanity_esp3d.h index 5acb0321..d6444687 100644 --- a/esp3d/src/include/sanity_esp3d.h +++ b/esp3d/src/include/sanity_esp3d.h @@ -20,17 +20,16 @@ #ifndef _SANITY_ESP3D_H #define _SANITY_ESP3D_H - -#include "esp3d_config.h" #if not defined(ESP_NO_SANITY_CHECK) /************************** * Settings * ***********************/ -#if (ESP_SAVE_SETTINGS == SETTINGS_IN_PREFERENCES) && defined( ARDUINO_ARCH_ESP8266) +#if (ESP_SAVE_SETTINGS == SETTINGS_IN_PREFERENCES) && \ + defined(ARDUINO_ARCH_ESP8266) #error Preferences library is not available for ESP8266 #endif -#if !defined (ESP_SAVE_SETTINGS) +#if !defined(ESP_SAVE_SETTINGS) #error Choose Preferences or EEPROM for settings #endif @@ -41,42 +40,41 @@ #if defined(ESP_DEBUG_FEATURE) #if ESP_DEBUG_FEATURE == ESP_SERIAL_OUTPUT #warning You use same serial for output and debug -#endif //ESP_DEBUG_FEATURE == ESP_SERIAL_OUTPUT -#if (ESP_DEBUG_FEATURE == DEBUG_OUTPUT_SERIAL2) && defined( ARDUINO_ARCH_ESP8266) +#endif // ESP_DEBUG_FEATURE == ESP_SERIAL_OUTPUT +#if (ESP_DEBUG_FEATURE == DEBUG_OUTPUT_SERIAL2) && defined(ARDUINO_ARCH_ESP8266) #error Serial 2 is not available in ESP8266 for debug -#endif //ESP_DEBUG_FEATURE == DEBUG_OUTPUT_SERIAL2 ) && ARDUINO_ARCH_ESP8266 -#endif //ESP_DEBUG_FEATURE +#endif // ESP_DEBUG_FEATURE == DEBUG_OUTPUT_SERIAL2 ) && ARDUINO_ARCH_ESP8266 +#endif // ESP_DEBUG_FEATURE /************************** * Serial * ***********************/ -#if !defined(ESP_SERIAL_OUTPUT) && COMMUNICATION_PROTOCOL!=SOCKET_SERIAL +#if !defined(ESP_SERIAL_OUTPUT) && COMMUNICATION_PROTOCOL != SOCKET_SERIAL #error ESP_SERIAL_OUTPUT must be defined -#endif //!defined(ESP_SERIAL_OUTPUT) && COMMUNICATION_PROTOCOL!=SOCKET_SERIAL +#endif //! defined(ESP_SERIAL_OUTPUT) && COMMUNICATION_PROTOCOL!=SOCKET_SERIAL -#if COMMUNICATION_PROTOCOL!=SOCKET_SERIAL && defined(ESP_SERIAL_BRIDGE_OUTPUT) && ESP_SERIAL_OUTPUT==ESP_SERIAL_BRIDGE_OUTPUT +#if COMMUNICATION_PROTOCOL != SOCKET_SERIAL && \ + defined(ESP_SERIAL_BRIDGE_OUTPUT) && \ + ESP_SERIAL_OUTPUT == ESP_SERIAL_BRIDGE_OUTPUT #error ESP_SERIAL_OUTPUT cannot be same as ESP_SERIAL_BRIDGE_OUTPUT -#endif //!defined(ESP_SERIAL_OUTPUT) && COMMUNICATION_PROTOCOL!=SOCKET_SERIAL +#endif //! defined(ESP_SERIAL_OUTPUT) && COMMUNICATION_PROTOCOL!=SOCKET_SERIAL - -#if (ESP_SERIAL_OUTPUT == USE_SERIAL2) && defined( ARDUINO_ARCH_ESP8266) +#if (ESP_SERIAL_OUTPUT == USE_SERIAL2) && defined(ARDUINO_ARCH_ESP8266) #error Serial 2 is not available in ESP8266 -#endif //ESP_SERIAL_OUTPUT == USE_SERIAL_2 ) && ARDUINO_ARCH_ESP8266 - +#endif // ESP_SERIAL_OUTPUT == USE_SERIAL_2 ) && ARDUINO_ARCH_ESP8266 /************************** * Bluetooth * ***********************/ -#if defined (BLUETOOTH_FEATURE) && defined( ARDUINO_ARCH_ESP8266) +#if defined(BLUETOOTH_FEATURE) && defined(ARDUINO_ARCH_ESP8266) #error Bluetooth is not available in ESP8266 #endif - /************************** * Ethernet * ***********************/ -#if defined (ETH_FEATURE) && defined( ARDUINO_ARCH_ESP8266) +#if defined(ETH_FEATURE) && defined(ARDUINO_ARCH_ESP8266) #error Ethernet is not available in ESP8266 #endif @@ -84,39 +82,47 @@ * Time * ***********************/ - /************************** * Filesystem * ***********************/ -#if FILESYSTEM_FEATURE == ESP_FAT_FILESYSTEM && defined( ARDUINO_ARCH_ESP8266) +#if FILESYSTEM_FEATURE == ESP_FAT_FILESYSTEM && defined(ARDUINO_ARCH_ESP8266) #error Fat FS is not available in ESP8266 #endif -#if FILESYSTEM_FEATURE == ESP_SPIFFS_FILESYSTEM && defined( ARDUINO_ARCH_ESP8266) +#if FILESYSTEM_FEATURE == ESP_SPIFFS_FILESYSTEM && defined(ARDUINO_ARCH_ESP8266) #error ESP_SPIFFS_FILESYSTEM is no more available in ESP8266, use ESP_LITTLEFS_FILESYSTEM instead #endif /************************** * Camera * ***********************/ -#if defined(CAMERA_DEVICE) && defined( ARDUINO_ARCH_ESP8266) +#if defined(CAMERA_DEVICE) && defined(ARDUINO_ARCH_ESP8266) #error Camera is not available in ESP8266 #endif /************************** * SD * ***********************/ -#if defined(SD_DEVICE) && defined( ARDUINO_ARCH_ESP8266) +#if defined(SD_DEVICE) && defined(ARDUINO_ARCH_ESP8266) #if SD_DEVICE == ESP_SDIO #error SDIO is not available in ESP8266 #endif #endif -#if defined (SD_DEVICE_CONNECTION) && defined(PIN_RESET_FEATURE) && ESP3D_RESET_PIN!=-1 -#if SD_DEVICE_CONNECTION == ESP_SHARED_SD && ESP_FLAG_SHARED_SD_PIN == ESP3D_RESET_PIN +#if defined(SD_DEVICE_CONNECTION) && defined(PIN_RESET_FEATURE) && \ + ESP3D_RESET_PIN != -1 +#if SD_DEVICE_CONNECTION == ESP_SHARED_SD && \ + ESP_FLAG_SHARED_SD_PIN == ESP3D_RESET_PIN #error ESP_FLAG_SHARED_SD_PIN and ESP3D_RESET_PIN are same, it is not allowed. #endif #endif +#if SD_CARD_TYPE == ESP_FYSETC_WIFI_PRO_SDCARD && \ + (SD_DEVICE != ESP_SD_NATIVE || SD_DEVICE_CONNECTION != ESP_SHARED_SD) +#error ESP_FYSETC_WIFI_PRO_SDCARD only works with ESP_SD_NATIVE and ESP_SHARED_SD +#define ESP_NO_SANITY_CHECK 1 +#endif // SD_CARD_TYPE == ESP_FYSETC_WIFI_PRO_SDCARD && SD_DEVICE != + // ESP_SD_NATIVE && SD_DEVICE_CONNECTION!=ESP_SHARED_SD + /************************** * FTP * ***********************/ @@ -166,6 +172,6 @@ #error SD_UPDATE_FEATURE is not available because SD_DEVICE is not enabled #endif -#endif //ESP_NO_SANITY_CHECK +#endif // ESP_NO_SANITY_CHECK -#endif //SANITY_ESP3D_H +#endif // SANITY_ESP3D_H diff --git a/esp3d/src/modules/filesystem/esp_sd.cpp b/esp3d/src/modules/filesystem/esp_sd.cpp index 219d2bc9..240177f4 100644 --- a/esp3d/src/modules/filesystem/esp_sd.cpp +++ b/esp3d/src/modules/filesystem/esp_sd.cpp @@ -61,24 +61,24 @@ File tSDFile_handle[ESP_MAX_SD_OPENHANDLE]; #if SD_DEVICE_CONNECTION == ESP_SHARED_SD bool ESP_SD::_enabled = false; - +#if SD_CARD_TYPE == ESP_FYSETC_WIFI_PRO_SDCARD +#include +#endif // SD_CARD_TYPE == ESP_FYSETC_WIFI_PRO_SDCARD bool ESP_SD::enableSharedSD() { log_esp3d("Enable Shared SD if possible"); if (_enabled) { log_esp3d("Already enabled, skip"); return false; } - _enabled = true; -#if defined(ESP3D_CS_SD_SENSE) - log_esp3d("Setup SD sense pin %d", ESP3D_CS_SD_SENSE); - pinMode(ESP3D_CS_SD_SENSE, INPUT_PULLUP); -#endif // defined(ESP3D_CS_SD_SENSE) -#if defined(ESP3D_POWER_SD_PIN) && ESP3D_POWER_SD_PIN != -1 - log_esp3d("Setup SD power pin %d", ESP3D_POWER_SD_PIN); - pinMode(ESP3D_POWER_SD_PIN, OUTPUT); - // digitalWrite(ESP3D_POWER_SD_PIN, ESP3D_POWER_SD_VALUE); -#endif // defined(ESP3D_POWER_SD_PIN) +#if defined(ESP_SD_CS_SENSE) && ESP_SD_CS_SENSE != -1 + bool active_cs = !digitalRead(ESP_SD_CS_SENSE); + if (active_cs) { + log_esp3d("SD CS is active, skip"); + return false; + } +#endif // ESP_SD_CS_SENSE + _enabled = true; #if defined(ESP_FLAG_SHARED_SD_PIN) && ESP_FLAG_SHARED_SD_PIN != -1 // need to check if SD is in use ? // Method : TBD @@ -89,6 +89,13 @@ bool ESP_SD::enableSharedSD() { digitalWrite(ESP_FLAG_SHARED_SD_PIN, ESP_FLAG_SHARED_SD_VALUE); Hal::wait(100); #endif // ESP_FLAG_SHARED_SD_PIN + +#if SD_CARD_TYPE == ESP_FYSETC_WIFI_PRO_SDCARD + log_esp3d("Custom spi : CS: %d, Miso: %d, Mosi: %d, SCK: %d", ESP_SD_CS_PIN, + ESP_SD_MISO_PIN, ESP_SD_MOSI_PIN, ESP_SD_SCK_PIN); + SPI.begin(ESP_SD_SCK_PIN, ESP_SD_MISO_PIN, ESP_SD_MOSI_PIN, ESP_SD_CS_PIN); +#endif // SD_CARD_TYPE == ESP_FYSETC_WIFI_PRO_SDCARD + #if defined(ESP3DLIB_ENV) // check if card is not currently in use if (card.isMounted() && (IS_SD_PRINTING() || IS_SD_FETCHING() || @@ -101,6 +108,22 @@ bool ESP_SD::enableSharedSD() { return _enabled; } + +bool ESP_SD::disableSharedSD() { +#if SD_CARD_TYPE == ESP_FYSETC_WIFI_PRO_SDCARD + pinMode(ESP_SD_CS_PIN, INPUT_PULLUP); + pinMode(ESP_SD_MISO_PIN, INPUT_PULLUP); + pinMode(ESP_SD_MOSI_PIN, INPUT_PULLUP); + pinMode(ESP_SD_SCK_PIN, INPUT_PULLUP); + pinMode(ESP_SD_D1_PIN, INPUT_PULLUP); + pinMode(ESP_SD_D2_PIN, INPUT_PULLUP); + SPI.end(); +#endif // SD_CARD_TYPE == ESP_FYSETC_WIFI_PRO_SDCARD + // do the switch + digitalWrite(ESP_FLAG_SHARED_SD_PIN, !ESP_FLAG_SHARED_SD_VALUE); + Hal::wait(100); + return true; +} #endif // SD_DEVICE_CONNECTION == ESP_SHARED_SD bool ESP_SD::_started = false; @@ -144,9 +167,9 @@ void ESP_SD::releaseFS(uint8_t FS) { #if SD_DEVICE_CONNECTION == ESP_SHARED_SD _enabled = false; #if defined(ESP_FLAG_SHARED_SD_PIN) && ESP_FLAG_SHARED_SD_PIN != -1 - log_esp3d("SD shared disabled PIN %d with %d", ESP_FLAG_SHARED_SD_PIN, - !ESP_FLAG_SHARED_SD_VALUE); - digitalWrite(ESP_FLAG_SHARED_SD_PIN, !ESP_FLAG_SHARED_SD_VALUE); + if (ESP_SD::disableSharedSD()) { + log_esp3d("Shared SD disabled"); + } #endif // ESP_FLAG_SHARED_SD_PIN #if defined(ESP3DLIB_ENV) log_esp3d("Mount SD in Marlin"); diff --git a/esp3d/src/modules/filesystem/esp_sd.h b/esp3d/src/modules/filesystem/esp_sd.h index b1602757..c927ce1f 100644 --- a/esp3d/src/modules/filesystem/esp_sd.h +++ b/esp3d/src/modules/filesystem/esp_sd.h @@ -20,96 +20,93 @@ #ifndef _ESP_SD_H #define _ESP_SD_H -#include "../../include/esp3d_config.h" -#include "../../core/esp3doutput.h" #include +#include "../../core/esp3doutput.h" +#include "../../include/esp3d_config.h" + + #define ESP_SD_FS_HEADER "/SD" #define ESP_MAX_SD_OPENHANDLE 4 -class ESP_SDFile -{ -public: - ESP_SDFile(void * handle = nullptr, bool isdir =false, bool iswritemode = false, const char * path = nullptr); - ESP_SDFile(const char * name, const char * filename, bool isdir = true, size_t size =0); - ~ESP_SDFile(); - operator bool() const; - bool isDirectory(); - bool seek(uint32_t pos, uint8_t mode = ESP_SEEK_SET); - const char* name() const; - const char* shortname() const; - const char* filename() const; - void close(); - bool isOpen(); - ESP_SDFile & operator=(const ESP_SDFile & other); - size_t size(); - time_t getLastWrite(); - int available(); - size_t write(uint8_t i); - size_t write(const uint8_t *buf, size_t size); - int read(); - size_t read(uint8_t* buf, size_t size); - void flush(); - ESP_SDFile openNextFile(); -private: - String _dirlist; - bool _isdir; - bool _iswritemode; - int8_t _index; - String _filename; - String _name; - size_t _size; - time_t _lastwrite; +class ESP_SDFile { + public: + ESP_SDFile(void* handle = nullptr, bool isdir = false, + bool iswritemode = false, const char* path = nullptr); + ESP_SDFile(const char* name, const char* filename, bool isdir = true, + size_t size = 0); + ~ESP_SDFile(); + operator bool() const; + bool isDirectory(); + bool seek(uint32_t pos, uint8_t mode = ESP_SEEK_SET); + const char* name() const; + const char* shortname() const; + const char* filename() const; + void close(); + bool isOpen(); + ESP_SDFile& operator=(const ESP_SDFile& other); + size_t size(); + time_t getLastWrite(); + int available(); + size_t write(uint8_t i); + size_t write(const uint8_t* buf, size_t size); + int read(); + size_t read(uint8_t* buf, size_t size); + void flush(); + ESP_SDFile openNextFile(); + + private: + String _dirlist; + bool _isdir; + bool _iswritemode; + int8_t _index; + String _filename; + String _name; + size_t _size; + time_t _lastwrite; }; -class ESP_SD -{ -public: - static String & formatBytes (uint64_t bytes); - static bool begin(); - static bool accessFS(uint8_t FS = FS_SD); - static void releaseFS(uint8_t FS = FS_SD); - static uint8_t getFSType(const char * path=nullptr); - static void handle(); - static void end(); - static uint8_t getState(bool refresh=false); - static uint8_t setState(uint8_t state); - static void refreshStats(bool force = false); - static uint64_t totalBytes(bool refresh = false); - static uint64_t usedBytes(bool refresh = false); - static uint64_t freeBytes(bool refresh = false); - static uint maxPathLength(); - static const char * FilesystemName(); - static bool format(ESP3DOutput * output = nullptr); - static ESP_SDFile open(const char* path, uint8_t mode = ESP_FILE_READ); - static bool exists(const char* path); - static bool remove(const char *path); - static bool mkdir(const char *path); - static bool rmdir(const char *path); - static bool rename(const char *oldpath, const char *newpath); - static void closeAll(); - static uint8_t getSPISpeedDivider() - { - return _spi_speed_divider; - } - static bool setSPISpeedDivider(uint8_t speeddivider); +class ESP_SD { + public: + static String& formatBytes(uint64_t bytes); + static bool begin(); + static bool accessFS(uint8_t FS = FS_SD); + static void releaseFS(uint8_t FS = FS_SD); + static uint8_t getFSType(const char* path = nullptr); + static void handle(); + static void end(); + static uint8_t getState(bool refresh = false); + static uint8_t setState(uint8_t state); + static void refreshStats(bool force = false); + static uint64_t totalBytes(bool refresh = false); + static uint64_t usedBytes(bool refresh = false); + static uint64_t freeBytes(bool refresh = false); + static uint maxPathLength(); + static const char* FilesystemName(); + static bool format(ESP3DOutput* output = nullptr); + static ESP_SDFile open(const char* path, uint8_t mode = ESP_FILE_READ); + static bool exists(const char* path); + static bool remove(const char* path); + static bool mkdir(const char* path); + static bool rmdir(const char* path); + static bool rename(const char* oldpath, const char* newpath); + static void closeAll(); + static uint8_t getSPISpeedDivider() { return _spi_speed_divider; } + static bool setSPISpeedDivider(uint8_t speeddivider); #if SD_DEVICE_CONNECTION == ESP_SHARED_SD - static bool enableSharedSD(); - static bool isEnabled() - { - return _enabled; - } -#endif // SD_DEVICE_CONNECTION == ESP_SHARED_SD -private: - static bool _started; + static bool enableSharedSD(); + static bool disableSharedSD(); + static bool isEnabled() { return _enabled; } +#endif // SD_DEVICE_CONNECTION == ESP_SHARED_SD + private: + static bool _started; #if SD_DEVICE_CONNECTION == ESP_SHARED_SD - static bool _enabled; -#endif // SD_DEVICE_CONNECTION == ESP_SHARED_SD - static uint8_t _state; - static uint8_t _spi_speed_divider; - static bool _sizechanged; + static bool _enabled; +#endif // SD_DEVICE_CONNECTION == ESP_SHARED_SD + static uint8_t _state; + static uint8_t _spi_speed_divider; + static bool _sizechanged; }; - -#endif //_ESP_SD_H +#endif //_ESP_SD_H diff --git a/esp3d/src/modules/filesystem/sd/sd_native_esp32.cpp b/esp3d/src/modules/filesystem/sd/sd_native_esp32.cpp index 9cd2bb9d..198c7ef2 100644 --- a/esp3d/src/modules/filesystem/sd/sd_native_esp32.cpp +++ b/esp3d/src/modules/filesystem/sd/sd_native_esp32.cpp @@ -27,7 +27,6 @@ sd_native_esp32.cpp - ESP3D sd support class #include "FS.h" #include "SD.h" - // TBC: base frequency // or use (1000000 * ESP.getCpuFreqMHz()) #define ESP_SPI_FREQ 4000000 @@ -73,12 +72,6 @@ uint8_t ESP_SD::getState(bool refresh) { } bool ESP_SD::begin() { -#if (ESP_SD_CS_PIN != -1) || (ESP_SD_MISO_PIN != -1) || \ - (ESP_SD_MOSI_PIN != -1) || (ESP_SD_SCK_PIN != -1) - log_esp3d("Custom spi : CS: %d, Miso: %d, Mosi: %d, SCK: %d", ESP_SD_CS_PIN, - ESP_SD_MISO_PIN, ESP_SD_MOSI_PIN, ESP_SD_SCK_PIN); - SPI.begin(ESP_SD_SCK_PIN, ESP_SD_MISO_PIN, ESP_SD_MOSI_PIN, ESP_SD_CS_PIN); -#endif _started = true; _state = ESP_SDCARD_NOT_PRESENT; _spi_speed_divider = Settings_ESP3D::read_byte(ESP_SD_SPEED_DIV); @@ -95,7 +88,28 @@ bool ESP_SD::begin() { pinMode(ESP_FLAG_SHARED_SD_PIN, OUTPUT); digitalWrite(ESP_FLAG_SHARED_SD_PIN, !ESP_FLAG_SHARED_SD_VALUE); #endif // ESP_FLAG_SHARED_SD_PIN +#if SD_CARD_TYPE == ESP_FYSETC_WIFI_PRO_SDCARD +#if defined(ESP_SD_CS_SENSE) + log_esp3d("Setup SD sense pin %d", ESP_SD_CS_SENSE); + pinMode(ESP_SD_CS_SENSE, INPUT_PULLUP); +#endif // defined(ESP_SD_CS_SENSE) +#if defined(ESP_SD_POWER_PIN) && ESP_SD_POWER_PIN != -1 + log_esp3d("Setup SD power pin %d", ESP_SD_POWER_PIN); + pinMode(ESP_SD_POWER_PIN, OUTPUT); + digitalWrite(ESP_SD_POWER_PIN, ESP_POWER_SD_VALUE); +#endif // defined(ESP3D_POWER_SD_PIN) +#endif // SD_CARD_TYPE == ESP_FYSETC_WIFI_PRO_SDCARD #endif // SD_DEVICE_CONNECTION == ESP_SHARED_SD +#if (ESP_SD_CS_PIN != -1) || (ESP_SD_MISO_PIN != -1) || \ + (ESP_SD_MOSI_PIN != -1) || (ESP_SD_SCK_PIN != -1) + log_esp3d("Custom spi : CS: %d, Miso: %d, Mosi: %d, SCK: %d", ESP_SD_CS_PIN, + ESP_SD_MISO_PIN, ESP_SD_MOSI_PIN, ESP_SD_SCK_PIN); + SPI.begin(ESP_SD_SCK_PIN, ESP_SD_MISO_PIN, ESP_SD_MOSI_PIN, ESP_SD_CS_PIN); +#endif +#if SD_CARD_TYPE == ESP_FYSETC_WIFI_PRO_SDCARD && \ + SD_DEVICE_CONNECTION == ESP_SHARED_SD + SPI.end(); +#endif // SD_CARD_TYPE == ESP_FYSETC_WIFI_PRO_SDCARD return _started; } diff --git a/esp3d/src/modules/filesystem/sd/sd_sdfat2_esp32.cpp b/esp3d/src/modules/filesystem/sd/sd_sdfat2_esp32.cpp index 16baea9f..521a648b 100644 --- a/esp3d/src/modules/filesystem/sd/sd_sdfat2_esp32.cpp +++ b/esp3d/src/modules/filesystem/sd/sd_sdfat2_esp32.cpp @@ -20,6 +20,7 @@ sd_sdfat2_esp32.cpp - ESP3D sd support class #include "../../../include/esp3d_config.h" #if defined(ARDUINO_ARCH_ESP32) && defined(SD_DEVICE) #if (SD_DEVICE == ESP_SDFAT2) + #include #include @@ -151,10 +152,7 @@ uint8_t ESP_SD::getState(bool refresh) { } bool ESP_SD::begin() { -#if (ESP_SD_CS_PIN != -1) || (ESP_SD_MISO_PIN != -1) || \ - (ESP_SD_MOSI_PIN != -1) || (ESP_SD_SCK_PIN != -1) - SPI.begin(ESP_SD_SCK_PIN, ESP_SD_MISO_PIN, ESP_SD_MOSI_PIN, ESP_SD_CS_PIN); -#endif + pinMode(ESP_SD_CS_PIN, OUTPUT); _started = true; _state = ESP_SDCARD_NOT_PRESENT; _spi_speed_divider = Settings_ESP3D::read_byte(ESP_SD_SPEED_DIV); @@ -176,6 +174,11 @@ bool ESP_SD::begin() { digitalWrite(ESP_FLAG_SHARED_SD_PIN, !ESP_FLAG_SHARED_SD_VALUE); #endif // ESP_FLAG_SHARED_SD_PIN #endif // SD_DEVICE_CONNECTION == ESP_SHARED_SD +#if (ESP_SD_CS_PIN != -1) || (ESP_SD_MISO_PIN != -1) || \ + (ESP_SD_MOSI_PIN != -1) || (ESP_SD_SCK_PIN != -1) + SPI.begin(ESP_SD_SCK_PIN, ESP_SD_MISO_PIN, ESP_SD_MOSI_PIN, ESP_SD_CS_PIN); +#endif // SPI + return _started; }