mirror of
https://github.com/Links2004/arduinoWebSockets.git
synced 2025-07-29 15:17:13 +02:00
code style
This commit is contained in:
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#define USE_SERIAL Serial
|
#define USE_SERIAL Serial
|
||||||
|
|
||||||
|
|
||||||
ESP8266WiFiMulti WiFiMulti;
|
ESP8266WiFiMulti WiFiMulti;
|
||||||
|
|
||||||
ESP8266WebServer server(80);
|
ESP8266WebServer server(80);
|
||||||
@ -49,9 +48,9 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length
|
|||||||
// decode rgb data
|
// decode rgb data
|
||||||
uint32_t rgb = (uint32_t) strtol((const char *) &payload[1], NULL, 16);
|
uint32_t rgb = (uint32_t) strtol((const char *) &payload[1], NULL, 16);
|
||||||
|
|
||||||
analogWrite(LED_RED, ((rgb >> 16) & 0xFF));
|
analogWrite(LED_RED, ((rgb >> 16) & 0xFF));
|
||||||
analogWrite(LED_GREEN, ((rgb >> 8) & 0xFF));
|
analogWrite(LED_GREEN, ((rgb >> 8) & 0xFF));
|
||||||
analogWrite(LED_BLUE, ((rgb >> 0) & 0xFF));
|
analogWrite(LED_BLUE, ((rgb >> 0) & 0xFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -119,15 +118,15 @@ unsigned long last_10sec = 0;
|
|||||||
unsigned int counter = 0;
|
unsigned int counter = 0;
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
unsigned long t = millis();
|
unsigned long t = millis();
|
||||||
webSocket.loop();
|
webSocket.loop();
|
||||||
server.handleClient();
|
server.handleClient();
|
||||||
|
|
||||||
if((t - last_10sec) > 10 * 1000) {
|
if((t - last_10sec) > 10 * 1000) {
|
||||||
counter++;
|
counter++;
|
||||||
bool ping = (counter % 2);
|
bool ping = (counter % 2);
|
||||||
int i = webSocket.connectedClients(ping);
|
int i = webSocket.connectedClients(ping);
|
||||||
USE_SERIAL.printf("%d Connected websocket clients ping: %d", i, ping);
|
USE_SERIAL.printf("%d Connected websocket clients ping: %d\n", i, ping);
|
||||||
last_10sec = millis();
|
last_10sec = millis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user