mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-08-30 01:30:05 +02:00
Merge pull request #200 from luc-github/Devt
Add SPI pins customization support
This commit is contained in:
@@ -875,12 +875,64 @@ bool COMMANDS::execute_internal_command (int cmd, String cmd_params, level_authe
|
|||||||
int8_t state = get_sd_state(true);
|
int8_t state = get_sd_state(true);
|
||||||
if (state == SDCARD_IDLE) {
|
if (state == SDCARD_IDLE) {
|
||||||
listDir(SD, "/", 10, espresponse->client());
|
listDir(SD, "/", 10, espresponse->client());
|
||||||
|
String ssd = "[SD Free:" + ESPResponseStream::formatBytes(SD.totalBytes() - SD.usedBytes());
|
||||||
|
ssd +=" Used:" + ESPResponseStream::formatBytes(SD.usedBytes());
|
||||||
|
ssd +=" Total:" + ESPResponseStream::formatBytes(SD.totalBytes());
|
||||||
|
ssd +="]";
|
||||||
espresponse->println ("");
|
espresponse->println ("");
|
||||||
|
espresponse->println (ssd.c_str());
|
||||||
}
|
}
|
||||||
else espresponse->println ((state == SDCARD_NOT_PRESENT) ? "No SD card" : "Busy");
|
else espresponse->println ((state == SDCARD_NOT_PRESENT) ? "No SD card" : "Busy");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
//Delete SD Card file / directory
|
||||||
|
//[ESP215]<file/dir name>pwd=<user/admin password>
|
||||||
|
case 215:
|
||||||
|
{
|
||||||
|
if (!espresponse) return false;
|
||||||
|
#ifdef ENABLE_AUTHENTICATION
|
||||||
|
if (auth_type == LEVEL_GUEST) {
|
||||||
|
espresponse->println ("Error: Wrong authentication!");
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
parameter = get_param (cmd_params, "", true);
|
||||||
|
if (parameter.length() != 0) {
|
||||||
|
int8_t state = get_sd_state(true);
|
||||||
|
parameter.trim();
|
||||||
|
if (parameter[0] != '/'){
|
||||||
|
parameter = "/" + parameter;
|
||||||
|
}
|
||||||
|
if (state == SDCARD_IDLE) {
|
||||||
|
File file2del = SD.open(parameter.c_str());
|
||||||
|
if (file2del) {
|
||||||
|
if (file2del.isDirectory()) {
|
||||||
|
if (!SD.rmdir((char *)parameter.c_str())) {
|
||||||
|
espresponse->println ("Error: Cannot delete directory! Is directory empty?");
|
||||||
|
} else {
|
||||||
|
espresponse->println ("Directory deleted.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!SD.remove((char *)parameter.c_str())) {
|
||||||
|
espresponse->println ("Error: Cannot delete file!");
|
||||||
|
} else {
|
||||||
|
espresponse->println ("File deleted.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
espresponse->println ("Error: Cannot stat file!");
|
||||||
|
}
|
||||||
|
file2del.close();
|
||||||
|
} else {
|
||||||
|
espresponse->println ((state == SDCARD_NOT_PRESENT) ? "No SD card" : "Busy");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
espresponse->println ("Error: Missing file name!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
//print SD file
|
//print SD file
|
||||||
//[ESP220]<filename>
|
//[ESP220]<filename>
|
||||||
case 220:
|
case 220:
|
||||||
|
@@ -36,6 +36,14 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//Set your pine definition
|
||||||
|
//let -1 to use default board pin
|
||||||
|
#define GRBL_SPI_SS -1
|
||||||
|
#define GRBL_SPI_MOSI -1
|
||||||
|
#define GRBL_SPI_MISO -1
|
||||||
|
#define GRBL_SPI_SCK -1
|
||||||
|
//Set you frequency
|
||||||
|
#define GRBL_SPI_FREQ 4000000
|
||||||
|
|
||||||
#ifdef CPU_MAP_ESP32
|
#ifdef CPU_MAP_ESP32
|
||||||
// This is the CPU Map for the ESP32 CNC Controller R2
|
// This is the CPU Map for the ESP32 CNC Controller R2
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
// Grbl versioning system
|
// Grbl versioning system
|
||||||
#define GRBL_VERSION "1.1f"
|
#define GRBL_VERSION "1.1f"
|
||||||
#define GRBL_VERSION_BUILD "20190708"
|
#define GRBL_VERSION_BUILD "20190829"
|
||||||
|
|
||||||
//#include <sdkconfig.h>
|
//#include <sdkconfig.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
@@ -200,7 +200,7 @@ uint8_t get_sd_state(bool refresh)
|
|||||||
sd_state = SDCARD_NOT_PRESENT;
|
sd_state = 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()) {
|
if (SD.begin((GRBL_SPI_SS == -1)?SS:GRBL_SPI_SS, SPI, GRBL_SPI_FREQ)) {
|
||||||
if ( SD.cardSize() > 0 )sd_state = SDCARD_IDLE;
|
if ( SD.cardSize() > 0 )sd_state = SDCARD_IDLE;
|
||||||
}
|
}
|
||||||
return sd_state;
|
return sd_state;
|
||||||
|
@@ -43,6 +43,10 @@ void system_ini() // Renamed from system_init() due to conflict with esp32 files
|
|||||||
attachInterrupt(digitalPinToInterrupt(CONTROL_CYCLE_START_PIN), isr_control_inputs, CHANGE);
|
attachInterrupt(digitalPinToInterrupt(CONTROL_CYCLE_START_PIN), isr_control_inputs, CHANGE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
//customize pin definition if needed
|
||||||
|
#if (GRBL_SPI_SS != -1) || (GRBL_SPI_MISO != -1) || (GRBL_SPI_MOSI != -1) || (GRBL_SPI_SCK != -1)
|
||||||
|
SPI.begin(GRBL_SPI_SCK, GRBL_SPI_MISO, GRBL_SPI_MOSI, GRBL_SPI_SS);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1366,19 +1366,20 @@ void Web_Server::handle_direct_SDFileList()
|
|||||||
}
|
}
|
||||||
jsonfile+="],\"path\":\"";
|
jsonfile+="],\"path\":\"";
|
||||||
jsonfile+=path + "\",";
|
jsonfile+=path + "\",";
|
||||||
static uint32_t volTotal = 1;
|
|
||||||
static uint32_t volFree = 0;
|
|
||||||
jsonfile+="\"total\":\"";
|
jsonfile+="\"total\":\"";
|
||||||
String stotalspace,susedspace;
|
String stotalspace,susedspace;
|
||||||
//SDCard are in GB or MB but no less
|
//SDCard are in GB or MB but no less
|
||||||
totalspace = SD.totalBytes();
|
totalspace = SD.totalBytes();
|
||||||
usedspace = SD.usedBytes();
|
usedspace = SD.usedBytes();
|
||||||
stotalspace = ESPResponseStream::formatBytes(totalspace);
|
stotalspace = ESPResponseStream::formatBytes(totalspace);
|
||||||
susedspace = ESPResponseStream::formatBytes(usedspace);
|
susedspace = ESPResponseStream::formatBytes(usedspace+1);
|
||||||
|
|
||||||
uint32_t occupedspace = (volFree/volTotal)*100;
|
uint32_t occupedspace = 1;
|
||||||
|
uint32_t usedspace2 = usedspace/(1024*1024);
|
||||||
|
uint32_t totalspace2 = totalspace/(1024*1024);
|
||||||
|
occupedspace = (usedspace2 * 100)/totalspace2;
|
||||||
//minimum if even one byte is used is 1%
|
//minimum if even one byte is used is 1%
|
||||||
if ( (occupedspace <= 1) && (volTotal!=volFree)) {
|
if ( occupedspace <= 1) {
|
||||||
occupedspace=1;
|
occupedspace=1;
|
||||||
}
|
}
|
||||||
if (totalspace) {
|
if (totalspace) {
|
||||||
|
@@ -85,6 +85,9 @@ Reply: 81
|
|||||||
* Get SD Card Content
|
* Get SD Card Content
|
||||||
[ESP210] pwd=<user/admin password>
|
[ESP210] pwd=<user/admin password>
|
||||||
|
|
||||||
|
* Delete SD Card file / directory
|
||||||
|
[ESP215]<file/dir name>pwd=<user/admin password>
|
||||||
|
|
||||||
* Print SD file
|
* Print SD file
|
||||||
[ESP220] <Filename> pwd=<user/admin password>
|
[ESP220] <Filename> pwd=<user/admin password>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user