forked from bbulkow/FastLED-idf
Update test code, have three different interesting blinking patterns.
This commit is contained in:
@@ -7,10 +7,12 @@
|
|||||||
CONDITIONS OF ANY KIND, either express or implied.
|
CONDITIONS OF ANY KIND, either express or implied.
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "esp_system.h"
|
#include "esp_system.h"
|
||||||
#include "esp_spi_flash.h"
|
#include "esp_spi_flash.h"
|
||||||
|
|
||||||
#include "FastLED.h"
|
#include "FastLED.h"
|
||||||
CRGBPalette16 currentPalette;
|
CRGBPalette16 currentPalette;
|
||||||
TBlendType currentBlending;
|
TBlendType currentBlending;
|
||||||
@@ -20,11 +22,11 @@ extern const TProgmemPalette16 IRAM_ATTR myRedWhiteBluePalette_p;
|
|||||||
|
|
||||||
#include "palettes.h"
|
#include "palettes.h"
|
||||||
|
|
||||||
#define NUM_LEDS 400
|
#define NUM_LEDS 40
|
||||||
#define DATA_PIN 15
|
#define DATA_PIN 18
|
||||||
#define BRIGHTNESS 64
|
#define BRIGHTNESS 64
|
||||||
#define LED_TYPE WS2811
|
#define LED_TYPE WS2811
|
||||||
#define COLOR_ORDER GRB
|
#define COLOR_ORDER RGB
|
||||||
CRGB leds[NUM_LEDS];
|
CRGB leds[NUM_LEDS];
|
||||||
|
|
||||||
|
|
||||||
@@ -32,6 +34,7 @@ extern "C" {
|
|||||||
void app_main();
|
void app_main();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ChangePalettePeriodically(){
|
void ChangePalettePeriodically(){
|
||||||
|
|
||||||
uint8_t secondHand = (millis() / 1000) % 60;
|
uint8_t secondHand = (millis() / 1000) % 60;
|
||||||
@@ -53,8 +56,10 @@ void ChangePalettePeriodically(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
void blinkLeds(void *pvParameters){
|
|
||||||
|
void blinkLeds_interesting(void *pvParameters){
|
||||||
while(1){
|
while(1){
|
||||||
|
printf("blink leds\n");
|
||||||
ChangePalettePeriodically();
|
ChangePalettePeriodically();
|
||||||
|
|
||||||
static uint8_t startIndex = 0;
|
static uint8_t startIndex = 0;
|
||||||
@@ -64,16 +69,94 @@ void blinkLeds(void *pvParameters){
|
|||||||
leds[i] = ColorFromPalette( currentPalette, startIndex, 64, currentBlending);
|
leds[i] = ColorFromPalette( currentPalette, startIndex, 64, currentBlending);
|
||||||
startIndex += 3;
|
startIndex += 3;
|
||||||
}
|
}
|
||||||
|
printf("show leds\n");
|
||||||
FastLED.show();
|
FastLED.show();
|
||||||
delay(40);
|
delay(400);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#define N_COLORS 17
|
||||||
|
CRGB colors[N_COLORS] = {
|
||||||
|
CRGB::AliceBlue,
|
||||||
|
CRGB::ForestGreen,
|
||||||
|
CRGB::Lavender,
|
||||||
|
CRGB::MistyRose,
|
||||||
|
CRGB::DarkOrchid,
|
||||||
|
CRGB::DarkOrange,
|
||||||
|
CRGB::Black,
|
||||||
|
CRGB::Red,
|
||||||
|
CRGB::Green,
|
||||||
|
CRGB::Blue,
|
||||||
|
CRGB::White,
|
||||||
|
CRGB::Teal,
|
||||||
|
CRGB::Violet,
|
||||||
|
CRGB::Lime,
|
||||||
|
CRGB::Chartreuse,
|
||||||
|
CRGB::BlueViolet,
|
||||||
|
CRGB::Aqua
|
||||||
|
};
|
||||||
|
|
||||||
|
void blinkLeds_simple(void *pvParameters){
|
||||||
|
|
||||||
|
while(1){
|
||||||
|
printf("blink leds\n");
|
||||||
|
|
||||||
|
for (int j=0;j<N_COLORS;j++) {
|
||||||
|
for (int i=0;i<NUM_LEDS;i++) {
|
||||||
|
leds[i] = colors[j];
|
||||||
|
}
|
||||||
|
FastLED.show();
|
||||||
|
delay(1000);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#define N_COLORS_CHASE 7
|
||||||
|
CRGB colors_chase[N_COLORS_CHASE] = {
|
||||||
|
CRGB::AliceBlue,
|
||||||
|
CRGB::Lavender,
|
||||||
|
CRGB::DarkOrange,
|
||||||
|
CRGB::Red,
|
||||||
|
CRGB::Green,
|
||||||
|
CRGB::Blue,
|
||||||
|
CRGB::White,
|
||||||
|
};
|
||||||
|
|
||||||
|
void blinkLeds_chase(void *pvParameters) {
|
||||||
|
int pos = 0;
|
||||||
|
int led_color = 0;
|
||||||
|
while(1){
|
||||||
|
printf("chase leds\n");
|
||||||
|
|
||||||
|
// do it the dumb way - blank the leds
|
||||||
|
for (int i=0;i<NUM_LEDS;i++) {
|
||||||
|
leds[i] = CRGB::Black;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the one LED to the right color
|
||||||
|
leds[pos] = colors_chase[led_color];
|
||||||
|
pos = (pos + 1) % NUM_LEDS;
|
||||||
|
|
||||||
|
// use a new color
|
||||||
|
if (pos == 0) {
|
||||||
|
led_color = (led_color + 1) % N_COLORS_CHASE ;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t start = esp_timer_get_time();
|
||||||
|
FastLED.show();
|
||||||
|
uint64_t end = esp_timer_get_time();
|
||||||
|
printf("Show Time: %"PRIu64"\n",end-start);
|
||||||
|
delay(200);
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void app_main() {
|
void app_main() {
|
||||||
|
printf(" entering app main, call add leds\n");
|
||||||
FastLED.addLeds<LED_TYPE, DATA_PIN>(leds, NUM_LEDS);
|
FastLED.addLeds<LED_TYPE, DATA_PIN>(leds, NUM_LEDS);
|
||||||
|
printf(" set max power\n");
|
||||||
FastLED.setMaxPowerInVoltsAndMilliamps(5,1000);
|
FastLED.setMaxPowerInVoltsAndMilliamps(5,1000);
|
||||||
xTaskCreatePinnedToCore(&blinkLeds, "blinkLeds", 4000, NULL, 5, NULL, 0);
|
printf("create task for led blinking\n");
|
||||||
|
xTaskCreatePinnedToCore(&blinkLeds_chase, "blinkLeds", 4000, NULL, 5, NULL, 0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user