add support for PL9823

This commit is contained in:
Wolfgang Hottgenroth 2019-04-19 23:35:34 +02:00
parent 9a1fb158ed
commit 12f6197bf9
Signed by: wn
GPG Key ID: B586EAFCDF2F65F4
3 changed files with 84 additions and 7 deletions

View File

@ -184,10 +184,10 @@ environment/project/io.sloeber.core.toolChain.release.1583508753/A.EXTRA.TIME.DT
environment/project/io.sloeber.core.toolChain.release.1583508753/A.EXTRA.TIME.DTS/value=3600
environment/project/io.sloeber.core.toolChain.release.1583508753/A.EXTRA.TIME.LOCAL/delimiter=\:
environment/project/io.sloeber.core.toolChain.release.1583508753/A.EXTRA.TIME.LOCAL/operation=replace
environment/project/io.sloeber.core.toolChain.release.1583508753/A.EXTRA.TIME.LOCAL/value=1554895981
environment/project/io.sloeber.core.toolChain.release.1583508753/A.EXTRA.TIME.LOCAL/value=1555711355
environment/project/io.sloeber.core.toolChain.release.1583508753/A.EXTRA.TIME.UTC/delimiter=\:
environment/project/io.sloeber.core.toolChain.release.1583508753/A.EXTRA.TIME.UTC/operation=replace
environment/project/io.sloeber.core.toolChain.release.1583508753/A.EXTRA.TIME.UTC/value=1554888781
environment/project/io.sloeber.core.toolChain.release.1583508753/A.EXTRA.TIME.UTC/value=1555704155
environment/project/io.sloeber.core.toolChain.release.1583508753/A.EXTRA.TIME.ZONE/delimiter=\:
environment/project/io.sloeber.core.toolChain.release.1583508753/A.EXTRA.TIME.ZONE/operation=replace
environment/project/io.sloeber.core.toolChain.release.1583508753/A.EXTRA.TIME.ZONE/value=3600
@ -466,10 +466,10 @@ environment/project/io.sloeber.core.toolChain.release.1583508753/JANTJE.BOARD_NA
environment/project/io.sloeber.core.toolChain.release.1583508753/JANTJE.BOARD_NAME/value=NodeMCU 1.0 (ESP-12E Module)
environment/project/io.sloeber.core.toolChain.release.1583508753/JANTJE.COM_PORT/delimiter=\:
environment/project/io.sloeber.core.toolChain.release.1583508753/JANTJE.COM_PORT/operation=replace
environment/project/io.sloeber.core.toolChain.release.1583508753/JANTJE.COM_PORT/value=/dev/ttyUSB4
environment/project/io.sloeber.core.toolChain.release.1583508753/JANTJE.COM_PORT/value=/dev/ttyUSB0
environment/project/io.sloeber.core.toolChain.release.1583508753/JANTJE.ECLIPSE_LOCATION/delimiter=\:
environment/project/io.sloeber.core.toolChain.release.1583508753/JANTJE.ECLIPSE_LOCATION/operation=replace
environment/project/io.sloeber.core.toolChain.release.1583508753/JANTJE.ECLIPSE_LOCATION/value=${eclipse_home}//////////
environment/project/io.sloeber.core.toolChain.release.1583508753/JANTJE.ECLIPSE_LOCATION/value=${eclipse_home}////////////////////
environment/project/io.sloeber.core.toolChain.release.1583508753/JANTJE.EXTRA.ALL/delimiter=\:
environment/project/io.sloeber.core.toolChain.release.1583508753/JANTJE.EXTRA.ALL/operation=replace
environment/project/io.sloeber.core.toolChain.release.1583508753/JANTJE.EXTRA.ALL/value=

View File

@ -9,7 +9,7 @@
tConfigBlock configBlock;
const uint32_t MAGIC = 3235774470;
const uint32_t MAGIC = 3235774471;
const char* CONFIG_SSID = "espconfig";
extern ESP8266WebServer webServer;

View File

@ -6,6 +6,10 @@
*/
// #define FASTLED
#define ADAFRUIT_NEOPIXEL
#include "defines.h"
#define MQTT_MAX_PACKET_SIZE 256
@ -18,8 +22,15 @@
#include <ESP8266WebServer.h>
#include <PubSubClient.h>
#ifdef FASTLED
#define FASTLED_ESP8266_NODEMCU_PIN_ORDER
#include <FastLED.h>
#endif
#ifdef ADAFRUIT_NEOPIXEL
#include <Adafruit_NeoPixel.h>
#endif
#include "configuration.h"
@ -35,9 +46,20 @@ WiFiClientSecure espClient;
PubSubClient client(espClient);
#ifdef FASTLED
CRGB leds[NUM_OF_LEDs];
#endif
#ifdef ADAFRUIT_NEOPIXEL
typedef struct {
uint8_t r;
uint8_t g;
uint8_t b;
} CRGB;
Adafruit_NeoPixel pixels(NUM_OF_LEDs, D1, NEO_RGB + NEO_KHZ400);
#endif
void setup_wifi() {
delay(10);
@ -170,21 +192,38 @@ void callback(char* topic, byte* payload, unsigned int length) {
// set brightness
b = strtol(tokens[0], NULL, 10);
for (uint8_t i = 0; i < NUM_OF_LEDs; i++) {
#ifdef FASTLED
leds[i].r = b;
leds[i].g = b;
leds[i].b = b;
#endif
#ifdef ADAFRUIT_NEOPIXEL
pixels.setPixelColor(i, pixels.Color(b, b, b));
#endif
}
#ifdef FASTLED
FastLED.show();
#endif
#ifdef ADAFRUIT_NEOPIXEL
pixels.show();
#endif
break;
case 2:
// set brightness for one LED
n = strtol(tokens[0], NULL, 10);
b = strtol(tokens[1], NULL, 10);
if (n >= 0 && n < NUM_OF_LEDs) {
#ifdef FASTLED
leds[n].r = b;
leds[n].g = b;
leds[n].b = b;
FastLED.show();
#endif
#ifdef ADAFRUIT_NEOPIXEL
pixels.setPixelColor(n, pixels.Color(b, b, b));
pixels.show();
#endif
}
break;
}
@ -197,17 +236,33 @@ void callback(char* topic, byte* payload, unsigned int length) {
// on, off, color word for all LEDs
colors = evaluationColorWord(tokens[0]);
for (uint8_t i = 0; i < NUM_OF_LEDs; i++) {
#ifdef FASTLED
leds[i] = colors;
#endif
#ifdef ADAFRUIT_NEOPIXEL
pixels.setPixelColor(i, pixels.Color(colors.r, colors.g, colors.b));
#endif
}
#ifdef FASTLED
FastLED.show();
#endif
#ifdef ADAFRUIT_NEOPIXEL
pixels.show();
#endif
break;
case 2:
// token0 = LED number, token1 = color
n = strtol(tokens[0], NULL, 10);
if (n >= 0 && n < NUM_OF_LEDs) {
colors = evaluationColorWord(tokens[1]);
#ifdef FASTLED
leds[n] = colors;
FastLED.show();
#endif
#ifdef ADAFRUIT_NEOPIXEL
pixels.setPixelColor(n, pixels.Color(colors.r, colors.g, colors.b));
pixels.show();
#endif
}
break;
case 3:
@ -216,11 +271,21 @@ void callback(char* topic, byte* payload, unsigned int length) {
green = strtol(tokens[1], NULL, 10);
blue = strtol(tokens[2], NULL, 10);
for (uint8_t i = 0; i < NUM_OF_LEDs; i++) {
#ifdef FASTLED
leds[i].r = red;
leds[i].g = green;
leds[i].b = blue;
#endif
#ifdef ADAFRUIT_NEOPIXEL
pixels.setPixelColor(i, pixels.Color(red, green, blue));
#endif
}
#ifdef FASTLED
FastLED.show();
#endif
#ifdef ADAFRUIT_NEOPIXEL
pixels.show();
#endif
break;
case 4:
// token0 = LED number, token1 = red, token2 = green, token3 = blue
@ -229,10 +294,16 @@ void callback(char* topic, byte* payload, unsigned int length) {
red = strtol(tokens[1], NULL, 10);
green = strtol(tokens[2], NULL, 10);
blue = strtol(tokens[3], NULL, 10);
#ifdef FASTLED
leds[n].r = red;
leds[n].g = green;
leds[n].b = blue;
FastLED.show();
#endif
#ifdef ADAFRUIT_NEOPIXEL
pixels.setPixelColor(n, pixels.Color(red, green, blue));
pixels.show();
#endif
}
break;
}
@ -291,7 +362,13 @@ void setupProduction() {
setup_wifi();
client.setServer(configBlock.mqttBroker, configBlock.mqttPort);
FastLED.addLeds<NEOPIXEL, PIXEL_PIN>(leds, NUM_OF_LEDs);
#ifdef FASTLED
// FastLED.addLeds<NEOPIXEL, PIXEL_PIN>(leds, NUM_OF_LEDs);
FastLED.addLeds<WS2812, PIXEL_PIN, GRB>(leds, NUM_OF_LEDs);
#endif
#ifdef ADAFRUIT_NEOPIXEL
pixels.begin();
#endif
}