diff --git a/Grbl_Esp32/src/Config.h b/Grbl_Esp32/src/Config.h index 250ff3c8..c0496f1b 100644 --- a/Grbl_Esp32/src/Config.h +++ b/Grbl_Esp32/src/Config.h @@ -61,20 +61,10 @@ Some features should not be changed. See notes below. const int MAX_N_AXIS = 6; -// Number of axes defined (steppers, servos, etc) (valid range: 3 to 6) -// Even if your machine only uses less than the minimum of 3, you should select 3 -#ifndef N_AXIS -# define N_AXIS 3 -#endif - -#ifndef LIMIT_MASK -# define LIMIT_MASK B0 -#endif - // Serial baud rate // OK to change, but the ESP32 boot text is 115200, so you will not see that is your // serial monitor, sender, etc uses a different value than 115200 -#define BAUD_RATE 115200 +const int BAUD_RATE = 115200; //Connect to your local AP with these credentials //#define CONNECT_TO_SSID "your SSID" @@ -82,8 +72,6 @@ const int MAX_N_AXIS = 6; //CONFIGURE_EYECATCH_BEGIN (DO NOT MODIFY THIS LINE) #define ENABLE_BLUETOOTH // enable bluetooth -#define ENABLE_SD_CARD // enable use of SD Card to run jobs - #define ENABLE_WIFI //enable wifi #define WIFI_OR_BLUETOOTH @@ -153,7 +141,7 @@ static const uint8_t NHomingLocateCycle = 1; // Integer (1-128) // and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may // be stored and executed in order. These startup blocks would typically be used to set the GCode // parser state depending on user preferences. -#define N_STARTUP_LINE 2 // Integer (1-2) +// #define N_STARTUP_LINE 2 // Integer (1-2) // Number of floating decimal points printed by Grbl for certain value types. These settings are // determined by realistic and commonly observed values in CNC machines. For example, position diff --git a/Grbl_Esp32/src/MotionControl.cpp b/Grbl_Esp32/src/MotionControl.cpp index 5a1a1b0f..26431e26 100644 --- a/Grbl_Esp32/src/MotionControl.cpp +++ b/Grbl_Esp32/src/MotionControl.cpp @@ -547,14 +547,14 @@ void mc_reset() { // turn off all User I/O immediately sys_digital_all_off(); sys_analog_all_off(); -#ifdef ENABLE_SD_CARD + // do we need to stop a running SD job? if (config->_sdCard->get_state(false) == SDCard::State::BusyPrinting) { //Report print stopped report_feedback_message(Message::SdFileQuit); config->_sdCard->closeFile(); } -#endif + // Kill steppers only if in any motion state, i.e. cycle, actively holding, or homing. // NOTE: If steppers are kept enabled via the step idle delay setting, this also keeps // the steppers enabled by avoiding the go_idle call altogether, unless the motion state is diff --git a/Grbl_Esp32/src/Protocol.cpp b/Grbl_Esp32/src/Protocol.cpp index 892238c3..4a063d0c 100644 --- a/Grbl_Esp32/src/Protocol.cpp +++ b/Grbl_Esp32/src/Protocol.cpp @@ -158,7 +158,6 @@ void protocol_main_loop() { // --------------------------------------------------------------------------------- int c; for (;;) { -#ifdef ENABLE_SD_CARD auto sdcard = config->_sdCard; if (sdcard->_ready_next) { char fileLine[255]; @@ -172,7 +171,6 @@ void protocol_main_loop() { sdcard->closeFile(); // close file and clear SD ready/running flags } } -#endif // Receive one line of incoming serial data, as the data becomes available. // Filtering, if necessary, is done later in gc_execute_line(), so the // filtering is the same with serial and file input. diff --git a/Grbl_Esp32/src/Report.cpp b/Grbl_Esp32/src/Report.cpp index cd85bc2e..2f882370 100644 --- a/Grbl_Esp32/src/Report.cpp +++ b/Grbl_Esp32/src/Report.cpp @@ -233,18 +233,13 @@ void report_status_message(Error status_code, uint8_t client) { auto sdCard = config->_sdCard; switch (status_code) { case Error::Ok: // Error::Ok -#ifdef ENABLE_SD_CARD if (sdCard->get_state(false) == SDCard::State::BusyPrinting) { sdCard->_ready_next = true; // flag so system_execute_line() will send the next line } else { grbl_send(client, "ok\r\n"); } -#else - grbl_send(client, "ok\r\n"); -#endif break; default: -#ifdef ENABLE_SD_CARD // do we need to stop a running SD job? if (sdCard->get_state(false) == SDCard::State::BusyPrinting) { if (status_code == Error::GcodeUnsupportedCommand) { @@ -259,7 +254,6 @@ void report_status_message(Error status_code, uint8_t client) { } return; } -#endif // With verbose errors, the message text is displayed instead of the number. // Grbl 0.9 used to display the text, while Grbl 1.1 switched to the number. // Many senders support both formats. @@ -299,13 +293,11 @@ std::map MessageText = { // NOTE: For interfaces, messages are always placed within brackets. And if silent mode // is installed, the message number codes are less than zero. void report_feedback_message(Message message) { // ok to send to all clients -#if defined(ENABLE_SD_CARD) if (message == Message::SdFileQuit) { grbl_notifyf("SD print canceled", "Reset during SD file at line: %d", config->_sdCard->get_current_line_number()); info_serial("Reset during SD file at line: %d", config->_sdCard->get_current_line_number()); } else -#endif //ENABLE_SD_CARD { auto it = MessageText.find(message); if (it != MessageText.end()) { @@ -558,9 +550,7 @@ void report_build_info(const char* line, uint8_t client) { if (hasBluetooth()) { grbl_send(client, "B"); } -#ifdef ENABLE_SD_CARD grbl_send(client, "S"); -#endif #ifdef ENABLE_PARKING_OVERRIDE_CONTROL grbl_send(client, "R"); #endif @@ -766,14 +756,12 @@ void report_realtime_status(uint8_t client) { } } } -#ifdef ENABLE_SD_CARD if (config->_sdCard->get_state(false) == SDCard::State::BusyPrinting) { sprintf(temp, "|SD:%4.2f,", config->_sdCard->report_perc_complete()); strcat(status, temp); config->_sdCard->get_current_filename(temp); strcat(status, temp); } -#endif #ifdef REPORT_HEAP sprintf(temp, "|Heap:%d", esp.getHeapSize()); strcat(status, temp); diff --git a/Grbl_Esp32/src/Serial.cpp b/Grbl_Esp32/src/Serial.cpp index d976baf5..972a4c55 100644 --- a/Grbl_Esp32/src/Serial.cpp +++ b/Grbl_Esp32/src/Serial.cpp @@ -161,20 +161,16 @@ void clientCheckTask(void* pvParameters) { if (is_realtime_command(data)) { execute_realtime_command(static_cast(data), client); } else { -#if defined(ENABLE_SD_CARD) if (config->_sdCard->get_state(false) < SDCard::State::Busy) { -#endif //ENABLE_SD_CARD vTaskEnterCritical(&myMutex); client_buffer[client].write(data); vTaskExitCritical(&myMutex); -#if defined(ENABLE_SD_CARD) } else { if (data == '\r' || data == '\n') { grbl_sendf(client, "error %d\r\n", Error::AnotherInterfaceBusy); info_client(client, "SD card job running"); } } -#endif //ENABLE_SD_CARD } } // if something available WebUI::COMMANDS::handle(); diff --git a/Grbl_Esp32/src/WebUI/WebServer.cpp b/Grbl_Esp32/src/WebUI/WebServer.cpp index 659b8704..60937bd9 100644 --- a/Grbl_Esp32/src/WebUI/WebServer.cpp +++ b/Grbl_Esp32/src/WebUI/WebServer.cpp @@ -32,10 +32,8 @@ # include # include # include -# ifdef ENABLE_SD_CARD -# include -# include "../SDCard.h" -# endif +# include +# include "../SDCard.h" # include # include # include @@ -157,11 +155,9 @@ namespace WebUI { //web update _webserver->on("/updatefw", HTTP_ANY, handleUpdate, WebUpdateUpload); -# ifdef ENABLE_SD_CARD //Direct SD management _webserver->on("/upload", HTTP_ANY, handle_direct_SDFileList, SDFile_direct_upload); //_webserver->on("/SD", HTTP_ANY, handle_SDCARD); -# endif # ifdef ENABLE_CAPTIVE_PORTAL if (WiFi.getMode() == WIFI_AP) { @@ -278,7 +274,6 @@ namespace WebUI { String contentType = getContentType(path); String pathWithGz = path + ".gz"; -# ifdef ENABLE_SD_CARD if ((path.substring(0, 4) == "/SD/")) { auto sdCard = config->_sdCard; //remove /SD @@ -331,7 +326,6 @@ namespace WebUI { _webserver->send(404, "text/plain", content); return; } else -# endif if (SPIFFS.exists(pathWithGz) || SPIFFS.exists(path)) { if (SPIFFS.exists(pathWithGz)) { path = pathWithGz; @@ -1177,8 +1171,6 @@ namespace WebUI { COMMANDS::wait(0); } -# ifdef ENABLE_SD_CARD - //Function to delete not empty directory on SD card bool Web_Server::deleteRecursive(String path) { bool result = true; @@ -1551,7 +1543,6 @@ namespace WebUI { } COMMANDS::wait(0); } -# endif void Web_Server::handle() { static uint32_t timeout = millis(); diff --git a/Grbl_Esp32/src/WebUI/WebServer.h b/Grbl_Esp32/src/WebUI/WebServer.h index c4bd8745..16851390 100644 --- a/Grbl_Esp32/src/WebUI/WebServer.h +++ b/Grbl_Esp32/src/WebUI/WebServer.h @@ -89,11 +89,9 @@ namespace WebUI { static void WebUpdateUpload(); static void pushError(int code, const char* st, bool web_error = 500, uint16_t timeout = 1000); static void cancelUpload(); -#ifdef ENABLE_SD_CARD static void handle_direct_SDFileList(); static void SDFile_direct_upload(); static bool deleteRecursive(String path); -#endif }; extern Web_Server web_server; diff --git a/Grbl_Esp32/src/WebUI/WebSettings.cpp b/Grbl_Esp32/src/WebUI/WebSettings.cpp index feaafade..2f969022 100644 --- a/Grbl_Esp32/src/WebUI/WebSettings.cpp +++ b/Grbl_Esp32/src/WebUI/WebSettings.cpp @@ -193,11 +193,11 @@ namespace WebUI { webPrint(GRBL_VERSION_BUILD); webPrint(")" " # FW target:grbl-embedded # FW HW:"); -#ifdef ENABLE_SD_CARD - webPrint("Direct SD"); -#else - webPrint("No SD"); -#endif + if (config->_sdCard->get_state(false) != SDCard::State::NotPresent) { + webPrint("Direct SD"); + } else { + webPrint("No SD"); + } webPrint(" # primary sd:/sd # secondary sd:none # authentication:"); #ifdef ENABLE_AUTHENTICATION webPrint("yes"); @@ -631,7 +631,6 @@ namespace WebUI { return Error::Ok; } -#ifdef ENABLE_SD_CARD static Error openSDFile(char* parameter) { if (*parameter == '\0') { webPrintln("Missing file name!"); @@ -765,7 +764,6 @@ namespace WebUI { SD.end(); return Error::Ok; } -#endif void listDirLocalFS(fs::FS& fs, const char* dirname, uint8_t levels, uint8_t client) { //char temp_filename[128]; // to help filter by extension TODO: 128 needs a definition based on something @@ -842,7 +840,6 @@ namespace WebUI { static Error showSDStatus(char* parameter, AuthenticationLevel auth_level) { // ESP200 const char* resp = "No SD card"; -#ifdef ENABLE_SD_CARD switch (config->_sdCard->get_state(true)) { case SDCard::State::Idle: resp = "SD card detected"; @@ -853,9 +850,6 @@ namespace WebUI { default: resp = "Busy"; } -#else - resp = "SD card not enabled"; -#endif webPrintln(resp); return Error::Ok; } @@ -1052,12 +1046,10 @@ namespace WebUI { new WebCommand("P=position T=type V=value", WEBCMD, WA, "ESP401", "WebUI/Set", setWebSetting); new WebCommand(NULL, WEBCMD, WU, "ESP400", "WebUI/List", listSettings, anyState); #endif -#ifdef ENABLE_SD_CARD new WebCommand("path", WEBCMD, WU, "ESP221", "SD/Show", showSDFile); new WebCommand("path", WEBCMD, WU, "ESP220", "SD/Run", runSDFile); new WebCommand("file_or_directory_path", WEBCMD, WU, "ESP215", "SD/Delete", deleteSDObject); new WebCommand(NULL, WEBCMD, WU, "ESP210", "SD/List", listSDFiles); -#endif #ifdef WEB_COMMON new WebCommand(NULL, WEBCMD, WU, "ESP200", "SD/Status", showSDStatus); new WebCommand("STA|AP|BT|OFF", WEBCMD, WA, "ESP115", "Radio/State", setRadioState);