Skip to content

Commit 329261a

Browse files
committed
Added display of the host name during start up.
Also can now be triggerent by a quick, < 2s, press of the button. Fixes #40
1 parent 177dd7a commit 329261a

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

src/emonesp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
#endif
5454

5555
#ifndef WIFI_BUTTON_AP_TIMEOUT
56-
#define WIFI_BUTTON_AP_TIMEOUT (5 * 1000)
56+
#define WIFI_BUTTON_AP_TIMEOUT (2 * 1000)
5757
#endif
5858

5959
#ifndef WIFI_BUTTON_FACTORY_RESET_TIMEOUT

src/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ void setup()
9191
DBUGF("After ota_setup: %d", HAL.getFreeHeap());
9292
#endif
9393

94+
lcd_display(F("OpenEVSE WiFI"), 0, 0, 0, LCD_CLEAR_LINE);
95+
lcd_display(currentfirmware, 0, 1, 5 * 1000, LCD_CLEAR_LINE);
96+
9497
rapiSender.setOnEvent(on_rapi_event);
9598
rapiSender.enableSequenceId(0);
9699

@@ -120,13 +123,10 @@ loop() {
120123
if(OPENEVSE_STATE_STARTING != state &&
121124
OPENEVSE_STATE_INVALID != state)
122125
{
126+
123127
// Read initial state from OpenEVSE
124128
if (rapi_read == 0)
125129
{
126-
lcd_display(F("OpenEVSE WiFI"), 0, 0, 0, LCD_CLEAR_LINE);
127-
lcd_display(currentfirmware, 0, 1, 5 * 1000, LCD_CLEAR_LINE);
128-
lcd_loop();
129-
130130
DBUGLN("first read RAPI values");
131131
handleRapiRead(); //Read all RAPI values
132132
rapi_read=1;

src/net_manager.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,15 @@ static void net_wifi_start()
134134
}
135135
}
136136

137+
static void display_state()
138+
{
139+
lcd_display(F("Hostname:"), 0, 0, 0, LCD_CLEAR_LINE);
140+
lcd_display(esp_hostname.c_str(), 0, 1, 5000, LCD_CLEAR_LINE);
141+
142+
lcd_display(F("IP Address:"), 0, 0, 0, LCD_CLEAR_LINE);
143+
lcd_display(ipaddress.c_str(), 0, 1, 5000, LCD_CLEAR_LINE);
144+
}
145+
137146
static void net_connected(IPAddress myAddress)
138147
{
139148
#ifdef WIFI_LED
@@ -146,8 +155,8 @@ static void net_connected(IPAddress myAddress)
146155
ipaddress = tmpStr;
147156
DEBUG.print("Connected, IP: ");
148157
DEBUG.println(tmpStr);
149-
lcd_display(F("IP Address"), 0, 0, 0, LCD_CLEAR_LINE);
150-
lcd_display(tmpStr, 0, 1, 5000, LCD_CLEAR_LINE);
158+
159+
display_state();
151160

152161
Mongoose.ipConfigChanged();
153162
}
@@ -426,6 +435,8 @@ net_loop()
426435
DBUGF("Button released");
427436
if(millis() > wifiButtonTimeOut + WIFI_BUTTON_AP_TIMEOUT) {
428437
startAP();
438+
} else {
439+
display_state();
429440
}
430441
}
431442
}
@@ -434,9 +445,8 @@ net_loop()
434445
{
435446
DBUGLN("*** Factory Reset ***");
436447

437-
lcd_display(F("Factory Reset"), 0, 0, 0, LCD_CLEAR_LINE);
438-
lcd_display(F(""), 0, 1, 10 * 1000, LCD_CLEAR_LINE);
439-
lcd_loop();
448+
lcd_display(F("Factory Reset"), 0, 0, 0, LCD_CLEAR_LINE | LCD_DISPLAY_NOW);
449+
lcd_display(F(""), 0, 1, 10 * 1000, LCD_CLEAR_LINE | LCD_DISPLAY_NOW);
440450

441451
delay(1000);
442452

@@ -448,9 +458,8 @@ net_loop()
448458
}
449459
else if(false == apMessage && LOW == wifiButtonState && millis() > wifiButtonTimeOut + WIFI_BUTTON_AP_TIMEOUT)
450460
{
451-
lcd_display(F("Access Point"), 0, 0, 0, LCD_CLEAR_LINE);
452-
lcd_display(F(""), 0, 1, 10 * 1000, LCD_CLEAR_LINE);
453-
lcd_loop();
461+
lcd_display(F("Access Point"), 0, 0, 0, LCD_CLEAR_LINE | LCD_DISPLAY_NOW);
462+
lcd_display(F(""), 0, 1, 10 * 1000, LCD_CLEAR_LINE | LCD_DISPLAY_NOW);
454463
apMessage = true;
455464
}
456465

0 commit comments

Comments
 (0)