diff --git a/Grbl_Esp32/grbl_sd.cpp b/Grbl_Esp32/grbl_sd.cpp index 60c8aae5..3a1aaf3e 100644 --- a/Grbl_Esp32/grbl_sd.cpp +++ b/Grbl_Esp32/grbl_sd.cpp @@ -31,6 +31,7 @@ File myFile; char fileTypes[FILE_TYPE_COUNT][8] = {".NC", ".TXT", ".GCODE"}; // filter out files not of these types (s/b UPPERCASE) bool SD_ready_next = false; // Grbl has processed a line and is waiting for another + // attempt to mount the SD card bool sd_mount() { if(!SD.begin()){ @@ -82,6 +83,7 @@ void listDir(fs::FS &fs, const char * dirname, uint8_t levels){ boolean openFile(fs::FS &fs, const char * path){ myFile = fs.open(path); + if(!myFile){ report_status_message(STATUS_SD_FAILED_READ, CLIENT_SERIAL); return false; @@ -209,4 +211,14 @@ uint8_t set_sd_state(uint8_t flag){ return sd_state; } +void sd_get_current_filename(char* name) { + + if (myFile != NULL) + { + strcpy(name, myFile.name()); + } + else + name[0] = 0; +} + diff --git a/Grbl_Esp32/grbl_sd.h b/Grbl_Esp32/grbl_sd.h index 658b872d..2ebec755 100644 --- a/Grbl_Esp32/grbl_sd.h +++ b/Grbl_Esp32/grbl_sd.h @@ -47,4 +47,6 @@ boolean readFileLine(char *line); void readFile(fs::FS &fs, const char * path); float sd_report_perc_complete(); +void sd_get_current_filename(char* name); + #endif diff --git a/Grbl_Esp32/report.cpp b/Grbl_Esp32/report.cpp index b76d39ed..f6510aa9 100644 --- a/Grbl_Esp32/report.cpp +++ b/Grbl_Esp32/report.cpp @@ -710,7 +710,10 @@ void report_realtime_status(uint8_t client) #ifdef ENABLE_SD_CARD if (get_sd_state(false) == SDCARD_BUSY_PRINTING) { - sprintf(temp, "|SD:%4.2f", sd_report_perc_complete()); + sprintf(temp, "|SD:%4.2f,", sd_report_perc_complete()); + strcat(status, temp); + + sd_get_current_filename(temp); strcat(status, temp); } #endif diff --git a/Grbl_Esp32/spindle_control.cpp b/Grbl_Esp32/spindle_control.cpp index 0c1a32f2..2046e169 100644 --- a/Grbl_Esp32/spindle_control.cpp +++ b/Grbl_Esp32/spindle_control.cpp @@ -94,16 +94,9 @@ void spindle_set_state(uint8_t state, float rpm) } else { // TODO ESP32 Enable and direction control - #ifdef SPINDLE_DIR_PIN - if (state == SPINDLE_ENABLE_CW) { - digitalWrite(SPINDLE_DIR_PIN, 1); - } - else - { - digitalWrite(SPINDLE_DIR_PIN, 0); - } - #endif - + #ifdef SPINDLE_DIR_PIN + digitalWrite(SPINDLE_DIR_PIN, state == SPINDLE_ENABLE_CW); + #endif // NOTE: Assumes all calls to this function is when Grbl is not moving or must remain off. if (settings.flags & BITFLAG_LASER_MODE) {