Merge pull request #7 from Qrome/1.4

1.4
pull/14/head V1.4
Qrome 2018-05-27 17:31:30 -07:00 committed by GitHub
commit 08335269d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 24 deletions

View File

@ -43,6 +43,7 @@ SOFTWARE.
#include "TimeClient.h" #include "TimeClient.h"
#include "OctoPrintClient.h" #include "OctoPrintClient.h"
#include "FS.h" #include "FS.h"
#include "SH1106Wire.h"
#include "SSD1306Wire.h" #include "SSD1306Wire.h"
#include "OLEDDisplayUi.h" #include "OLEDDisplayUi.h"
@ -51,25 +52,26 @@ SOFTWARE.
//****************************** //******************************
// OctoPrint Monitoring -- Monitor your 3D printer OctoPrint Server // OctoPrint Monitoring -- Monitor your 3D printer OctoPrint Server
String OctoPrintApiKey = ""; // ApiKey from your User Account on OctoPrint String OctoPrintApiKey = ""; // ApiKey from your User Account on OctoPrint
String OctoPrintServer = ""; // IP or Address of your OctoPrint Server (DO NOT include http://) 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); 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 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]/ 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_username = "admin"; // User account for the Web Interface
char* www_password = "password"; // Password for the Web Interface char* www_password = "password"; // Password for the Web Interface
float UtcOffset = -7; // Hour offset from GMT for your timezone 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; 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 // Display Settings
const int I2C_DISPLAY_ADDRESS = 0x3c; // I2C Address of your Display (usually 0x3c or 0x3d) const int I2C_DISPLAY_ADDRESS = 0x3c; // I2C Address of your Display (usually 0x3c or 0x3d)
const int SDA_PIN = D2; const int SDA_PIN = D2;
const int SCL_PIN = D5; 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) boolean ENABLE_OTA = true; // this will allow you to load firmware to the device over WiFi (see OTA for ESP8266)
//****************************** //******************************
// End Settings // End Settings

View File

@ -27,9 +27,9 @@ SOFTWARE.
#include "Settings.h" #include "Settings.h"
#define VERSION "1.3" #define VERSION "1.4"
#define HOSTNAME "ESP8266-" #define HOSTNAME "OctMon-"
#define CONFIG "/conf.txt" #define CONFIG "/conf.txt"
/* Useful Constants */ /* Useful Constants */
@ -45,7 +45,12 @@ SOFTWARE.
// Initialize the oled display for I2C_DISPLAY_ADDRESS // Initialize the oled display for I2C_DISPLAY_ADDRESS
// SDA_PIN and SCL_PIN // 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 ); OLEDDisplayUi ui( &display );
void drawProgress(OLEDDisplay *display, int percentage, String label); void drawProgress(OLEDDisplay *display, int percentage, String label);
@ -167,21 +172,13 @@ void setup() {
//wifiManager.resetSettings(); //wifiManager.resetSettings();
wifiManager.setAPCallback(configModeCallback); wifiManager.setAPCallback(configModeCallback);
//or use this for auto generated name ESP + ChipID
wifiManager.autoConnect();
//Manual Wifi
String hostname(HOSTNAME); String hostname(HOSTNAME);
hostname += String(ESP.getChipId(), HEX); hostname += String(ESP.getChipId(), HEX);
WiFi.hostname(hostname); if (!wifiManager.autoConnect((const char *)hostname.c_str())) {// new addition
delay(3000);
int cnt = 0; WiFi.disconnect(true);
while (WiFi.status() != WL_CONNECTED) { ESP.reset();
digitalWrite(externalLight, LOW); delay(5000);
delay(500);
Serial.print(".");
cnt++;
digitalWrite(externalLight, HIGH);
} }
// You can change the transition that is used // You can change the transition that is used
@ -222,6 +219,7 @@ void setup() {
else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed"); else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
else if (error == OTA_END_ERROR) Serial.println("End Failed"); else if (error == OTA_END_ERROR) Serial.println("End Failed");
}); });
ArduinoOTA.setHostname((const char *)hostname.c_str());
ArduinoOTA.begin(); ArduinoOTA.begin();
} }
@ -553,6 +551,18 @@ void displayPrinterStatus() {
void configModeCallback (WiFiManager *myWiFiManager) { void configModeCallback (WiFiManager *myWiFiManager) {
Serial.println("Entered config mode"); 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("Wifi Manager");
Serial.println("Please connect to AP"); Serial.println("Please connect to AP");
Serial.println(myWiFiManager->getConfigPortalSSID()); Serial.println(myWiFiManager->getConfigPortalSSID());