add 128x64 display, doenst cost much, better view

This commit is contained in:
Marcus 2024-04-22 01:58:31 +02:00
parent 7470ead144
commit 01b8043569
1 changed files with 45 additions and 8 deletions

View File

@ -412,7 +412,7 @@ DHT dht(PINdht, DHTTYPE);
/*
* Display Stuff
*/
Adafruit_SSD1306 display = Adafruit_SSD1306(128, 32, &WIRE);
Adafruit_SSD1306 display = Adafruit_SSD1306(128, 64, &WIRE);
// 'CanGrow_Logo', 128x32px
const unsigned char bmpCanGrow_Logo [] PROGMEM = {
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) {
Serial.println("Please release PIN_WIPE to erase all data saved in EEPROM");
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
wipeMsg = 1;
}
@ -637,6 +643,10 @@ void wipeEEPROM() {
// write a 0 to all 512 bytes of the 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); }
// commit everything to EEPROM and end here
@ -666,7 +676,10 @@ void wipeEEPROM() {
bool loadEEPROM() {
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 this first, because we decide on the ssid length (>0?) if
// we run in unconfigured AP mode, nor not
@ -815,6 +828,10 @@ bool loadEEPROM() {
}
Serial.println(":: EEPROM loaded ::");
display.setCursor(0,42);
display.println("EEPROM loaded");
display.display();
return(strlen(WIFIssid));
}
@ -823,6 +840,12 @@ void wifiConnect() {
FirstRun = false;
Serial.print("SSID: ");
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
WiFi.begin(WIFIssid, WIFIpassword);
@ -840,6 +863,11 @@ void wifiConnect() {
Serial.println(WiFi.localIP());
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.setTimeOffset(ntpOffset * 60 * 60);
timeClient.update();
@ -851,12 +879,8 @@ void wifiConnect() {
Serial.println(timeClient.getFormattedTime());
Serial.println(timeClient.getEpochTime());
display.clearDisplay();
display.println(timeClient.getFormattedTime());
display.display();
display.setCursor(0,0);
// display text
display.print("IP: ");
display.print(WiFi.localIP());
display.display();
@ -864,6 +888,13 @@ void wifiConnect() {
void wifiAp() {
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;
// configure WiFi Access Point
WiFi.softAPConfig(WIFIip, WIFIgateway, WIFInetmask);
@ -933,12 +964,18 @@ void setup() {
// initialise DHT11
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)");
// wait a few seconds to let the user pull D4 down to wipe EEPROM
// and we can enjoy the boot screen meanwhile :p
// meanwhile blink with the led onboad :)
// 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++) {
if(i % 2) {