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");
|
||||
String httpData = "mac=" + WiFi.macAddress() + "&board=" + BOARD + "&firmware=" + BOARDFIRMWARE + "&service=" + SERVICE;
|
||||
int httpResponseCode = http.POST(httpData);
|
||||
if ( DEBUG && (httpResponseCode != 200) ) {
|
||||
Serial.println("Error sending status: " + String(httpResponseCode));
|
||||
}
|
||||
http.end();
|
||||
return millis();
|
||||
}
|
||||
|
|
@ -66,15 +69,17 @@ unsigned long lastDebounceTime = 0;
|
|||
bool actionState = false;
|
||||
bool debouncing = false;
|
||||
void loop() {
|
||||
if ( millis() > (lastStatusTime + STATUSINTERVAL) ) {
|
||||
unsigned long currentMillis = millis();
|
||||
if ( (currentMillis - lastStatusTime) >= STATUSINTERVAL ) {
|
||||
lastStatusTime = sendDeviceStatus();
|
||||
currentMillis = lastStatusTime;
|
||||
}
|
||||
unsigned short buttonCheck = digitalRead(BUTTONPIN);
|
||||
if ( buttonCheck != lastButtonState ) {
|
||||
debouncing = true;
|
||||
lastDebounceTime = millis();
|
||||
lastDebounceTime = currentMillis;
|
||||
}
|
||||
if ( debouncing && (millis() >= (lastDebounceTime + DEBOUNCEMS)) ) {
|
||||
if ( debouncing && (currentMillis >= (lastDebounceTime + DEBOUNCEMS)) ) {
|
||||
debouncing = false;
|
||||
if ( buttonCheck != buttonState ) {
|
||||
buttonState = buttonCheck;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user