Fixed edge-case bug in button press routing (polling instead of interrupt) and added logo to web interface
This commit is contained in:
parent
ca2e2e95bd
commit
663e1345ed
|
@ -70,7 +70,7 @@ enum UpdateStatus {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned long HW_GROUP = 1; // Changes with hardware changes that require software changes
|
unsigned long HW_GROUP = 1; // Changes with hardware changes that require software changes
|
||||||
unsigned long FW_VERSION = 1807020001; // Changes with each release; must always increase
|
unsigned long FW_VERSION = 1808070002; // Changes with each release; must always increase
|
||||||
unsigned long SP_VERSION = 0; // Loaded from SPIFFS; changed with each SPIFFS build; must always increase (uses timestamp as version)
|
unsigned long SP_VERSION = 0; // Loaded from SPIFFS; changed with each SPIFFS build; must always increase (uses timestamp as version)
|
||||||
|
|
||||||
// FW & SPIFFS update settings
|
// FW & SPIFFS update settings
|
||||||
|
@ -105,6 +105,7 @@ bool AP_ACTIVE = false;
|
||||||
|
|
||||||
// Variables for keeping track of the config button
|
// Variables for keeping track of the config button
|
||||||
volatile bool btnState = 0; // Current button state
|
volatile bool btnState = 0; // Current button state
|
||||||
|
bool oldBtnState = 0; // Previous button state
|
||||||
volatile bool btnPressed = 0; // Flag to check if the last button press has already been processed
|
volatile bool btnPressed = 0; // Flag to check if the last button press has already been processed
|
||||||
volatile unsigned long btnTimer = 0; // Start time of last button press (only while pressed)
|
volatile unsigned long btnTimer = 0; // Start time of last button press (only while pressed)
|
||||||
volatile unsigned long btnDur = 0; // Duration of the last button press (only while released)
|
volatile unsigned long btnDur = 0; // Duration of the last button press (only while released)
|
||||||
|
@ -220,6 +221,25 @@ void blinkLEDStatusLoop(unsigned int duration) {
|
||||||
delay(duration);
|
delay(duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handleConfigButton() {
|
||||||
|
// Read the config button state to determine if it has been pressed or released
|
||||||
|
btnState = !digitalRead(PIN_CONFIG);
|
||||||
|
// Calculate the last press duration
|
||||||
|
if (btnState) {
|
||||||
|
btnTimer = millis();
|
||||||
|
btnDur = 0;
|
||||||
|
} else {
|
||||||
|
btnDur = millis() - btnTimer;
|
||||||
|
btnTimer = 0;
|
||||||
|
// Discard presses <= 50ms
|
||||||
|
if (btnDur > 50) {
|
||||||
|
btnPressed = 1;
|
||||||
|
} else {
|
||||||
|
btnDur = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
WEB SERVER
|
WEB SERVER
|
||||||
*/
|
*/
|
||||||
|
@ -251,6 +271,7 @@ String formatPageBaseWithExtraHead(String content, String extraHead) {
|
||||||
page += extraHead;
|
page += extraHead;
|
||||||
page += "</head>";
|
page += "</head>";
|
||||||
page += "<body>";
|
page += "<body>";
|
||||||
|
page += "<img id='logo' src='/xatlabs_logo.png'>";
|
||||||
page += content;
|
page += content;
|
||||||
page += "</body>";
|
page += "</body>";
|
||||||
page += "</html>";
|
page += "</html>";
|
||||||
|
@ -392,22 +413,7 @@ void handle_update_running() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ISR_config() {
|
void ISR_config() {
|
||||||
// Read the config button state to determine if it has been pressed or released
|
handleConfigButton();
|
||||||
btnState = !digitalRead(PIN_CONFIG);
|
|
||||||
// Calculate the last press duration
|
|
||||||
if (btnState) {
|
|
||||||
btnTimer = millis();
|
|
||||||
btnDur = 0;
|
|
||||||
} else {
|
|
||||||
btnDur = millis() - btnTimer;
|
|
||||||
btnTimer = 0;
|
|
||||||
// Discard presses <= 50ms
|
|
||||||
if (btnDur > 50) {
|
|
||||||
btnPressed = 1;
|
|
||||||
} else {
|
|
||||||
btnDur = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -629,7 +635,7 @@ void setup() {
|
||||||
|
|
||||||
pinMode(PIN_STATUS, OUTPUT);
|
pinMode(PIN_STATUS, OUTPUT);
|
||||||
pinMode(PIN_CONFIG, INPUT_PULLUP);
|
pinMode(PIN_CONFIG, INPUT_PULLUP);
|
||||||
attachInterrupt(digitalPinToInterrupt(PIN_CONFIG), ISR_config, CHANGE);
|
//attachInterrupt(digitalPinToInterrupt(PIN_CONFIG), ISR_config, CHANGE);
|
||||||
|
|
||||||
#ifdef ARDUINO_OTA_ENABLED
|
#ifdef ARDUINO_OTA_ENABLED
|
||||||
ArduinoOTA.setHostname("WiFi-Shield");
|
ArduinoOTA.setHostname("WiFi-Shield");
|
||||||
|
@ -683,6 +689,7 @@ void setup() {
|
||||||
server.on("/update-running", handle_update_running);
|
server.on("/update-running", handle_update_running);
|
||||||
server.serveStatic("/main.css", SPIFFS, "/main.css");
|
server.serveStatic("/main.css", SPIFFS, "/main.css");
|
||||||
server.serveStatic("/favicon.ico", SPIFFS, "/favicon.ico");
|
server.serveStatic("/favicon.ico", SPIFFS, "/favicon.ico");
|
||||||
|
server.serveStatic("/xatlabs_logo.png", SPIFFS, "/xatlabs_logo.png");
|
||||||
server.begin();
|
server.begin();
|
||||||
|
|
||||||
#ifdef SERIAL_DEBUG
|
#ifdef SERIAL_DEBUG
|
||||||
|
@ -714,6 +721,12 @@ void loop() {
|
||||||
#endif
|
#endif
|
||||||
server.handleClient();
|
server.handleClient();
|
||||||
|
|
||||||
|
btnState = !digitalRead(PIN_CONFIG);
|
||||||
|
if (btnState != oldBtnState) {
|
||||||
|
oldBtnState = btnState;
|
||||||
|
handleConfigButton();
|
||||||
|
}
|
||||||
|
|
||||||
WiFiClient newClient = IBISServer.available();
|
WiFiClient newClient = IBISServer.available();
|
||||||
if (newClient) client = newClient;
|
if (newClient) client = newClient;
|
||||||
if (client) {
|
if (client) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"SPVersion": 1802082058}
|
{"SPVersion": 1808072004}
|
|
@ -5,4 +5,8 @@ body {
|
||||||
|
|
||||||
form {
|
form {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#logo {
|
||||||
|
display: block;
|
||||||
}
|
}
|
Binary file not shown.
After Width: | Height: | Size: 5.8 KiB |
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
|
@ -1 +1 @@
|
||||||
1807020001
|
1808070002
|
BIN
spiffs.bin
BIN
spiffs.bin
Binary file not shown.
|
@ -1 +1 @@
|
||||||
1802082058
|
1808072004
|
Loading…
Reference in New Issue