diff --git a/docs/Commands.txt b/docs/Commands.txt index 4e655c04..d98a68a3 100644 --- a/docs/Commands.txt +++ b/docs/Commands.txt @@ -83,6 +83,9 @@ if PULLUP=YES set input pull up (for GPIO16(ESP8266) INPUT_PULLDOWN_16), if not if RAW=YES do not set pinmode just read value Flash pins (6~11) cannot be used +*Get/Set SD card Speed factor 1 2 4 6 8 16 32 +[ESP202]SPEED=pwd= + * Output to esp screen status [ESP214]pwd= @@ -225,4 +228,4 @@ rmdir / remove / mkdir / exists / create [ESP910][pwd=] *Get state / Set state of output message clients -[ESP910]=[pwd=] \ No newline at end of file +[ESP920]=[pwd=] diff --git a/esp3d/src/core/commands.cpp b/esp3d/src/core/commands.cpp index afa59ec6..e35d875e 100644 --- a/esp3d/src/core/commands.cpp +++ b/esp3d/src/core/commands.cpp @@ -414,6 +414,11 @@ bool Commands::execute_internal_command (int cmd, const char* cmd_params, level_ case 200: response = ESP200(cmd_params, auth_type, output); break; + //Get/Set SD card Speed factor 1 2 4 6 8 16 32 + //[ESP202]SPEED=pwd= + case 202: + response = ESP202(cmd_params, auth_type, output); + break; #ifdef SD_UPDATE_FEATURE //Get/Set SD Check at boot state which can be ON, OFF //[ESP402]pwd= diff --git a/esp3d/src/core/commands.h b/esp3d/src/core/commands.h index cedde69b..2a44ccdb 100644 --- a/esp3d/src/core/commands.h +++ b/esp3d/src/core/commands.h @@ -86,6 +86,7 @@ public: #endif //FTP_FEATURE #if defined (SD_DEVICE) bool ESP200(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output); + bool ESP202(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output); #ifdef SD_UPDATE_FEATURE bool ESP402(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output); #endif //SD_UPDATE_FEATURE diff --git a/esp3d/src/core/espcmd/ESP0.cpp b/esp3d/src/core/espcmd/ESP0.cpp index 0b6c9d57..405711eb 100644 --- a/esp3d/src/core/espcmd/ESP0.cpp +++ b/esp3d/src/core/espcmd/ESP0.cpp @@ -76,6 +76,9 @@ const char * help[]= {"[ESP] - display this help", #ifdef DIRECT_PIN_FEATURE "[ESP201](Pxxx) (Vxxx) (PULLUP=YES RAW=YES ANALOG=NO ANALOG_RANGE=255 CLEARCHANNELS=NO) - read / set pin value", #endif //DIRECT_PIN_FEATURE +#if defined (SD_DEVICE) + "[ESP202] - display / set SD Card SD card Speed factor (1 2 4 6 8 16 32)", +#endif //SD_DEVICE #ifdef SENSOR_DEVICE "[ESP210](type=NONE/xxx) (interval=xxxx) - display and read/set SENSOR info", #endif //SENSOR_DEVICE diff --git a/esp3d/src/core/espcmd/ESP202.cpp b/esp3d/src/core/espcmd/ESP202.cpp new file mode 100644 index 00000000..ab93b942 --- /dev/null +++ b/esp3d/src/core/espcmd/ESP202.cpp @@ -0,0 +1,65 @@ +/* + ESP202.cpp - ESP3D command class + + Copyright (c) 2014 Luc Lebosse. All rights reserved. + + This code is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with This code; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#include "../../include/esp3d_config.h" +#if defined (SD_DEVICE) +#include "../commands.h" +#include "../esp3doutput.h" +#include "../settings_esp3d.h" +#include "../../modules/filesystem/esp_sd.h" +#include "../../modules/authentication/authentication_service.h" +//Get/Set SD card Speed factor 1 2 4 6 8 16 32 +//[ESP202]SPEED=pwd= +bool Commands::ESP202(const char* cmd_params, level_authenticate_type auth_type, ESP3DOutput * output) +{ + (void)cmd_params; +#ifdef AUTHENTICATION_FEATURE + if (auth_type == LEVEL_GUEST) { + output->printERROR("Wrong authentication!", 401); + return false; + } +#else + (void)auth_type; +#endif //AUTHENTICATION_FEATURE + bool response = true; + String parameter; + parameter = get_param (cmd_params, ""); + //get + if (parameter.length() == 0) { + String r = "SPEED=" + String(Settings_ESP3D::read_byte (ESP_SD_SPEED_DIV)); + output->printMSG (r.c_str()); + } else { //set + parameter = get_param (cmd_params, "SPEED="); + if ((parameter == "1") || (parameter == "2") || (parameter == "4")|| (parameter == "6")|| (parameter == "8")|| (parameter == "16")|| (parameter == "32")) { + if (!Settings_ESP3D::write_byte (ESP_SD_SPEED_DIV, parameter.toInt())) { + response = false; + output->printERROR ("Set failed!"); + } else { + ESP_SD::setSPISpeedDivider(parameter.toInt()); + output->printMSG ("ok"); + } + } else { + output->printERROR ("Invalid parameter!"); + response = false; + } + } + return response; +} + +#endif //SD_DEVICE diff --git a/esp3d/src/core/hal.cpp b/esp3d/src/core/hal.cpp index 0b913e64..def23d35 100644 --- a/esp3d/src/core/hal.cpp +++ b/esp3d/src/core/hal.cpp @@ -195,6 +195,13 @@ bool Hal::begin() WiFi.enableSTA (false); WiFi.enableAP (false); WiFi.mode (WIFI_OFF); +#if SD_DEVICE_CONNECTION == ESP_SHARED_SD + #if defined(ESP_SD_DETECT_PIN) && ESP_SD_DETECT_PIN != -1 + pinMode (ESP_SD_DETECT_PIN, INPUT); +#endif + pinMode (ESP_FLAG_SHARED_SD_PIN, OUTPUT); + digitalWrite(ESP_FLAG_SHARED_SD_PIN, !ESP_FLAG_SHARED_SD_VALUE); +#endif //SD_DEVICE_CONNECTION == ESP_SHARED_SD return true; } diff --git a/esp3d/src/include/version.h b/esp3d/src/include/version.h index 55427849..e6da7218 100644 --- a/esp3d/src/include/version.h +++ b/esp3d/src/include/version.h @@ -22,7 +22,7 @@ #define _VERSION_ESP3D_H //version and sources location -#define FW_VERSION "3.0.0.a72" +#define FW_VERSION "3.0.0.a73" #define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0" #endif //_VERSION_ESP3D_H