fastled breaks from frame 6 onwards
This commit is contained in:
parent
b913fca342
commit
9f889cd1a9
@ -19,7 +19,7 @@ lib_deps =
|
|||||||
bblanchon/ArduinoJson@^6.19.4
|
bblanchon/ArduinoJson@^6.19.4
|
||||||
vshymanskyy/Preferences@^2.0.0
|
vshymanskyy/Preferences@^2.0.0
|
||||||
mbed-multitech/flash-fs
|
mbed-multitech/flash-fs
|
||||||
fastled/FastLED@^3.6.0
|
fastled/FastLED@^3.7.0
|
||||||
arkhipenko/TaskScheduler@^3.7.0
|
arkhipenko/TaskScheduler@^3.7.0
|
||||||
drk/PubSubClient@^2.8
|
drk/PubSubClient@^2.8
|
||||||
khoih-prog/ESPAsync_WiFiManager@^1.15.1
|
khoih-prog/ESPAsync_WiFiManager@^1.15.1
|
||||||
|
|||||||
100
src/Hanglamp.cpp
100
src/Hanglamp.cpp
@ -5,7 +5,10 @@
|
|||||||
#define _TASK_SLEEP_ON_IDLE_RUN // Enable 1 ms SLEEP_IDLE powerdowns between runs if no callback methods were invoked during the pass
|
#define _TASK_SLEEP_ON_IDLE_RUN // Enable 1 ms SLEEP_IDLE powerdowns between runs if no callback methods were invoked during the pass
|
||||||
#define _TASK_STATUS_REQUEST // Compile with support for StatusRequest functionality - triggering tasks on status change events in addition to time only
|
#define _TASK_STATUS_REQUEST // Compile with support for StatusRequest functionality - triggering tasks on status change events in addition to time only
|
||||||
|
|
||||||
#include <TaskScheduler.h>
|
// #define ENABLE_MQTT
|
||||||
|
#define ENABLE_WIFI
|
||||||
|
|
||||||
|
// #include <TaskScheduler.h>
|
||||||
|
|
||||||
#include "MQTT.h"
|
#include "MQTT.h"
|
||||||
#include "Wifi.h"
|
#include "Wifi.h"
|
||||||
@ -32,7 +35,50 @@ CRGB colorTable[] = {
|
|||||||
CRGB::Green,
|
CRGB::Green,
|
||||||
CRGB::Purple,
|
CRGB::Purple,
|
||||||
CRGB::Turquoise,
|
CRGB::Turquoise,
|
||||||
CRGB::Yellow
|
CRGB::Yellow,
|
||||||
|
CRGB::Red,
|
||||||
|
CRGB::Blue,
|
||||||
|
CRGB::Green,
|
||||||
|
CRGB::Purple,
|
||||||
|
CRGB::Turquoise,
|
||||||
|
CRGB::Yellow,
|
||||||
|
CRGB::Red,
|
||||||
|
CRGB::Blue,
|
||||||
|
CRGB::Green,
|
||||||
|
CRGB::Purple,
|
||||||
|
CRGB::Turquoise,
|
||||||
|
CRGB::Yellow,
|
||||||
|
CRGB::Red,
|
||||||
|
CRGB::Blue,
|
||||||
|
CRGB::Green,
|
||||||
|
CRGB::Purple,
|
||||||
|
CRGB::Turquoise,
|
||||||
|
CRGB::Yellow,
|
||||||
|
CRGB::Red,
|
||||||
|
CRGB::Blue,
|
||||||
|
CRGB::Green,
|
||||||
|
CRGB::Purple,
|
||||||
|
CRGB::Turquoise,
|
||||||
|
CRGB::Yellow,
|
||||||
|
CRGB::Red,
|
||||||
|
CRGB::Blue,
|
||||||
|
CRGB::Green,
|
||||||
|
CRGB::Purple,
|
||||||
|
CRGB::Turquoise,
|
||||||
|
CRGB::Yellow,
|
||||||
|
CRGB::Red,
|
||||||
|
CRGB::Blue,
|
||||||
|
CRGB::Green,
|
||||||
|
CRGB::Purple,
|
||||||
|
CRGB::Turquoise,
|
||||||
|
CRGB::Yellow,
|
||||||
|
CRGB::Red,
|
||||||
|
CRGB::Blue,
|
||||||
|
CRGB::Green,
|
||||||
|
CRGB::Purple,
|
||||||
|
CRGB::Turquoise,
|
||||||
|
CRGB::Yellow,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t colorIndex = 0;
|
uint8_t colorIndex = 0;
|
||||||
@ -45,14 +91,6 @@ void colors(){
|
|||||||
jumpTo(colorTable[colorIndex]);
|
jumpTo(colorTable[colorIndex]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Scheduler runner;
|
|
||||||
|
|
||||||
Task taskBlink(1000, TASK_FOREVER, &blink);
|
|
||||||
Task taskColors(1000, TASK_FOREVER, &colors);
|
|
||||||
// Task taskFade(1, TASK_FOREVER, &fadeTask);
|
|
||||||
// Task taskFeedWatchdog(1000, TASK_FOREVER, &feedWatchdog);
|
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
||||||
|
|
||||||
@ -69,48 +107,58 @@ void setup() {
|
|||||||
// runner.init();
|
// runner.init();
|
||||||
Serial.println("Initialized scheduler");
|
Serial.println("Initialized scheduler");
|
||||||
|
|
||||||
runner.addTask(taskBlink);
|
|
||||||
runner.addTask(taskColors);
|
|
||||||
// runner.addTask(taskFade);
|
|
||||||
// runner.addTask(taskFeedWatchdog);
|
|
||||||
|
|
||||||
// taskBlink.enable();
|
|
||||||
taskColors.enable();
|
|
||||||
// taskFade.enable();
|
|
||||||
// taskFeedWatchdog.enable();
|
|
||||||
|
|
||||||
Serial.println("Scheduled tasks");
|
Serial.println("Scheduled tasks");
|
||||||
|
|
||||||
|
|
||||||
// PinFinder_setup();
|
#ifdef ENABLE_PINFINDER
|
||||||
|
PinFinder_setup();
|
||||||
|
#endif
|
||||||
|
|
||||||
Led_setup();
|
Led_setup();
|
||||||
|
|
||||||
jumpTo(CRGB(0xFF00FF));
|
jumpTo(CRGB(0xFF00FF));
|
||||||
|
|
||||||
|
#ifdef ENABLE_WIFI
|
||||||
Wifi_setup();
|
Wifi_setup();
|
||||||
|
#endif
|
||||||
|
|
||||||
jumpTo(CRGB(0x00FFFF));
|
jumpTo(CRGB(0x00FFFF));
|
||||||
|
|
||||||
jumpTo(CRGB(0x000000));
|
jumpTo(CRGB(0x000000));
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
MQTT_setup();
|
MQTT_setup();
|
||||||
// OTA_setup();
|
#endif
|
||||||
|
#ifdef ENABLE_OTA
|
||||||
|
OTA_setup();
|
||||||
|
#endif
|
||||||
|
|
||||||
jumpTo(CRGB(0x00FFFF));
|
jumpTo(CRGB(0x00FFFF));
|
||||||
|
|
||||||
ESP.wdtEnable(10000);
|
// ESP.wdtEnable(10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
#ifdef ENABLE_MQTT
|
||||||
MQTT_loop();
|
MQTT_loop();
|
||||||
// OTA_loop();
|
#endif
|
||||||
// PinFinder_loop();
|
|
||||||
|
#ifdef ENABLE_OTA
|
||||||
|
OTA_loop();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_PINFINDER
|
||||||
|
PinFinder_loop();
|
||||||
|
#endif
|
||||||
|
|
||||||
// runner.execute();
|
|
||||||
colors();
|
colors();
|
||||||
|
|
||||||
delay(100);
|
delay(2000);
|
||||||
|
|
||||||
|
// Led_loop();
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
String command;
|
String command;
|
||||||
|
|
||||||
|
|||||||
53
src/Led.cpp
53
src/Led.cpp
@ -12,6 +12,11 @@ CRGB strip2[STRIP_LENGTH];
|
|||||||
|
|
||||||
int fadeStart = 0;
|
int fadeStart = 0;
|
||||||
|
|
||||||
|
#ifdef LED_NEOPIXEL_BUS
|
||||||
|
NeoPixelBus<NeoGrbFeature, NeoWs2812xMethod> strip(STRIP_LENGTH, PIN_STRIP1);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void fadeTo(const CRGB & dest){
|
void fadeTo(const CRGB & dest){
|
||||||
|
|
||||||
Serial.println("fadeTask is not implemented");
|
Serial.println("fadeTask is not implemented");
|
||||||
@ -33,19 +38,44 @@ void fadeTo(const CRGB & dest){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void displayLed(){
|
void displayLed(){
|
||||||
|
|
||||||
|
#ifdef LED_FASTLED
|
||||||
for(uint8_t index = 0; index < STRIP_LENGTH; index++){
|
for(uint8_t index = 0; index < STRIP_LENGTH; index++){
|
||||||
// Serial.printf("Led 1:%02d 0x%02x%02x%02x\n", index, strip1[index].r, strip1[index].g, strip1[index].b);
|
// Serial.printf("Led 1:%02d 0x%02x%02x%02x\n", index, strip1[index].r, strip1[index].g, strip1[index].b);
|
||||||
}
|
}
|
||||||
for(uint8_t index = 0; index < STRIP_LENGTH; index++){
|
for(uint8_t index = 0; index < STRIP_LENGTH; index++){
|
||||||
// Serial.printf("Led 2:%02d 0x%02x%02x%02x\n", index, strip2[index].r, strip2[index].g, strip2[index].b);
|
// Serial.printf("Led 2:%02d 0x%02x%02x%02x\n", index, strip2[index].r, strip2[index].g, strip2[index].b);
|
||||||
}
|
}
|
||||||
|
auto before = micros64();
|
||||||
FastLED.show();
|
FastLED.show();
|
||||||
|
auto after = micros64();
|
||||||
|
Serial.printf("FastLED.show took %d micros\n", after - before);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LED_NEOPIXEL_BUS
|
||||||
|
|
||||||
|
for(uint8_t index = 0; index < STRIP_LENGTH; index++){
|
||||||
|
RgbColor color;
|
||||||
|
color.R = strip1[index].r;
|
||||||
|
color.G = strip1[index].g;
|
||||||
|
color.B = strip1[index].b;
|
||||||
|
strip.SetPixelColor(index, color);
|
||||||
|
}
|
||||||
|
strip.Show();
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void jumpTo(const CRGB & dest){
|
void jumpTo(const CRGB & dest){
|
||||||
|
// auto before = micros64();
|
||||||
|
// FastLED.showColor(dest);
|
||||||
|
// auto after = micros64();
|
||||||
|
// Serial.printf("FastLED.showColor took %d micros\n", after - before);
|
||||||
|
// return;
|
||||||
|
|
||||||
for(uint8_t index = 0; index < STRIP_LENGTH; index++){
|
for(uint8_t index = 0; index < STRIP_LENGTH; index++){
|
||||||
strip1[index] = dest;
|
strip1[index] = CRGB(dest);
|
||||||
strip2[index] = dest;
|
strip2[index] = CRGB(dest);
|
||||||
}
|
}
|
||||||
Serial.printf("Set color to 0x%02x%02x%02x\n", dest.r, dest.g, dest.b);
|
Serial.printf("Set color to 0x%02x%02x%02x\n", dest.r, dest.g, dest.b);
|
||||||
displayLed();
|
displayLed();
|
||||||
@ -79,17 +109,20 @@ void fadeTask(){
|
|||||||
|
|
||||||
|
|
||||||
void Led_setup(){
|
void Led_setup(){
|
||||||
// pinMode(PIN_STRIP1, OUTPUT);
|
|
||||||
// pinMode(PIN_STRIP2, OUTPUT);
|
pinMode(PIN_STRIP1, OUTPUT);
|
||||||
|
pinMode(PIN_STRIP2, OUTPUT);
|
||||||
|
|
||||||
// analogWriteRange(255);
|
// analogWriteRange(255);
|
||||||
|
|
||||||
|
#ifdef LED_FASTLED
|
||||||
// pinMode(PIN_BUILTIN_LED, OUTPUT);
|
// FastLED.addLeds<WS2812B, PIN_STRIP1>(strip2, STRIP_LENGTH);
|
||||||
// digitalWrite(PIN_BUILTIN_LED, HIGH);
|
|
||||||
|
|
||||||
FastLED.addLeds<WS2812B, PIN_STRIP1>(strip1, STRIP_LENGTH);
|
|
||||||
FastLED.addLeds<WS2812B, PIN_STRIP2>(strip2, STRIP_LENGTH);
|
FastLED.addLeds<WS2812B, PIN_STRIP2>(strip2, STRIP_LENGTH);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LED_NEOPIXEL_BUS
|
||||||
|
strip.Begin();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Led_loop(){
|
void Led_loop(){
|
||||||
@ -111,7 +144,7 @@ void Led_loop(){
|
|||||||
strip2[14] = CRGB(85, 60, 180);
|
strip2[14] = CRGB(85, 60, 180);
|
||||||
FastLED.show();
|
FastLED.show();
|
||||||
delay(500);
|
delay(500);
|
||||||
strip2[19] = CRGB(50, 255, 20);
|
strip2[15] = CRGB(50, 255, 20);
|
||||||
FastLED.show();
|
FastLED.show();
|
||||||
delay(500);
|
delay(500);
|
||||||
}
|
}
|
||||||
19
src/Led.h
19
src/Led.h
@ -4,13 +4,24 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
// #define LED_NEOPIXEL_BUS
|
||||||
|
#define LED_FASTLED
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef LED_FASTLED
|
||||||
|
// #define FASTLED_ALL_PINS_HARDWARE_SPI
|
||||||
|
// #define FASTLED_ALLOW_INTERRUPTS 0
|
||||||
|
#define FASTLED_INTERRUPT_RETRY_COUNT 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <FastLED.h>
|
#include <FastLED.h>
|
||||||
|
|
||||||
#define PIN_BUILTIN_LED 2
|
#ifdef LED_NEOPIXEL_BUS
|
||||||
|
#include <NeoPixelBus.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define PIN_STRIP1 4
|
||||||
#define PIN_STRIP1 0
|
#define PIN_STRIP2 5
|
||||||
#define PIN_STRIP2 2
|
|
||||||
|
|
||||||
#define STRIP_LENGTH 46
|
#define STRIP_LENGTH 46
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user