Change the word toggle to action
This commit is contained in:
		
							parent
							
								
									bcb5208e4d
								
							
						
					
					
						commit
						c7ece609ea
					
				
							
								
								
									
										12
									
								
								src/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								src/main.cpp
									
									
									
									
									
								
							| 
						 | 
					@ -12,7 +12,7 @@
 | 
				
			||||||
#define SERVICE "LEDsActionButton"
 | 
					#define SERVICE "LEDsActionButton"
 | 
				
			||||||
#define STATUSINTERVAL 600000
 | 
					#define STATUSINTERVAL 600000
 | 
				
			||||||
 | 
					
 | 
				
			||||||
String toggleURL = "http://moon.basement.lan/l/actionbutton.php?state=";
 | 
					String actionURL = "http://moon.basement.lan/l/actionbutton.php?state=";
 | 
				
			||||||
String statusURL = "http://moon.basement.lan/l/boardstatus.php";
 | 
					String statusURL = "http://moon.basement.lan/l/boardstatus.php";
 | 
				
			||||||
unsigned short buttonState = HIGH, lastButtonState = HIGH;
 | 
					unsigned short buttonState = HIGH, lastButtonState = HIGH;
 | 
				
			||||||
unsigned long lastStatusTime = 0;
 | 
					unsigned long lastStatusTime = 0;
 | 
				
			||||||
| 
						 | 
					@ -20,10 +20,10 @@ unsigned long lastStatusTime = 0;
 | 
				
			||||||
AsyncWebServer server(80);
 | 
					AsyncWebServer server(80);
 | 
				
			||||||
PrettyOTA OTAUpdates;
 | 
					PrettyOTA OTAUpdates;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sendToggleMessage(bool state) {
 | 
					void sendActionMessage(bool state) {
 | 
				
			||||||
  Serial.println("Action button triggered");
 | 
					  Serial.println("Action button triggered");
 | 
				
			||||||
  char webMsg[255] = "";
 | 
					  char webMsg[255] = "";
 | 
				
			||||||
  strcat(webMsg, toggleURL.c_str());
 | 
					  strcat(webMsg, actionURL.c_str());
 | 
				
			||||||
  strcat(webMsg, (state) ? "true" : "false");
 | 
					  strcat(webMsg, (state) ? "true" : "false");
 | 
				
			||||||
  HTTPClient http;
 | 
					  HTTPClient http;
 | 
				
			||||||
  http.begin(webMsg);
 | 
					  http.begin(webMsg);
 | 
				
			||||||
| 
						 | 
					@ -86,7 +86,7 @@ void setup() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
unsigned long lastDebounceTime = 0;
 | 
					unsigned long lastDebounceTime = 0;
 | 
				
			||||||
bool toggleState = false;
 | 
					bool actionState = false;
 | 
				
			||||||
bool debouncing = false;
 | 
					bool debouncing = false;
 | 
				
			||||||
void loop() {
 | 
					void loop() {
 | 
				
			||||||
  if ( millis() > (lastStatusTime + STATUSINTERVAL) ) {
 | 
					  if ( millis() > (lastStatusTime + STATUSINTERVAL) ) {
 | 
				
			||||||
| 
						 | 
					@ -105,8 +105,8 @@ void loop() {
 | 
				
			||||||
    if ( buttonCheck != buttonState ) {
 | 
					    if ( buttonCheck != buttonState ) {
 | 
				
			||||||
      buttonState = buttonCheck;
 | 
					      buttonState = buttonCheck;
 | 
				
			||||||
      if ( buttonState == LOW ) {
 | 
					      if ( buttonState == LOW ) {
 | 
				
			||||||
        toggleState = !toggleState;
 | 
					        actionState = !actionState;
 | 
				
			||||||
        sendToggleMessage(toggleState);
 | 
					        sendActionMessage(actionState);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user