add 128x64 display, doenst cost much, better view
This commit is contained in:
parent
7470ead144
commit
01b8043569
1 changed files with 45 additions and 8 deletions
|
@ -412,7 +412,7 @@ DHT dht(PINdht, DHTTYPE);
|
||||||
/*
|
/*
|
||||||
* Display Stuff
|
* Display Stuff
|
||||||
*/
|
*/
|
||||||
Adafruit_SSD1306 display = Adafruit_SSD1306(128, 32, &WIRE);
|
Adafruit_SSD1306 display = Adafruit_SSD1306(128, 64, &WIRE);
|
||||||
// 'CanGrow_Logo', 128x32px
|
// 'CanGrow_Logo', 128x32px
|
||||||
const unsigned char bmpCanGrow_Logo [] PROGMEM = {
|
const unsigned char bmpCanGrow_Logo [] PROGMEM = {
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
@ -629,6 +629,12 @@ void wipeEEPROM() {
|
||||||
if(wipeMsg == 0) {
|
if(wipeMsg == 0) {
|
||||||
Serial.println("Please release PIN_WIPE to erase all data saved in EEPROM");
|
Serial.println("Please release PIN_WIPE to erase all data saved in EEPROM");
|
||||||
Serial.println("LAST CHANCE TO KEEP THE DATA BY RESETTING NOW!!");
|
Serial.println("LAST CHANCE TO KEEP THE DATA BY RESETTING NOW!!");
|
||||||
|
|
||||||
|
display.setCursor(0,36);
|
||||||
|
display.println("RELEASE PIN_WIPE");
|
||||||
|
display.println("TO WIPE EEPROM");
|
||||||
|
display.display();
|
||||||
|
|
||||||
// increase i to show the serial message only once
|
// increase i to show the serial message only once
|
||||||
wipeMsg = 1;
|
wipeMsg = 1;
|
||||||
}
|
}
|
||||||
|
@ -637,6 +643,10 @@ void wipeEEPROM() {
|
||||||
|
|
||||||
// write a 0 to all 512 bytes of the EEPROM
|
// write a 0 to all 512 bytes of the EEPROM
|
||||||
Serial.print("wiping EEPROM... ");
|
Serial.print("wiping EEPROM... ");
|
||||||
|
display.setCursor(0,36);
|
||||||
|
display.println("Wiping EEPROM...");
|
||||||
|
display.println("Will restart in 3s");
|
||||||
|
display.display();
|
||||||
for (int i = 0; i < 512; i++) { EEPROM.write(i, 0); }
|
for (int i = 0; i < 512; i++) { EEPROM.write(i, 0); }
|
||||||
|
|
||||||
// commit everything to EEPROM and end here
|
// commit everything to EEPROM and end here
|
||||||
|
@ -666,7 +676,10 @@ void wipeEEPROM() {
|
||||||
bool loadEEPROM() {
|
bool loadEEPROM() {
|
||||||
Serial.println(":: loading EEPROM ::");
|
Serial.println(":: loading EEPROM ::");
|
||||||
|
|
||||||
|
display.setCursor(0,36);
|
||||||
|
display.fillRect(0,36,128,64-36, 0);
|
||||||
|
display.println("loading EEPROM");
|
||||||
|
display.display();
|
||||||
// read var WIFIssid from address 0, 32 byte long
|
// read var WIFIssid from address 0, 32 byte long
|
||||||
// read this first, because we decide on the ssid length (>0?) if
|
// read this first, because we decide on the ssid length (>0?) if
|
||||||
// we run in unconfigured AP mode, nor not
|
// we run in unconfigured AP mode, nor not
|
||||||
|
@ -815,6 +828,10 @@ bool loadEEPROM() {
|
||||||
}
|
}
|
||||||
Serial.println(":: EEPROM loaded ::");
|
Serial.println(":: EEPROM loaded ::");
|
||||||
|
|
||||||
|
display.setCursor(0,42);
|
||||||
|
display.println("EEPROM loaded");
|
||||||
|
display.display();
|
||||||
|
|
||||||
return(strlen(WIFIssid));
|
return(strlen(WIFIssid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -823,6 +840,12 @@ void wifiConnect() {
|
||||||
FirstRun = false;
|
FirstRun = false;
|
||||||
Serial.print("SSID: ");
|
Serial.print("SSID: ");
|
||||||
Serial.println(WIFIssid);
|
Serial.println(WIFIssid);
|
||||||
|
|
||||||
|
display.fillRect(0,36,128,64-36, 0);
|
||||||
|
display.setCursor(0,36);
|
||||||
|
display.println("Connecting to WiFi");
|
||||||
|
display.println(WIFIssid);
|
||||||
|
display.display();
|
||||||
|
|
||||||
// Start WiFi connection
|
// Start WiFi connection
|
||||||
WiFi.begin(WIFIssid, WIFIpassword);
|
WiFi.begin(WIFIssid, WIFIpassword);
|
||||||
|
@ -840,6 +863,11 @@ void wifiConnect() {
|
||||||
Serial.println(WiFi.localIP());
|
Serial.println(WiFi.localIP());
|
||||||
|
|
||||||
Serial.println(":: Getting time from NTP ::");
|
Serial.println(":: Getting time from NTP ::");
|
||||||
|
display.fillRect(0,36,128,64-36, 0);
|
||||||
|
display.setCursor(0,36);
|
||||||
|
display.println("Getting NTP time");
|
||||||
|
display.display();
|
||||||
|
|
||||||
timeClient.begin();
|
timeClient.begin();
|
||||||
timeClient.setTimeOffset(ntpOffset * 60 * 60);
|
timeClient.setTimeOffset(ntpOffset * 60 * 60);
|
||||||
timeClient.update();
|
timeClient.update();
|
||||||
|
@ -851,12 +879,8 @@ void wifiConnect() {
|
||||||
|
|
||||||
Serial.println(timeClient.getFormattedTime());
|
Serial.println(timeClient.getFormattedTime());
|
||||||
Serial.println(timeClient.getEpochTime());
|
Serial.println(timeClient.getEpochTime());
|
||||||
|
display.println(timeClient.getFormattedTime());
|
||||||
|
|
||||||
display.clearDisplay();
|
|
||||||
display.display();
|
display.display();
|
||||||
display.setCursor(0,0);
|
|
||||||
// display text
|
|
||||||
display.print("IP: ");
|
display.print("IP: ");
|
||||||
display.print(WiFi.localIP());
|
display.print(WiFi.localIP());
|
||||||
display.display();
|
display.display();
|
||||||
|
@ -864,6 +888,13 @@ void wifiConnect() {
|
||||||
|
|
||||||
void wifiAp() {
|
void wifiAp() {
|
||||||
Serial.println(":: Creating Accesspoint ::");
|
Serial.println(":: Creating Accesspoint ::");
|
||||||
|
|
||||||
|
display.fillRect(0,36,128,64-36, 0);
|
||||||
|
display.setCursor(0,36);
|
||||||
|
display.println("Creating AccessPoint");
|
||||||
|
display.println(APssid);
|
||||||
|
display.display();
|
||||||
|
|
||||||
FirstRun = true;
|
FirstRun = true;
|
||||||
// configure WiFi Access Point
|
// configure WiFi Access Point
|
||||||
WiFi.softAPConfig(WIFIip, WIFIgateway, WIFInetmask);
|
WiFi.softAPConfig(WIFIip, WIFIgateway, WIFInetmask);
|
||||||
|
@ -933,12 +964,18 @@ void setup() {
|
||||||
|
|
||||||
// initialise DHT11
|
// initialise DHT11
|
||||||
dht.begin(); //TODO: Do only, when configured
|
dht.begin(); //TODO: Do only, when configured
|
||||||
|
|
||||||
Serial.println("To wipe the EEPROM saved data, set D4 (PIN_WIPE) to LOW - NOW! (2 seconds left)");
|
Serial.println("To wipe the EEPROM saved data, set D4 (PIN_WIPE) to LOW - NOW! (2 seconds left)");
|
||||||
// wait a few seconds to let the user pull D4 down to wipe EEPROM
|
// wait a few seconds to let the user pull D4 down to wipe EEPROM
|
||||||
// and we can enjoy the boot screen meanwhile :p
|
// and we can enjoy the boot screen meanwhile :p
|
||||||
// meanwhile blink with the led onboad :)
|
// meanwhile blink with the led onboad :)
|
||||||
// 333 * 6 =~ 2 seconds
|
// 333 * 6 =~ 2 seconds
|
||||||
|
|
||||||
|
display.fillRect(0,36,128,64-36, 0);
|
||||||
|
display.setCursor(0,36);
|
||||||
|
display.println("To wipe EEPROM pull");
|
||||||
|
display.println("D4 (PIN_WIPE) to GND");
|
||||||
|
display.display();
|
||||||
|
|
||||||
for(byte i = 0; i <= 6 ; i++) {
|
for(byte i = 0; i <= 6 ; i++) {
|
||||||
if(i % 2) {
|
if(i % 2) {
|
||||||
|
|
Loading…
Reference in a new issue