Skip to content

Commit

Permalink
Merge pull request #7 from Qrome/1.4
Browse files Browse the repository at this point in the history
1.4
  • Loading branch information
Qrome authored May 28, 2018
2 parents 57bd817 + b7d9ad3 commit 0833526
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
14 changes: 8 additions & 6 deletions printermonitor/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ SOFTWARE.
#include "TimeClient.h"
#include "OctoPrintClient.h"
#include "FS.h"
#include "SH1106Wire.h"
#include "SSD1306Wire.h"
#include "OLEDDisplayUi.h"

Expand All @@ -51,25 +52,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

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
Expand Down
46 changes: 28 additions & 18 deletions printermonitor/printermonitor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ SOFTWARE.

#include "Settings.h"

#define VERSION "1.3"
#define VERSION "1.4"

#define HOSTNAME "ESP8266-"
#define HOSTNAME "OctMon-"
#define CONFIG "/conf.txt"

/* Useful Constants */
Expand All @@ -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);
Expand Down Expand Up @@ -167,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);
Expand Down Expand Up @@ -222,6 +219,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();
}

Expand Down Expand Up @@ -552,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());
Expand Down

0 comments on commit 0833526

Please sign in to comment.