From 70e0d4ec6442e7e77474f6a6bfa904ad2d2752a6 Mon Sep 17 00:00:00 2001 From: Chrome Legion Date: Thu, 24 May 2018 19:28:51 -0700 Subject: [PATCH 1/4] Qrome - Added hostname to OTA listing --- printermonitor/printermonitor.ino | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/printermonitor/printermonitor.ino b/printermonitor/printermonitor.ino index 11e360d..0fbb79c 100644 --- a/printermonitor/printermonitor.ino +++ b/printermonitor/printermonitor.ino @@ -27,9 +27,9 @@ SOFTWARE. #include "Settings.h" -#define VERSION "1.3" +#define VERSION "1.4" -#define HOSTNAME "ESP8266-" +#define HOSTNAME "OctoMon-" #define CONFIG "/conf.txt" /* Useful Constants */ @@ -222,6 +222,7 @@ void setup() { else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed"); else if (error == OTA_END_ERROR) Serial.println("End Failed"); }); + ArduinoOTA.setHostname((const char *)hostname.c_str()); ArduinoOTA.begin(); } From e2bf33b86b84145c3e9353e8871906260cc873d2 Mon Sep 17 00:00:00 2001 From: Chrome Legion Date: Fri, 25 May 2018 22:19:28 -0700 Subject: [PATCH 2/4] Qrome - added support for the SH1106 display --- printermonitor/Settings.h | 11 +++++++++-- printermonitor/printermonitor.ino | 7 ++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/printermonitor/Settings.h b/printermonitor/Settings.h index 96adc95..e567ca2 100644 --- a/printermonitor/Settings.h +++ b/printermonitor/Settings.h @@ -43,7 +43,6 @@ SOFTWARE. #include "TimeClient.h" #include "OctoPrintClient.h" #include "FS.h" -#include "SSD1306Wire.h" #include "OLEDDisplayUi.h" //****************************** @@ -68,6 +67,7 @@ boolean DISPLAYCLOCK = true; // true = Show Clock when not printing / false = tu const int I2C_DISPLAY_ADDRESS = 0x3c; // I2C Address of your Display (usually 0x3c or 0x3d) const int SDA_PIN = D2; const int SCL_PIN = D5; +//#define DISPLAY_SH1106 // Uncomment this line to use the SH1106 display -- SSD1306 is used by default and is most common boolean ENABLE_OTA = true; // this will allow you to load firmware to the device over WiFi (see OTA for ESP8266) @@ -75,4 +75,11 @@ boolean ENABLE_OTA = true; // this will allow you to load firmware to the devic // End Settings //****************************** -String themeColor = "light-green"; // this can be changed later in the web interface. +String themeColor = "light-green"; // this can be changed later in the web interface. + +// Define the type of display you are using above and include the right lib +#if defined(DISPLAY_SH1106) + #include "SH1106Wire.h" +#else + #include "SSD1306Wire.h" +#endif diff --git a/printermonitor/printermonitor.ino b/printermonitor/printermonitor.ino index 0fbb79c..3c87a48 100644 --- a/printermonitor/printermonitor.ino +++ b/printermonitor/printermonitor.ino @@ -45,7 +45,12 @@ SOFTWARE. // Initialize the oled display for I2C_DISPLAY_ADDRESS // SDA_PIN and SCL_PIN -SSD1306Wire display(I2C_DISPLAY_ADDRESS, SDA_PIN, SCL_PIN); +#if defined(DISPLAY_SH1106) + SH1106Wire display(I2C_DISPLAY_ADDRESS, SDA_PIN, SCL_PIN); +#else + SSD1306Wire display(I2C_DISPLAY_ADDRESS, SDA_PIN, SCL_PIN); // this is the default +#endif + OLEDDisplayUi ui( &display ); void drawProgress(OLEDDisplay *display, int percentage, String label); From ba566776b422337a0ef1d78cab18fa1bc84cade3 Mon Sep 17 00:00:00 2001 From: Chrome Legion Date: Fri, 25 May 2018 22:23:17 -0700 Subject: [PATCH 3/4] Qrome - updated comments in Settings.h --- printermonitor/Settings.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/printermonitor/Settings.h b/printermonitor/Settings.h index e567ca2..1053fc3 100644 --- a/printermonitor/Settings.h +++ b/printermonitor/Settings.h @@ -50,26 +50,26 @@ SOFTWARE. //****************************** // OctoPrint Monitoring -- Monitor your 3D printer OctoPrint Server -String OctoPrintApiKey = ""; // ApiKey from your User Account on OctoPrint -String OctoPrintServer = ""; // IP or Address of your OctoPrint Server (DO NOT include http://) -int OctoPrintPort = 80; // the port you are running your OctoPrint server on (usually 80); +String OctoPrintApiKey = ""; // ApiKey from your User Account on OctoPrint +String OctoPrintServer = ""; // IP or Address of your OctoPrint Server (DO NOT include http://) +int OctoPrintPort = 80; // the port you are running your OctoPrint server on (usually 80); const int WEBSERVER_PORT = 80; // The port you can access this device on over HTTP const boolean WEBSERVER_ENABLED = true; // Device will provide a web interface via http://[ip]:[port]/ char* www_username = "admin"; // User account for the Web Interface char* www_password = "password"; // Password for the Web Interface float UtcOffset = -7; // Hour offset from GMT for your timezone -boolean IS_24HOUR = false; // 23:00 millitary 24 hour clock +boolean IS_24HOUR = false; // 23:00 millitary 24 hour clock int minutesBetweenDataRefresh = 60; -boolean DISPLAYCLOCK = true; // true = Show Clock when not printing / false = turn off display when not printing +boolean DISPLAYCLOCK = true; // true = Show Clock when not printing / false = turn off display when not printing // Display Settings const int I2C_DISPLAY_ADDRESS = 0x3c; // I2C Address of your Display (usually 0x3c or 0x3d) const int SDA_PIN = D2; const int SCL_PIN = D5; -//#define DISPLAY_SH1106 // Uncomment this line to use the SH1106 display -- SSD1306 is used by default and is most common +//#define DISPLAY_SH1106 // Uncomment this line to use the SH1106 display -- SSD1306 is used by default and is most common -boolean ENABLE_OTA = true; // this will allow you to load firmware to the device over WiFi (see OTA for ESP8266) +boolean ENABLE_OTA = true; // this will allow you to load firmware to the device over WiFi (see OTA for ESP8266) //****************************** // End Settings @@ -77,7 +77,7 @@ boolean ENABLE_OTA = true; // this will allow you to load firmware to the devic String themeColor = "light-green"; // this can be changed later in the web interface. -// Define the type of display you are using above and include the right lib +// SSD1306 is default - if DISPLAY_SH1106 is defined then it will use SH1106 #if defined(DISPLAY_SH1106) #include "SH1106Wire.h" #else From b7d9ad32ddd208d505ba65d52a434b26c7b86f7f Mon Sep 17 00:00:00 2001 From: Chrome Legion Date: Sun, 27 May 2018 17:27:58 -0700 Subject: [PATCH 4/4] Qrome - Added custom hostname and display screen --- printermonitor/Settings.h | 11 +++------- printermonitor/printermonitor.ino | 36 +++++++++++++++++-------------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/printermonitor/Settings.h b/printermonitor/Settings.h index 1053fc3..0c973b2 100644 --- a/printermonitor/Settings.h +++ b/printermonitor/Settings.h @@ -43,6 +43,8 @@ SOFTWARE. #include "TimeClient.h" #include "OctoPrintClient.h" #include "FS.h" +#include "SH1106Wire.h" +#include "SSD1306Wire.h" #include "OLEDDisplayUi.h" //****************************** @@ -75,11 +77,4 @@ boolean ENABLE_OTA = true; // this will allow you to load firmware to the de // End Settings //****************************** -String themeColor = "light-green"; // this can be changed later in the web interface. - -// SSD1306 is default - if DISPLAY_SH1106 is defined then it will use SH1106 -#if defined(DISPLAY_SH1106) - #include "SH1106Wire.h" -#else - #include "SSD1306Wire.h" -#endif +String themeColor = "light-green"; // this can be changed later in the web interface. diff --git a/printermonitor/printermonitor.ino b/printermonitor/printermonitor.ino index 3c87a48..cdf0628 100644 --- a/printermonitor/printermonitor.ino +++ b/printermonitor/printermonitor.ino @@ -29,7 +29,7 @@ SOFTWARE. #define VERSION "1.4" -#define HOSTNAME "OctoMon-" +#define HOSTNAME "OctMon-" #define CONFIG "/conf.txt" /* Useful Constants */ @@ -172,23 +172,15 @@ void setup() { //wifiManager.resetSettings(); wifiManager.setAPCallback(configModeCallback); - //or use this for auto generated name ESP + ChipID - wifiManager.autoConnect(); - - //Manual Wifi String hostname(HOSTNAME); hostname += String(ESP.getChipId(), HEX); - WiFi.hostname(hostname); - - int cnt = 0; - while (WiFi.status() != WL_CONNECTED) { - digitalWrite(externalLight, LOW); - delay(500); - Serial.print("."); - cnt++; - digitalWrite(externalLight, HIGH); + if (!wifiManager.autoConnect((const char *)hostname.c_str())) {// new addition + delay(3000); + WiFi.disconnect(true); + ESP.reset(); + delay(5000); } - + // You can change the transition that is used // SLIDE_LEFT, SLIDE_RIGHT, SLIDE_TOP, SLIDE_DOWN ui.setFrameAnimation(SLIDE_LEFT); @@ -558,7 +550,19 @@ void displayPrinterStatus() { void configModeCallback (WiFiManager *myWiFiManager) { Serial.println("Entered config mode"); - Serial.println(WiFi.softAPIP()); + Serial.println(WiFi.softAPIP()); + + display.clear(); + display.setTextAlignment(TEXT_ALIGN_CENTER); + display.setFont(ArialMT_Plain_10); + display.drawString(64, 0, "Wifi Manager"); + display.drawString(64, 10, "Please connect to AP"); + display.setFont(ArialMT_Plain_16); + display.drawString(64, 23, myWiFiManager->getConfigPortalSSID()); + display.setFont(ArialMT_Plain_10); + display.drawString(64, 42, "To setup Wifi connection"); + display.display(); + Serial.println("Wifi Manager"); Serial.println("Please connect to AP"); Serial.println(myWiFiManager->getConfigPortalSSID());