Compare commits
2 Commits
a5300f34e6
...
9d36a75875
| Author | SHA1 | Date | |
|---|---|---|---|
| 9d36a75875 | |||
| d2848e84e9 |
11
src/main.cpp
11
src/main.cpp
|
|
@ -48,6 +48,9 @@ unsigned long sendDeviceStatus() {
|
||||||
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
|
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
String httpData = "mac=" + WiFi.macAddress() + "&board=" + BOARD + "&firmware=" + BOARDFIRMWARE + "&service=" + SERVICE;
|
String httpData = "mac=" + WiFi.macAddress() + "&board=" + BOARD + "&firmware=" + BOARDFIRMWARE + "&service=" + SERVICE;
|
||||||
int httpResponseCode = http.POST(httpData);
|
int httpResponseCode = http.POST(httpData);
|
||||||
|
if ( DEBUG && (httpResponseCode != 200) ) {
|
||||||
|
Serial.println("Error sending status: " + String(httpResponseCode));
|
||||||
|
}
|
||||||
http.end();
|
http.end();
|
||||||
return millis();
|
return millis();
|
||||||
}
|
}
|
||||||
|
|
@ -66,15 +69,17 @@ unsigned long lastDebounceTime = 0;
|
||||||
bool actionState = false;
|
bool actionState = false;
|
||||||
bool debouncing = false;
|
bool debouncing = false;
|
||||||
void loop() {
|
void loop() {
|
||||||
if ( millis() > (lastStatusTime + STATUSINTERVAL) ) {
|
unsigned long currentMillis = millis();
|
||||||
|
if ( (currentMillis - lastStatusTime) >= STATUSINTERVAL ) {
|
||||||
lastStatusTime = sendDeviceStatus();
|
lastStatusTime = sendDeviceStatus();
|
||||||
|
currentMillis = lastStatusTime;
|
||||||
}
|
}
|
||||||
unsigned short buttonCheck = digitalRead(BUTTONPIN);
|
unsigned short buttonCheck = digitalRead(BUTTONPIN);
|
||||||
if ( buttonCheck != lastButtonState ) {
|
if ( buttonCheck != lastButtonState ) {
|
||||||
debouncing = true;
|
debouncing = true;
|
||||||
lastDebounceTime = millis();
|
lastDebounceTime = currentMillis;
|
||||||
}
|
}
|
||||||
if ( debouncing && (millis() >= (lastDebounceTime + DEBOUNCEMS)) ) {
|
if ( debouncing && (currentMillis >= (lastDebounceTime + DEBOUNCEMS)) ) {
|
||||||
debouncing = false;
|
debouncing = false;
|
||||||
if ( buttonCheck != buttonState ) {
|
if ( buttonCheck != buttonState ) {
|
||||||
buttonState = buttonCheck;
|
buttonState = buttonCheck;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user