code beautifying
This commit is contained in:
@ -24,7 +24,6 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
|
||||||
|
|
||||||
#define MAX_TOKENS 5
|
|
||||||
|
|
||||||
|
|
||||||
void callback(char* topic, byte* payload, unsigned int length);
|
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) {
|
void callback(char* topic, byte* payload, unsigned int length) {
|
||||||
|
const uint8_t MAX_TOKENS = 5;
|
||||||
const uint8_t BUFSIZE = 128;
|
const uint8_t BUFSIZE = 128;
|
||||||
if ((length + 1) >= BUFSIZE) { // 1 for terminating NUL
|
if ((length + 1) >= BUFSIZE) { // 1 for terminating NUL
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -144,19 +145,22 @@ void callback(char* topic, byte* payload, unsigned int length) {
|
|||||||
tokens[tokenCnt] = tk;
|
tokens[tokenCnt] = tk;
|
||||||
if (tk) {
|
if (tk) {
|
||||||
tokenCnt++;
|
tokenCnt++;
|
||||||
|
#ifdef DEBUG
|
||||||
Serial.print("TokenCnt: ");
|
Serial.print("TokenCnt: ");
|
||||||
Serial.print(tokenCnt);
|
Serial.print(tokenCnt);
|
||||||
Serial.println();
|
Serial.println();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} while (tk);
|
} while (tk);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
for (uint8_t i = 0; i < tokenCnt; i++) {
|
for (uint8_t i = 0; i < tokenCnt; i++) {
|
||||||
Serial.print("Token ");
|
Serial.print("Token ");
|
||||||
Serial.print(i);
|
Serial.print(i);
|
||||||
Serial.print(": ");
|
Serial.print(": ");
|
||||||
Serial.println(tokens[i]);
|
Serial.println(tokens[i]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (! strcmp(topic, configBlock.mqttTopicCommand)) {
|
if (! strcmp(topic, configBlock.mqttTopicCommand)) {
|
||||||
int32_t n, b;
|
int32_t n, b;
|
||||||
@ -177,7 +181,9 @@ void callback(char* topic, byte* payload, unsigned int length) {
|
|||||||
n = strtol(tokens[0], NULL, 10);
|
n = strtol(tokens[0], NULL, 10);
|
||||||
b = strtol(tokens[1], NULL, 10);
|
b = strtol(tokens[1], NULL, 10);
|
||||||
if (n >= 0 && n < NUM_OF_LEDs) {
|
if (n >= 0 && n < NUM_OF_LEDs) {
|
||||||
leds[n] = b;
|
leds[n].r = b;
|
||||||
|
leds[n].g = b;
|
||||||
|
leds[n].b = b;
|
||||||
FastLED.show();
|
FastLED.show();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -230,9 +236,7 @@ void callback(char* topic, byte* payload, unsigned int length) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,52 +301,6 @@ void loopProduction() {
|
|||||||
if (reconnected) {
|
if (reconnected) {
|
||||||
reconnectTime = millis();
|
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);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user