code beautifying
This commit is contained in:
parent
15e33778a7
commit
9a1fb158ed
@ -24,7 +24,6 @@
|
||||
#include "configuration.h"
|
||||
|
||||
|
||||
#define MAX_TOKENS 5
|
||||
|
||||
|
||||
void callback(char* topic, byte* payload, unsigned int length);
|
||||
@ -111,7 +110,9 @@ static CRGB evaluationColorWord(char* cmd) {
|
||||
|
||||
|
||||
|
||||
|
||||
void callback(char* topic, byte* payload, unsigned int length) {
|
||||
const uint8_t MAX_TOKENS = 5;
|
||||
const uint8_t BUFSIZE = 128;
|
||||
if ((length + 1) >= BUFSIZE) { // 1 for terminating NUL
|
||||
#ifdef DEBUG
|
||||
@ -144,19 +145,22 @@ void callback(char* topic, byte* payload, unsigned int length) {
|
||||
tokens[tokenCnt] = tk;
|
||||
if (tk) {
|
||||
tokenCnt++;
|
||||
#ifdef DEBUG
|
||||
Serial.print("TokenCnt: ");
|
||||
Serial.print(tokenCnt);
|
||||
Serial.println();
|
||||
#endif
|
||||
}
|
||||
} while (tk);
|
||||
|
||||
#ifdef DEBUG
|
||||
for (uint8_t i = 0; i < tokenCnt; i++) {
|
||||
Serial.print("Token ");
|
||||
Serial.print(i);
|
||||
Serial.print(": ");
|
||||
Serial.println(tokens[i]);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (! strcmp(topic, configBlock.mqttTopicCommand)) {
|
||||
int32_t n, b;
|
||||
@ -177,7 +181,9 @@ void callback(char* topic, byte* payload, unsigned int length) {
|
||||
n = strtol(tokens[0], NULL, 10);
|
||||
b = strtol(tokens[1], NULL, 10);
|
||||
if (n >= 0 && n < NUM_OF_LEDs) {
|
||||
leds[n] = b;
|
||||
leds[n].r = b;
|
||||
leds[n].g = b;
|
||||
leds[n].b = b;
|
||||
FastLED.show();
|
||||
}
|
||||
break;
|
||||
@ -230,9 +236,7 @@ void callback(char* topic, byte* payload, unsigned int length) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -297,52 +301,6 @@ void loopProduction() {
|
||||
if (reconnected) {
|
||||
reconnectTime = millis();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
#define FASTLED_ESP8266_NODEMCU_PIN_ORDER
|
||||
|
||||
#include "RgbLed.h"
|
||||
#include <FastLED.h>
|
||||
|
||||
|
||||
CRGB leds[2];
|
||||
|
||||
void setup() {
|
||||
FastLED.addLeds<NEOPIXEL, 1>(leds, 2);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
leds[0] = CRGB::Red;
|
||||
leds[1] = CRGB::Red;
|
||||
FastLED.show();
|
||||
delay(500);
|
||||
leds[0] = CRGB::Green;
|
||||
leds[1] = CRGB::Green;
|
||||
FastLED.show();
|
||||
delay(500);
|
||||
leds[0] = CRGB::Blue;
|
||||
leds[1] = CRGB::Blue;
|
||||
FastLED.show();
|
||||
delay(500);
|
||||
leds[0].r = 0;
|
||||
leds[0].g = 0;
|
||||
leds[0].b = 255;
|
||||
leds[1].r = 255;
|
||||
leds[1].g = 255;
|
||||
leds[1].b = 255;
|
||||
FastLED.show();
|
||||
delay(500);
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user