diff --git a/docs/Commands.txt b/docs/Commands.txt index 91b6b178..0f5736a9 100644 --- a/docs/Commands.txt +++ b/docs/Commands.txt @@ -70,6 +70,12 @@ 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 +* Output to esp screen status +[ESP214]pwd= + +* Touch Calibration +[ESP215][pwd=] + * Get full EEPROM settings content but do not give any passwords [ESP400] pwd= @@ -86,11 +92,11 @@ ESP_STA_IP_VALUE 100 //4 bytes xxx.xxx.xxx.xxx ESP_STA_MASK_VALUE 104 //4 bytes xxx.xxx.xxx.xxx ESP_STA_GATEWAY_VALUE 108 //4 bytes xxx.xxx.xxx.xxx ESP_BAUD_RATE 112 //4 bytes = int -ESP_STA_PHY_MODE 116 //1 byte = flag -ESP_SLEEP_MODE 117 //1 byte = flag +ESP_NOTIFICATION_TYPE 116 //1 byte = flag +ESP_CALIBRATION 117 //1 byte = flag ESP_AP_CHANNEL 118 //1 byte = flag -ESP_AP_AUTH_TYPE 119 //1 byte = flag -ESP_SSID_VISIBLE 120 //1 byte = flag +FREE 119 //1 byte = flag +FREE 120 //1 byte = flag ESP_HTTP_PORT 121 //4 bytes = int ESP_TELNET_PORT 125 //4 bytes = int ESP_OUTPUT_FLAG 129 //1 bytes = flag @@ -102,12 +108,14 @@ ESP_USER_PWD 197 //21 bytes 20+1 = string ; warning does not su ESP_AP_SSID 218 //33 bytes 32+1 = string ; warning does not support multibyte char like chinese ESP_AP_PASSWORD 251 //65 bytes 64 +1 = string ;warning does not support multibyte char like chinese ESP_AP_IP_VALUE 316 //4 bytes xxx.xxx.xxx.xxx - +ESP_BOOT_DELAY 320 //4 bytes xxx.xxx.xxx.xxx +ESP_WEBSOCKET_PORT 324 //4 bytes xxx.xxx.xxx.xxx ESP_HTTP_ON 328 //1 byte = flag ESP_TELNET_ON 329 //1 byte = flag -ESP_AP_PHY_MODE 330 //1 byte = flag +ESP_WEBSOCKET_ON 330 //1 byte = flag ESP_SD_SPEED_DIV 331 //1 byte = flag - +ESP_NOTIFICATION_TOKEN1 332 //64 bytes 63+1 = string ; warning does not support multibyte char like chinese +ESP_NOTIFICATION_TOKEN2 396 //64 bytes 63+1 = string ; warning does not support multibyte char like chinese ESP_DHT_TYPE 460//1 bytes = flag ESP_TARGET_FW 461 //1 bytes = flag ESP_TIMEZONE 462//1 bytes = flag @@ -120,6 +128,12 @@ ESP_PRIMARY_SD 851//1 bytes = flag ESP_SECONDARY_SD 852//1 bytes = flag ESP_DIRECT_SD_CHECK 853//1 bytes = flag ESP_SD_CHECK_UPDATE_AT_BOOT 854//1 bytes = flag +ESP_NOTIFICATION_SETTINGS 855//128 bytes 127+1 = string ; warning does not support multibyte char like chinese +ESP_CALIBRATION_1 983 +ESP_CALIBRATION_2 987 +ESP_CALIBRATION_3 991 +ESP_CALIBRATION_4 995 +ESP_CALIBRATION_5 999 *Get available AP list (limited to 30) output is JSON or plain text according parameter diff --git a/esp3d/configuration.h b/esp3d/configuration.h index d80c91d5..040cc3af 100644 --- a/esp3d/configuration.h +++ b/esp3d/configuration.h @@ -43,13 +43,13 @@ #define TELNET_FEATURE //WS_DATA_FEATURE: allow to connect serial from Websocket -#define WS_DATA_FEATURE +//#define WS_DATA_FEATURE //DISPLAY_DEVICE: allow screen output //OLED_I2C_SSD1306 1 //OLED_I2C_SSDSH1106 2 //TFT_SPI_ILI9341_320X240 3 -//#define DISPLAY_DEVICE OLED_I2C_SSD1306 +//#define DISPLAY_DEVICE TFT_SPI_ILI9341_320X240 #if defined (DISPLAY_DEVICE) //for ILI9143 edit User_Setup.h of TFT_eSPI library @@ -58,9 +58,16 @@ #define DISPLAY_I2C_PIN_RST 16 //comment if not applicable #define DISPLAY_I2C_ADDR 0x3c #define DISPLAY_FLIP_VERTICALY 1 //comment to disable +#define DISPLAY_TOUCH_DRIVER XPT2046_SPI #endif //DISPLAY_DEVICE + +//INPUT_DEVICE: allow input +//ROTARY_ENCODER 1 +//#define INPUT_DEVICE ROTARY_ENCODER + //DHT_DEVICE: send update of temperature / humidity based on DHT 11/22 //#define DHT_DEVICE + #ifdef DHT_DEVICE #define ESP3D_DHT_PIN 22 //USE_CELSIUS diff --git a/esp3d/src/core/commands.cpp b/esp3d/src/core/commands.cpp index 4059f8c6..08684b3c 100644 --- a/esp3d/src/core/commands.cpp +++ b/esp3d/src/core/commands.cpp @@ -65,6 +65,8 @@ void Commands::process(uint8_t * sbuf, size_t len, ESP3DOutput * output, level_a //check if current line is an [ESPXXX] command bool Commands::is_esp_command(uint8_t * sbuf, size_t len) { + //TODO + //M117 should be handled here and transfered to [ESP214] if it is an host if (len < 8) { return false; } @@ -337,6 +339,20 @@ bool Commands::execute_internal_command (int cmd, const char* cmd_params, level_ response = ESP210(cmd_params, auth_type, output); break; #endif //#ifdef DHT_DEVICE +#if defined (DISPLAY_DEVICE) + //Output to esp screen status + //[ESP214]pwd= + case 214: + response = ESP214(cmd_params, auth_type, output); + break; +#if defined(DISPLAY_TOUCH_DRIVER) + //Touch Calibration + //[ESP215][pwd=] + case 215: + response = ESP215(cmd_params, auth_type, output); + break; +#endif //DISPLAY_TOUCH_DRIVER +#endif //DISPLAY_DEVICE //Get full ESP3D settings //[ESP400] case 400: diff --git a/esp3d/src/core/commands.h b/esp3d/src/core/commands.h index 7ccfc774..bc70f0fd 100644 --- a/esp3d/src/core/commands.h +++ b/esp3d/src/core/commands.h @@ -78,6 +78,12 @@ public: #ifdef DIRECT_PIN_FEATURE bool ESP201(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output); #endif //DIRECT_PIN_FEATURE +#if defined (DISPLAY_DEVICE) + bool ESP214(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output); +#if defined(DISPLAY_TOUCH_DRIVER) + bool ESP215(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output); +#endif //DISPLAY_TOUCH_DRIVER +#endif //DISPLAY_DEVICE #ifdef DHT_DEVICE bool ESP210(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output); #endif //DHT_DEVICE diff --git a/esp3d/src/core/espcmd/ESP130.cpp b/esp3d/src/core/espcmd/ESP130.cpp index 7a072a59..73034b26 100644 --- a/esp3d/src/core/espcmd/ESP130.cpp +++ b/esp3d/src/core/espcmd/ESP130.cpp @@ -62,7 +62,6 @@ bool Commands::ESP130(const char* cmd_params, level_authenticate_type auth_type, output->printERROR ("Set failed!"); response = false; } - output->printMSG ("ok"); } } diff --git a/esp3d/src/core/espcmd/ESP214.cpp b/esp3d/src/core/espcmd/ESP214.cpp new file mode 100644 index 00000000..2ade3f7d --- /dev/null +++ b/esp3d/src/core/espcmd/ESP214.cpp @@ -0,0 +1,47 @@ +/* + ESP214.cpp - ESP3D command class + + Copyright (c) 2014 Luc Lebosse. All rights reserved. + + This library 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 library 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 library; 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 (DISPLAY_DEVICE) +#include "../commands.h" +#include "../esp3doutput.h" +#include "../settings_esp3d.h" +#include "../../modules/display/display.h" +#include "../../modules/authentication/authentication_service.h" +//Output to esp screen status +//[ESP214]pwd= +bool Commands::ESP214(const char* cmd_params, level_authenticate_type auth_type, ESP3DOutput * output) +{ + bool response = true; + String parameter; +#ifdef AUTHENTICATION_FEATURE + if (auth_type == LEVEL_GUEST) { + output->printERROR("Wrong authentication!", 401); + return false; + } +#else + (void)auth_type; +#endif //AUTHENTICATION_FEATURE + parameter = get_param (cmd_params, ""); + esp3d_display.SetStatus(parameter.c_str()); + output->printMSG ("ok"); + return response; +} + +#endif //DISPLAY_DEVICE diff --git a/esp3d/src/core/espcmd/ESP215.cpp b/esp3d/src/core/espcmd/ESP215.cpp new file mode 100644 index 00000000..a7069bc8 --- /dev/null +++ b/esp3d/src/core/espcmd/ESP215.cpp @@ -0,0 +1,57 @@ +/* + ESP215.cpp - ESP3D command class + + Copyright (c) 2014 Luc Lebosse. All rights reserved. + + This library 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 library 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 library; 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(DISPLAY_DEVICE) && defined(DISPLAY_TOUCH_DRIVER) +#include "../commands.h" +#include "../esp3doutput.h" +#include "../settings_esp3d.h" +#include "../../modules/authentication/authentication_service.h" +#include "../../modules/display/display.h" +//Touch Calibration +//[ESP215][pwd=] +bool Commands::ESP215(const char* cmd_params, level_authenticate_type auth_type, ESP3DOutput * output) +{ + bool response = true; + String parameter; +#ifdef AUTHENTICATION_FEATURE + if (auth_type == LEVEL_GUEST) { + output->printERROR("Wrong authentication!", 401); + return false; + } +#else + (void)auth_type; +#endif //AUTHENTICATION_FEATURE + parameter = get_param (cmd_params, ""); + //get + if (parameter.length() == 0) { + output->printMSG((Settings_ESP3D::read_byte(ESP_CALIBRATION)==1)?"Done":"Not done"); + } else { //set + parameter.toUpperCase(); + if (parameter == "CALIBRATE") { + output->printMSG("Please follow screen instructions"); + esp3d_display.startCalibration(); + } else { + output->printERROR("Invalid parameter!"); + } + } + return response; +} + +#endif //DISPLAY_DEVICE && DISPLAY_TOUCH_DRIVER diff --git a/esp3d/src/core/settings_esp3d.cpp b/esp3d/src/core/settings_esp3d.cpp index 4de79a68..369ad12d 100644 --- a/esp3d/src/core/settings_esp3d.cpp +++ b/esp3d/src/core/settings_esp3d.cpp @@ -26,7 +26,7 @@ #if ESP_SAVE_SETTINGS == SETTINGS_IN_EEPROM #include //EEPROM SIZE (Up to 4096) -#define EEPROM_SIZE 1024 //max is 1024 +#define EEPROM_SIZE 2048 //max is 2048 #endif //SETTINGS_IN_EEPROM #if defined (WIFI_FEATURE) || defined(ETH_FEATURE) @@ -115,6 +115,8 @@ #define DEFAULT_TELNET_PORT 23L #define DEFAULT_DHT_INTERVAL 30000L #define DEFAULT_BOOT_DELAY 10000L +#define DEFAULT_CALIBRATION_VALUE 0 +#define DEFAULT_CALIBRATION_DONE 0 #ifdef WIFI_FEATURE //default string values @@ -267,10 +269,6 @@ uint8_t Settings_ESP3D::get_default_byte_value(int pos) case ESP_SD_SPEED_DIV: res = DEFAULT_SDREADER_SPEED; break; -#endif //SDCARD_FEATURE - case ESP_TARGET_FW: - res = DEFAULT_FW; - break; case ESP_PRIMARY_SD: res = DEFAULT_PRIMARY_SD; break; @@ -283,6 +281,13 @@ uint8_t Settings_ESP3D::get_default_byte_value(int pos) case ESP_SD_CHECK_UPDATE_AT_BOOT: res = DEFAULT_SD_CHECK_UPDATE_AT_BOOT; break; + case ESP_IS_DIRECT_SD: + res = DEFAULT_IS_DIRECT_SD; + break; +#endif //SDCARD_FEATURE + case ESP_TARGET_FW: + res = DEFAULT_FW; + break; #ifdef TIMESTAMP_FEATURE case ESP_TIMEZONE: res = DEFAULT_TIME_ZONE; @@ -290,9 +295,6 @@ uint8_t Settings_ESP3D::get_default_byte_value(int pos) case ESP_TIME_IS_DST: res = DEFAULT_TIME_DST; break; - case ESP_IS_DIRECT_SD: - res = DEFAULT_IS_DIRECT_SD; - break; #endif //TIMESTAMP_FEATURE #if defined(DHT_DEVICE) @@ -300,6 +302,11 @@ uint8_t Settings_ESP3D::get_default_byte_value(int pos) res = DEFAULT_DHT_TYPE; break; #endif //DHT_DEVICE +#if defined(DISPLAY_DEVICE) && defined(DISPLAY_TOUCH_DRIVER) + case ESP_CALIBRATION: + res = DEFAULT_CALIBRATION_DONE; + break; +#endif // DISPLAY_DEVICE && DISPLAY_TOUCH_DRIVER default: res = DEFAULT_ESP_BYTE; } @@ -317,6 +324,15 @@ uint32_t Settings_ESP3D::get_default_int32_value(int pos) case ESP_BOOT_DELAY: res = DEFAULT_BOOT_DELAY; break; +#if defined(DISPLAY_DEVICE) && defined(DISPLAY_TOUCH_DRIVER) + case ESP_CALIBRATION_1: + case ESP_CALIBRATION_2: + case ESP_CALIBRATION_3: + case ESP_CALIBRATION_4: + case ESP_CALIBRATION_5: + res = DEFAULT_CALIBRATION_VALUE; + break; +#endif // DISPLAY_DEVICE && DISPLAY_TOUCH_DRIVER #if defined (WIFI_FEATURE) || defined (ETH_FEATURE) case ESP_AP_IP_VALUE: case ESP_STA_IP_VALUE: @@ -949,6 +965,17 @@ bool Settings_ESP3D::reset() #if ESP_SAVE_SETTINGS == SETTINGS_IN_EEPROM log_esp3d("clear EEPROM"); +#if defined(DISPLAY_DEVICE) && defined(DISPLAY_TOUCH_DRIVER) + //Calibration done (internal only) + Settings_ESP3D::write_byte(ESP_CALIBRATION,Settings_ESP3D::get_default_byte_value(ESP_CALIBRATION)); + //Calibration data (internal only) + Settings_ESP3D::write_uint32 (ESP_CALIBRATION_1, Settings_ESP3D::get_default_int32_value(ESP_CALIBRATION_1)); + Settings_ESP3D::write_uint32 (ESP_CALIBRATION_2, Settings_ESP3D::get_default_int32_value(ESP_CALIBRATION_2)); + Settings_ESP3D::write_uint32 (ESP_CALIBRATION_3, Settings_ESP3D::get_default_int32_value(ESP_CALIBRATION_3)); + Settings_ESP3D::write_uint32 (ESP_CALIBRATION_4, Settings_ESP3D::get_default_int32_value(ESP_CALIBRATION_4)); + Settings_ESP3D::write_uint32 (ESP_CALIBRATION_5, Settings_ESP3D::get_default_int32_value(ESP_CALIBRATION_5)); +#endif // DISPLAY_DEVICE && DISPLAY_TOUCH_DRIVER + #if defined (WIFI_FEATURE) || defined (BLUETOOTH_FEATURE) || defined (ETH_FEATURE) //Hostname Settings_ESP3D::write_string(ESP_HOSTNAME,Settings_ESP3D::get_default_string_value(ESP_HOSTNAME).c_str()); @@ -1057,6 +1084,7 @@ bool Settings_ESP3D::reset() //set version in settings if (res) { log_esp3d("Reset Setting Version"); + //Settings version (internal only) res = Settings_ESP3D::write_string(ESP_SETTINGS_VERSION, CURRENT_SETTINGS_VERSION); } return res; diff --git a/esp3d/src/core/settings_esp3d.h b/esp3d/src/core/settings_esp3d.h index 98bf95f8..641668f7 100644 --- a/esp3d/src/core/settings_esp3d.h +++ b/esp3d/src/core/settings_esp3d.h @@ -1,3 +1,4 @@ + /* settings_esp3d.h - settings esp3d functions class @@ -44,7 +45,7 @@ #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_SLEEP_MODE 117 //1 byte = flag +#define ESP_CALIBRATION 117 //1 byte = flag #define ESP_AP_CHANNEL 118 //1 byte = flag //#define ESP_AP_AUTH_TYPE 119 //1 byte = flag //#define ESP_SSID_VISIBLE 120 //1 byte = flag @@ -80,6 +81,12 @@ #define ESP_DIRECT_SD_CHECK 853//1 bytes = flag #define ESP_SD_CHECK_UPDATE_AT_BOOT 854//1 bytes = flag #define ESP_NOTIFICATION_SETTINGS 855//128 bytes 127+1 = string ; warning does not support multibyte char like chinese +#define ESP_CALIBRATION_1 983 +#define ESP_CALIBRATION_2 987 +#define ESP_CALIBRATION_3 991 +#define ESP_CALIBRATION_4 995 +#define ESP_CALIBRATION_5 999 + //Hidden password #define HIDDEN_PASSWORD "********" diff --git a/esp3d/src/include/defines.h b/esp3d/src/include/defines.h index f899ccff..6582688a 100644 --- a/esp3d/src/include/defines.h +++ b/esp3d/src/include/defines.h @@ -43,6 +43,12 @@ #define OLED_I2C_SSDSH1106 2 #define TFT_SPI_ILI9341_320X240 3 +//Touch +#define XPT2046_SPI 1 + +//Input +#define ROTARY_ENCODER 1 + //File systems #define ESP_SPIFFS_FILESYSTEM 1 #define ESP_FAT_FILESYSTEM 2 diff --git a/esp3d/src/include/version.h b/esp3d/src/include/version.h index 08dd7e5b..c87e60d0 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.a7" +#define FW_VERSION "3.0.0.a8" #define REPOSITORY "https://github.com/luc-github/ESP3D" #endif //_VERSION_ESP3D_H diff --git a/esp3d/src/modules/display/TFT_ILI9341_240X320.h b/esp3d/src/modules/display/TFT_ILI9341_240X320.h index 7284c8f5..10febf43 100644 --- a/esp3d/src/modules/display/TFT_ILI9341_240X320.h +++ b/esp3d/src/modules/display/TFT_ILI9341_240X320.h @@ -30,12 +30,16 @@ #define SSID_FG TFT_WHITE #define IP_FG TFT_WHITE #define STATUS_FG TFT_WHITE +#define CALIBRATION_BG TFT_BLACK +#define CALIBRATION_FG TFT_GREEN +#define CALIBRATION_CORNER TFT_RED //Fonts #define FONTSIGNAL 2 #define FONTSSID 2 -#define FONTIP 3 +#define FONTIP 2 #define FONTSTATUS 2 +#define FONTCALIBRATION 2 //Positions #define SIGNAL_X 320-34 @@ -61,6 +65,6 @@ #define IP_AREA_H 16 #define STATUS_AREA_X 0 -#define STATUS_AREA_Y 48 +#define STATUS_AREA_Y 223 #define STATUS_AREA_W 320 #define STATUS_AREA_H 16 diff --git a/esp3d/src/modules/display/display.cpp b/esp3d/src/modules/display/display.cpp index c07fab6a..88e11bb0 100644 --- a/esp3d/src/modules/display/display.cpp +++ b/esp3d/src/modules/display/display.cpp @@ -60,6 +60,40 @@ TFT_eSPI esp3d_screen = TFT_eSPI(); Display esp3d_display; +bool Display::startCalibration() +{ + bool res = false; +#if defined(DISPLAY_TOUCH_DRIVER) +#if DISPLAY_TOUCH_DRIVER == XPT2046_SPI + uint16_t calibrationData[5]; + clear_screen(); + //display instructions + uint size = getStringWidth("Touch corners as indicated"); + setTextFont(FONTCALIBRATION); + drawString("Touch corners as indicated", (SCREEN_WIDTH-size)/2, (SCREEN_HEIGHT-16)/2, CALIBRATION_FG); + esp3d_screen.calibrateTouch(calibrationData, CALIBRATION_CORNER, CALIBRATION_BG, 15); + res = true; + for (uint8_t i = 0; i < 5; i++) { + if(!Settings_ESP3D::write_uint32 (ESP_CALIBRATION_1+(4*i), calibrationData[i])) { + res= false; + } + } + if (!Settings_ESP3D::write_byte (ESP_CALIBRATION, 1)) { + res= false; + } + clear_screen(); + if(res) { + SetStatus("Calibration done"); + } else { + SetStatus("Calibration error"); + } + update_screen(true); +#endif //XPT2046_SPI + +#endif //DISPLAY_TOUCH_DRIVER + return res; +} + bool Display::splash() { //log_esp3d("Splash"); @@ -75,16 +109,22 @@ bool Display::splash() return false; } - -void Display::showStatus() +bool Display::showStatus(bool force) { //Display Status - String status = _status; + bool refresh_status = force; + static String status; + if (status != _status) { + status = _status; + refresh_status = true; + } + setTextFont(FONTSTATUS); uint16_t size = sizetoFitSpace(status.c_str(), STATUS_AREA_W); //check the need for resize if (size < status.length()) { static int status_shift = -1; + refresh_status = true; status+=" "; //log_esp3d("current %s", status.c_str()); if (status_shift > status.length()) { @@ -106,169 +146,232 @@ void Display::showStatus() } //log_esp3d("sized %s", status.c_str()); } - //clear area - fillRect(STATUS_AREA_X, STATUS_AREA_Y, STATUS_AREA_W, STATUS_AREA_H, SCREEN_BG); - drawString(status.c_str(), STATUS_AREA_X, STATUS_AREA_Y, STATUS_FG); + if (refresh_status) { + //clear area + fillRect(STATUS_AREA_X, STATUS_AREA_Y, STATUS_AREA_W, STATUS_AREA_H, SCREEN_BG); + drawString(status.c_str(), STATUS_AREA_X, STATUS_AREA_Y, STATUS_FG); + } + return refresh_status; } -bool Display::main_screen() +bool Display::display_signal(bool force) { - //log_esp3d("Mainscreen"); - //Signal - int sig = -1; - + static int sig = -1; + bool refresh_signal = false; + bool refresh_label = false; + static String label; #if defined (WIFI_FEATURE) if (WiFiConfig::started()) { - String ssid; + if (WiFi.getMode() == WIFI_AP) { - sig = 100; - ssid = WiFiConfig::AP_SSID(); + if (sig != 100) { + sig = 100; + refresh_signal = true; + } + if (label != WiFiConfig::AP_SSID()) { + label = WiFiConfig::AP_SSID(); + refresh_label = true; + } } else { if (WiFi.isConnected()) { - sig = WiFiConfig::getSignal (WiFi.RSSI ()); - ssid = WiFi.SSID(); + if (sig != WiFiConfig::getSignal (WiFi.RSSI ())) { + sig = WiFiConfig::getSignal (WiFi.RSSI ()); + refresh_signal = true; + } + if (label != WiFi.SSID()) { + label = WiFi.SSID(); + refresh_label = true; + } + } else { + if (sig != -1) { + sig = -1; + refresh_signal = true; + } + if (label != "") { + label = ""; + refresh_label = true; + } } } - //Display SSID setTextFont(FONTSSID); - uint16_t size = sizetoFitSpace(ssid.c_str(), SSID_AREA_W); + uint16_t size = sizetoFitSpace(label.c_str(), SSID_AREA_W); //check the need for resize - if (size < ssid.length()) { - static int ssid_shift = -1; - ssid+=" "; - //log_esp3d("current %s", ssid.c_str()); - if (ssid_shift > ssid.length()) { - ssid_shift = -1; + if (size < label.length()) { + refresh_label = true; + static int label_shift = -1; + label+=" "; + //log_esp3d("current %s", label.c_str()); + if (label_shift > label.length()) { + label_shift = -1; } - //log_esp3d("shift %d", ssid_shift); - if (ssid_shift > 0) { - ssid.remove(0,ssid_shift); + //log_esp3d("shift %d", label_shift); + if (label_shift > 0) { + label.remove(0,label_shift); } - //log_esp3d("shifted %s", ssid.c_str()); - size = sizetoFitSpace(ssid.c_str(), SSID_AREA_W); - //log_esp3d("size available %d existing %d",size, ssid.length()); - if (size < ssid.length()) { + //log_esp3d("shifted %s", label.c_str()); + size = sizetoFitSpace(label.c_str(), SSID_AREA_W); + //log_esp3d("size available %d existing %d",size, label.length()); + if (size < label.length()) { //cut - ssid = ssid.substring(0,size); - ssid_shift++; + label = label.substring(0,size); + label_shift++; } else { - ssid_shift = -1; + label_shift = -1; } - //log_esp3d("sized %s", ssid.c_str()); + //log_esp3d("sized %s", label.c_str()); + } + if (refresh_label || force) { + //clear area + fillRect(SSID_AREA_X, SSID_AREA_Y, SSID_AREA_W, SSID_AREA_H, SCREEN_BG); + drawString(label.c_str(), SSID_AREA_X, SSID_AREA_Y, SSID_FG); } - //clear area - fillRect(SSID_AREA_X, SSID_AREA_Y, SSID_AREA_W, SSID_AREA_H, SCREEN_BG); - drawString(ssid.c_str(), SSID_AREA_X, SSID_AREA_Y, SSID_FG); } #endif // WIFI_FEATURE + #if defined (ETH_FEATURE) if (EthConfig::started()) { - sig = -2; - setTextFont(FONTSSID); - //clear area - fillRect(SSID_AREA_X, SSID_AREA_Y, SSID_AREA_W, SSID_AREA_H, SCREEN_BG); + if (sig != -2) { + sig = -2; + refresh_signal = true; + } //display connection speed if(ETH.linkUp()) { - ssid = ETH.linkSpeed(); - ssid+= "Mbps"; - drawString(ssid.c_str(), SSID_AREA_X, SSID_AREA_Y, SSID_FG); + String tmp = ETH.linkSpeed(); + tmp+= "Mbps"; + if (label != tmp) { + label = tmp; + refresh_label = true; + } + } else { + if (label !="") { + label =""; + refresh_label = true; + } + } + if (refresh_label || force) { + setTextFont(FONTSSID); + //clear area + fillRect(SSID_AREA_X, SSID_AREA_Y, SSID_AREA_W, SSID_AREA_H, SCREEN_BG); + drawString(label.c_str(), SSID_AREA_X, SSID_AREA_Y, SSID_FG); } } #endif //ETH_FEATURE + #if defined (BLUETOOTH_FEATURE) if (bt_service.started()) { - sig = -3; + if (sig!=-3) { + sig = -3; + refresh_signal = true; + } + //Display hostname - String hostname = bt_service.hostname(); + if (label != bt_service.hostname()) { + refresh_label = true; + label = bt_service.hostname(); + } setTextFont(FONTSSID); - uint16_t size = sizetoFitSpace(hostname.c_str(), SSID_AREA_W); + uint16_t size = sizetoFitSpace(label.c_str(), SSID_AREA_W); //check the need for resize - if (size < hostname.length()) { - static int hostname_shift = -1; - hostname+=" "; + if (size < label.length()) { + refresh_label = true; + static int label_shift = -1; + label+=" "; //log_esp3d("current %s", hostname.c_str()); - if (hostname_shift > hostname.length()) { - hostname_shift = -1; + if (label_shift > label.length()) { + label_shift = -1; } - //log_esp3d("shift %d", hostname_shift); - if (hostname_shift > 0) { - hostname.remove(0,hostname_shift); + //log_esp3d("shift %d", label_shift); + if (label_shift > 0) { + label.remove(0,label_shift); } //log_esp3d("shifted %s", hostname.c_str()); - size = sizetoFitSpace(hostname.c_str(), SSID_AREA_W); + size = sizetoFitSpace(label.c_str(), SSID_AREA_W); //log_esp3d("size available %d existing %d",size, hostname.length()); - if (size < hostname.length()) { + if (size < label.length()) { //cut - hostname = hostname.substring(0,size); - hostname_shift++; + label = label.substring(0,size); + label_shift++; } else { - hostname_shift = -1; + label_shift = -1; } //log_esp3d("sized %s", hostname.c_str()); } - //clear area - fillRect(SSID_AREA_X, SSID_AREA_Y, SSID_AREA_W, SSID_AREA_H, SCREEN_BG); - if (hostname.length()>0) { - drawString(hostname.c_str(), SSID_AREA_X, SSID_AREA_Y, SSID_FG); + if( refresh_label || force) { + //clear area + fillRect(SSID_AREA_X, SSID_AREA_Y, SSID_AREA_W, SSID_AREA_H, SCREEN_BG); + if (label.length()>0) { + drawString(label.c_str(), SSID_AREA_X, SSID_AREA_Y, SSID_FG); + } } } #endif //BLUETOOTH_FEATURE - //set current font size - setTextFont(FONTSIGNAL); - fillRect(SIGNAL_X, SIGNAL_Y, SIGNAL_W, SIGNAL_H,SCREEN_BG); - fillRect(SIGNAL_ICON_X, SIGNAL_ICON_Y, SIGNAL_ICON_W, SIGNAL_ICON_H,SCREEN_BG); - String s; - if (sig > 0) { - //Signal % - s = String(sig); - s+="%"; - //Signal Icon according % + + if (refresh_signal || force) { + String s; + //set current font size + setTextFont(FONTSIGNAL); + fillRect(SIGNAL_X, SIGNAL_Y, SIGNAL_W, SIGNAL_H,SCREEN_BG); + fillRect(SIGNAL_ICON_X, SIGNAL_ICON_Y, SIGNAL_ICON_W, SIGNAL_ICON_H,SCREEN_BG); if (sig > 0) { - fillRect(SIGNAL_ICON_X, SIGNAL_ICON_Y + (SIGNAL_ICON_H * 0.6), SIGNAL_ICON_W_BAR, SIGNAL_ICON_H * 0.4, SIGNAL_FG); - } else { - drawRect(SIGNAL_ICON_X, SIGNAL_ICON_Y + (SIGNAL_ICON_H * 0.6), SIGNAL_ICON_W_BAR, SIGNAL_ICON_H * 0.4, SIGNAL_FG); + //Signal % + s = String(sig); + s+="%"; + //Signal Icon according % + if (sig > 0) { + fillRect(SIGNAL_ICON_X, SIGNAL_ICON_Y + (SIGNAL_ICON_H * 0.6), SIGNAL_ICON_W_BAR, SIGNAL_ICON_H * 0.4, SIGNAL_FG); + } else { + drawRect(SIGNAL_ICON_X, SIGNAL_ICON_Y + (SIGNAL_ICON_H * 0.6), SIGNAL_ICON_W_BAR, SIGNAL_ICON_H * 0.4, SIGNAL_FG); + } + + if (sig >= 25) { + fillRect(SIGNAL_ICON_X + SIGNAL_ICON_SPACER_X +SIGNAL_ICON_W_BAR, SIGNAL_ICON_Y + (SIGNAL_ICON_H * 0.4), SIGNAL_ICON_W_BAR, (SIGNAL_ICON_H * 0.6), SIGNAL_FG); + } else { + drawRect(SIGNAL_ICON_X + SIGNAL_ICON_SPACER_X + SIGNAL_ICON_W_BAR, SIGNAL_ICON_Y + (SIGNAL_ICON_H * 0.4), SIGNAL_ICON_W_BAR, (SIGNAL_ICON_H * 0.6), SIGNAL_FG); + } + + if (sig >= 50) { + fillRect(SIGNAL_ICON_X + (2*(SIGNAL_ICON_SPACER_X + SIGNAL_ICON_W_BAR)), SIGNAL_ICON_Y + (SIGNAL_ICON_H * 0.2), SIGNAL_ICON_W_BAR, (SIGNAL_ICON_H * 0.8), SIGNAL_FG); + } else { + drawRect(SIGNAL_ICON_X + (2*(SIGNAL_ICON_SPACER_X + SIGNAL_ICON_W_BAR)), SIGNAL_ICON_Y + (SIGNAL_ICON_H * 0.2), SIGNAL_ICON_W_BAR, (SIGNAL_ICON_H * 0.8), SIGNAL_FG); + } + + if (sig >= 75) { + fillRect(SIGNAL_ICON_X + (3*(SIGNAL_ICON_SPACER_X + SIGNAL_ICON_W_BAR)), SIGNAL_ICON_Y, SIGNAL_ICON_W_BAR, (SIGNAL_ICON_H), SIGNAL_FG); + } else { + drawRect(SIGNAL_ICON_X + (3*(SIGNAL_ICON_SPACER_X + SIGNAL_ICON_W_BAR)), SIGNAL_ICON_Y, SIGNAL_ICON_W_BAR, (SIGNAL_ICON_H), SIGNAL_FG); + } + } - - if (sig >= 25) { - fillRect(SIGNAL_ICON_X + SIGNAL_ICON_SPACER_X +SIGNAL_ICON_W_BAR, SIGNAL_ICON_Y + (SIGNAL_ICON_H * 0.4), SIGNAL_ICON_W_BAR, (SIGNAL_ICON_H * 0.6), SIGNAL_FG); - } else { - drawRect(SIGNAL_ICON_X + SIGNAL_ICON_SPACER_X + SIGNAL_ICON_W_BAR, SIGNAL_ICON_Y + (SIGNAL_ICON_H * 0.4), SIGNAL_ICON_W_BAR, (SIGNAL_ICON_H * 0.6), SIGNAL_FG); + //No signal / no connection + if (sig == -1) { + s = " X"; } - - if (sig >= 50) { - fillRect(SIGNAL_ICON_X + (2*(SIGNAL_ICON_SPACER_X + SIGNAL_ICON_W_BAR)), SIGNAL_ICON_Y + (SIGNAL_ICON_H * 0.2), SIGNAL_ICON_W_BAR, (SIGNAL_ICON_H * 0.8), SIGNAL_FG); - } else { - drawRect(SIGNAL_ICON_X + (2*(SIGNAL_ICON_SPACER_X + SIGNAL_ICON_W_BAR)), SIGNAL_ICON_Y + (SIGNAL_ICON_H * 0.2), SIGNAL_ICON_W_BAR, (SIGNAL_ICON_H * 0.8), SIGNAL_FG); + //Ethernet is connected + if (sig == -2) { + s = "Eth"; } - - if (sig >= 75) { - fillRect(SIGNAL_ICON_X + (3*(SIGNAL_ICON_SPACER_X + SIGNAL_ICON_W_BAR)), SIGNAL_ICON_Y, SIGNAL_ICON_W_BAR, (SIGNAL_ICON_H), SIGNAL_FG); - } else { - drawRect(SIGNAL_ICON_X + (3*(SIGNAL_ICON_SPACER_X + SIGNAL_ICON_W_BAR)), SIGNAL_ICON_Y, SIGNAL_ICON_W_BAR, (SIGNAL_ICON_H), SIGNAL_FG); + //BT is active + if (sig == -3) { + s = "BT"; } + //Show Connection type + drawString(s.c_str(), SIGNAL_X, SIGNAL_Y, SIGNAL_FG); + } + if (refresh_signal || refresh_label || force) { + return true; + } else { + return false; + } +} - } - //No signal / no connection - if (sig == -1) { - s = " X"; - } - //Ethernet is connected - if (sig == -2) { - s = "Eth"; - } - //BT is active - if (sig == -3) { - s = "BT"; - } - //Show Connection type - drawString(s.c_str(), SIGNAL_X, SIGNAL_Y, SIGNAL_FG); - - //IP - setTextFont(FONTIP); - fillRect(IP_AREA_X, IP_AREA_Y, IP_AREA_W, IP_AREA_H, SCREEN_BG); +bool Display::display_IP(bool force) +{ + bool refresh_label = force; + static String label; #if defined (WIFI_FEATURE) || defined (ETH_FEATURE) || defined (BLUETOOTH_FEATURE) if (NetConfig::started()) { + String s; switch(NetConfig::getMode()) { #if defined (WIFI_FEATURE) case ESP_WIFI_STA: @@ -292,14 +395,45 @@ bool Display::main_screen() s=""; break; } - if (s.length()>0) { - drawString(s.c_str(), IP_AREA_X, IP_AREA_Y, IP_FG); + if (s!= label) { + label = s; + refresh_label = true; + } + if (refresh_label) { + if (label.length()>0) { + setTextFont(FONTIP); + fillRect(IP_AREA_X, IP_AREA_Y, IP_AREA_W, IP_AREA_H, SCREEN_BG); + drawString(label.c_str(), IP_AREA_X, IP_AREA_Y, IP_FG); + } + } + } else { + if (label != "") { + label = ""; + refresh_label = true; + fillRect(IP_AREA_X, IP_AREA_Y, IP_AREA_W, IP_AREA_H, SCREEN_BG); } } #endif //WIFI_FEATURE || ETH_FEATURE || BLUETOOTH_FEATURE - //status - showStatus(); - return true; + return refresh_label; +} + +bool Display::main_screen(bool force) +{ + bool res = false; + if (display_signal(force)) { + res = true; + } + if (display_IP(force)) { + res = true; + } + if (showStatus(force)) { + res = true; + } + if (res) { + return true; + } else { + return false; + } } uint16_t Display::sizetoFitSpace(const char * string, uint16_t maxwidth) @@ -319,6 +453,7 @@ void Display::show_screenID(uint8_t screenID) { clear_screen(); _screenID = screenID; + update_screen(true); } Display::Display() @@ -329,6 +464,7 @@ Display::Display() _screenwidth = SCREEN_WIDTH; _screenheight = SCREEN_HEIGHT; } + Display::~Display() { end(); @@ -363,6 +499,15 @@ bool Display::begin() #endif //TFT_SPI_ILI9341_320X240 show_screenID(SPLASH_SCREEN); update_screen(); +#if defined(DISPLAY_TOUCH_DRIVER) + if(Settings_ESP3D::read_byte(ESP_CALIBRATION)==1) { + uint16_t calibrationData[5]; + for (uint8_t i = 0; i < 5; i++) { + calibrationData[i] = Settings_ESP3D::read_uint32 (ESP_CALIBRATION_1+(4*i)); + } + esp3d_screen.setTouch(calibrationData); + } +#endif //DISPLAY_TOUCH_DRIVER res = true; if (!res) { end(); @@ -370,6 +515,7 @@ bool Display::begin() _started = res; return _started; } + void Display::end() { if(!_started) { @@ -404,39 +550,40 @@ void Display::update_screen(bool force) if ( !ESP3DOutput::isOutput(ESP_SCREEN_CLIENT)) { return; } + static uint32_t last_update = millis(); bool need_update = force; - switch(_screenID) { - case SPLASH_SCREEN: - if (!_splash_displayed) { - need_update = splash(); + if (((millis()- last_update) > DISPLAY_REFRESH_TIME) || force) { + last_update = millis(); + + switch(_screenID) { + case SPLASH_SCREEN: + if (!_splash_displayed) { + need_update = splash(); + } + break; + case MAIN_SCREEN: + need_update = main_screen(force); + break; + default: + break; } - break; - case MAIN_SCREEN: - need_update = main_screen(); - break; - default: - break; - } - if (need_update) { + if (need_update) { #if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106 - esp3d_screen.display(); - //log_esp3d("Update display"); + esp3d_screen.display(); + //log_esp3d("Update display"); #endif //DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106 - Hal::wait(0); + Hal::wait(0); + } } } void Display::handle() { - static uint32_t last_update = millis(); if ( !ESP3DOutput::isOutput(ESP_SCREEN_CLIENT)) { return; } if (_started) { - if ((millis()- last_update) > DISPLAY_REFRESH_TIME) { - last_update = millis(); - update_screen(); - } + update_screen(); } } @@ -484,6 +631,7 @@ void Display::fillRect(int16_t x, int16_t y, int16_t width, int16_t height, int1 esp3d_screen.fillRect(x, y, width, height, color); #endif //TFT_SPI_ILI9341_240X320 } + void Display::setTextFont(uint8_t font) { #if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106 @@ -500,6 +648,7 @@ void Display::setTextFont(uint8_t font) esp3d_screen.setTextFont(font); #endif //TFT_SPI_ILI9341_240X320 } + void Display::drawString(const char *string, int32_t poX, int32_t poY, int16_t color) { if ( !ESP3DOutput::isOutput(ESP_SCREEN_CLIENT)) { @@ -530,8 +679,6 @@ void Display::drawXbm(int16_t x, int16_t y, int16_t width, int16_t height, int16 #endif //TFT_SPI_ILI9341_240X320 } - - void Display::drawXbm(int16_t x, int16_t y, int16_t width, int16_t height, uint16_t fgcolor, uint16_t bgcolor, const unsigned char *xbm) { if ( !ESP3DOutput::isOutput(ESP_SCREEN_CLIENT)) { diff --git a/esp3d/src/modules/display/display.h b/esp3d/src/modules/display/display.h index 5e9738ac..e0c9ec5d 100644 --- a/esp3d/src/modules/display/display.h +++ b/esp3d/src/modules/display/display.h @@ -20,6 +20,7 @@ #define SPLASH_SCREEN 0 #define MAIN_SCREEN 1 +#define CALIBRATION_SCREEN 2 #ifndef _DISPLAY_H #define _DISPLAY_H @@ -38,10 +39,13 @@ public: void clear_screen(); void progress(uint8_t v); void SetStatus(const char * status); + bool startCalibration(); private: - bool main_screen(); + bool main_screen(bool force = false); + bool display_signal(bool force = false); + bool display_IP(bool force = false); bool splash(); - void showStatus(); + bool showStatus(bool force = false); bool _started; uint8_t _screenID; bool _splash_displayed; diff --git a/esp3d/src/modules/http/http_server.cpp b/esp3d/src/modules/http/http_server.cpp index 9b459ad0..78884174 100644 --- a/esp3d/src/modules/http/http_server.cpp +++ b/esp3d/src/modules/http/http_server.cpp @@ -116,6 +116,9 @@ bool HTTP_Server::begin() { bool no_error = true; end(); + if (Settings_ESP3D::read_byte(ESP_HTTP_ON) !=1) { + return no_error; + } _port = Settings_ESP3D::read_uint32(ESP_HTTP_PORT); _webserver= new WEBSERVER(_port); if (!_webserver) { diff --git a/esp3d/src/modules/input/input.cpp b/esp3d/src/modules/input/input.cpp new file mode 100644 index 00000000..d0b80808 --- /dev/null +++ b/esp3d/src/modules/input/input.cpp @@ -0,0 +1,73 @@ +/* + input.cpp - input functions class + + Copyright (c) 2014 Luc Lebosse. All rights reserved. + + This library 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 library 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 library; 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 (INPUT_DEVICE) +#include "input.h" +#include "../../core/settings_esp3d.h" +#include "../../core/esp3doutput.h" + + +Input esp3d_input; + + +Input::Input() +{ + _started = false; +} + +Input::~Input() +{ + end(); +} + +bool Input::begin() +{ + bool res = true; + _started = false; + if (!res) { + end(); + } + _started = res; + return _started; +} + +void Input::end() +{ + if(!_started) { + return; + } + _started = false; +} + +bool Input::started() +{ + return _started; +} + + +void Input::handle() +{ + if (_started) { + + } +} + +#endif //INPUT_DEVICE diff --git a/esp3d/src/modules/input/input.h b/esp3d/src/modules/input/input.h new file mode 100644 index 00000000..ca081120 --- /dev/null +++ b/esp3d/src/modules/input/input.h @@ -0,0 +1,40 @@ +/* + input.h - input functions class + + Copyright (c) 2014 Luc Lebosse. All rights reserved. + + This library 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 library 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 library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#ifndef _INPUT_H +#define _INPUT_H + + +class Input +{ +public: + Input(); + ~Input(); + bool begin(); + void end(); + void handle(); + bool started(); +private: + bool _started; +}; + +extern Input esp3d_input; + +#endif //_INPUT_H + diff --git a/esp3d/src/modules/network/netservices.cpp b/esp3d/src/modules/network/netservices.cpp index c98ac24c..398ef22c 100644 --- a/esp3d/src/modules/network/netservices.cpp +++ b/esp3d/src/modules/network/netservices.cpp @@ -182,13 +182,16 @@ bool NetServices::begin() } } #endif //CAPTIVE_PORTAL_FEATURE + #ifdef HTTP_FEATURE if (!HTTP_Server::begin()) { res= false; output.printERROR("HTTP server failed"); } else { - String stmp = "HTTP server started port " + String(HTTP_Server::port()); - output.printMSG(stmp.c_str()); + if(HTTP_Server::started()) { + String stmp = "HTTP server started port " + String(HTTP_Server::port()); + output.printMSG(stmp.c_str()); + } } #endif //HTTP_FEATURE #ifdef TELNET_FEATURE @@ -196,8 +199,10 @@ bool NetServices::begin() res= false; output.printERROR("Telnet server failed"); } else { - String stmp = "Telnet server started port " + String(telnet_server.port()); - output.printMSG(stmp.c_str()); + if(telnet_server.started()) { + String stmp = "Telnet server started port " + String(telnet_server.port()); + output.printMSG(stmp.c_str()); + } } #endif //TELNET_FEATURE #ifdef WS_DATA_FEATURE @@ -221,7 +226,7 @@ bool NetServices::begin() #endif //MDNS_FEATURE #ifdef SSDP_FEATURE //SSDP service presentation - if(WiFi.getMode() != WIFI_AP) { + if(WiFi.getMode() != WIFI_AP && HTTP_Server::started()) { //Add specific for SSDP String stmp = String(Hal::getChipID()); SSDP.setSchemaURL ("description.xml"); @@ -229,13 +234,13 @@ bool NetServices::begin() SSDP.setName (hostname.c_str()); SSDP.setURL ("/"); SSDP.setDeviceType ("upnp:rootdevice"); - SSDP.setSerialNumber (stmp.c_str()); + // SSDP.setSerialNumber (stmp.c_str()); //Any customization could be here - SSDP.setModelName (ESP_MODEL_NAME); - SSDP.setModelURL (ESP_MODEL_URL); - SSDP.setModelNumber (ESP_MODEL_NUMBER); - SSDP.setManufacturer (ESP_MANUFACTURER_NAME); - SSDP.setManufacturerURL (ESP_MANUFACTURER_URL); + // SSDP.setModelName (ESP_MODEL_NAME); + // SSDP.setModelURL (ESP_MODEL_URL); + // SSDP.setModelNumber (ESP_MODEL_NUMBER); + // SSDP.setManufacturer (ESP_MANUFACTURER_NAME); + // SSDP.setManufacturerURL (ESP_MANUFACTURER_URL); SSDP.begin(); stmp = "SSDP started with '" + hostname + "'"; output.printMSG(stmp.c_str()); diff --git a/esp3d/src/modules/telnet/telnet_server.cpp b/esp3d/src/modules/telnet/telnet_server.cpp index b4684b21..7ce4f084 100644 --- a/esp3d/src/modules/telnet/telnet_server.cpp +++ b/esp3d/src/modules/telnet/telnet_server.cpp @@ -93,6 +93,9 @@ Telnet_Server::~Telnet_Server() bool Telnet_Server::begin(uint16_t port, bool debug) { end(); + if (Settings_ESP3D::read_byte(ESP_TELNET_ON) !=1) { + return true; + } //Get telnet port if (port == 0) { _port = Settings_ESP3D::read_uint32(ESP_TELNET_PORT); @@ -183,7 +186,7 @@ void Telnet_Server::handle() void Telnet_Server::flushbuffer() { - if (!_buffer || _started) { + if (!_buffer || !_started) { _buffer_size = 0; return; }