Merge pull request #1218 from marmilicious/master

Some Modernization updates for #1208
This commit is contained in:
Mark Kriegsman 2021-04-10 13:27:00 -04:00 committed by GitHub
commit 1a273c8d3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 47 additions and 46 deletions

View File

@ -15,8 +15,8 @@ CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(57600);
Serial.println("resetting");
LEDS.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS);
LEDS.setBrightness(84);
FastLED.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS);
FastLED.setBrightness(84);
}
void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } }

View File

@ -11,9 +11,6 @@ FASTLED_USING_NAMESPACE
//
// -Mark Kriegsman, December 2014
#if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000)
#warning "Requires FastLED 3.1 or later; check github for latest code."
#endif
#define DATA_PIN 3
//#define CLK_PIN 4
@ -117,7 +114,7 @@ void bpm()
void juggle() {
// eight colored dots, weaving in and out of sync with each other
fadeToBlackBy( leds, NUM_LEDS, 20);
byte dothue = 0;
uint8_t dothue = 0;
for( int i = 0; i < 8; i++) {
leds[beatsin16( i+7, 0, NUM_LEDS-1 )] |= CHSV(dothue, 200, 255);
dothue += 32;

View File

@ -72,7 +72,7 @@ void loop()
void Fire2012()
{
// Array of temperature readings at each simulation cell
static byte heat[NUM_LEDS];
static uint8_t heat[NUM_LEDS];
// Step 1. Cool down every cell a little
for( int i = 0; i < NUM_LEDS; i++) {

View File

@ -128,7 +128,7 @@ void loop()
void Fire2012WithPalette()
{
// Array of temperature readings at each simulation cell
static byte heat[NUM_LEDS];
static uint8_t heat[NUM_LEDS];
// Step 1. Cool down every cell a little
for( int i = 0; i < NUM_LEDS; i++) {
@ -150,7 +150,7 @@ void Fire2012WithPalette()
for( int j = 0; j < NUM_LEDS; j++) {
// Scale the heat value from 0-255 down to 0-240
// for best results with color palettes.
byte colorindex = scale8( heat[j], 240);
uint8_t colorindex = scale8( heat[j], 240);
CRGB color = ColorFromPalette( gPal, colorindex);
int pixelnumber;
if( gReverseDirection ) {

View File

@ -11,8 +11,8 @@ CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP];
// OctoWS2811: 2,14,7,8,6,20,21,5
void setup() {
LEDS.addLeds<OCTOWS2811>(leds, NUM_LEDS_PER_STRIP);
LEDS.setBrightness(32);
FastLED.addLeds<OCTOWS2811>(leds, NUM_LEDS_PER_STRIP);
FastLED.setBrightness(32);
}
void loop() {
@ -32,6 +32,6 @@ void loop() {
hue++;
LEDS.show();
LEDS.delay(10);
FastLED.show();
FastLED.delay(10);
}

View File

@ -24,13 +24,13 @@ void setup() {
delay(5000);
Serial.begin(57600);
Serial.println("Starting...");
// LEDS.addLeds<WS2811_PORTA,NUM_STRIPS>(leds, NUM_LEDS_PER_STRIP);
// LEDS.addLeds<WS2811_PORTB,NUM_STRIPS>(leds, NUM_LEDS_PER_STRIP);
// LEDS.addLeds<WS2811_PORTD,NUM_STRIPS>(leds, NUM_LEDS_PER_STRIP).setCorrection(TypicalLEDStrip);
LEDS.addLeds<WS2811_PORTDC,NUM_STRIPS>(leds, NUM_LEDS_PER_STRIP);
// FastLED.addLeds<WS2811_PORTA,NUM_STRIPS>(leds, NUM_LEDS_PER_STRIP);
// FastLED.addLeds<WS2811_PORTB,NUM_STRIPS>(leds, NUM_LEDS_PER_STRIP);
// FastLED.addLeds<WS2811_PORTD,NUM_STRIPS>(leds, NUM_LEDS_PER_STRIP).setCorrection(TypicalLEDStrip);
FastLED.addLeds<WS2811_PORTDC,NUM_STRIPS>(leds, NUM_LEDS_PER_STRIP);
// Teensy 4 parallel output example
// LEDS.addLeds<NUM_STRIPS, WS2811, 1>(leds,NUM_LEDS_PER_STRIP);
// FastLED.addLeds<NUM_STRIPS, WS2811, 1>(leds,NUM_LEDS_PER_STRIP);
}
void loop() {
@ -51,6 +51,6 @@ void loop() {
hue++;
LEDS.show();
// LEDS.delay(100);
FastLED.show();
// FastLED.delay(100);
}

View File

@ -7,8 +7,10 @@
// Params for width and height
const uint8_t kMatrixWidth = 16;
const uint8_t kMatrixHeight = 16;
#define MAX_DIMENSION ((kMatrixWidth>kMatrixHeight) ? kMatrixWidth : kMatrixHeight)
#define NUM_LEDS (kMatrixWidth * kMatrixHeight)
// Param for different pixel layouts
const bool kMatrixSerpentineLayout = true;
@ -62,15 +64,15 @@ uint16_t speed = 20; // a nice starting speed, mixes well with a scale of 100
uint16_t scale = 311;
// This is the array that we keep our computed noise values in
uint8_t noise[MAX_DIMENSION][MAX_DIMENSION];
uint16_t noise[MAX_DIMENSION][MAX_DIMENSION];
void setup() {
// uncomment the following lines if you want to see FPS count information
// Serial.begin(38400);
// Serial.println("resetting!");
delay(3000);
LEDS.addLeds<WS2811,2,RGB>(leds,NUM_LEDS);
LEDS.setBrightness(96);
FastLED.addLeds<WS2811,2,RGB>(leds,NUM_LEDS);
FastLED.setBrightness(96);
// Initialize our coordinates to some random values
x = random16();
@ -107,6 +109,6 @@ void loop() {
}
ihue+=1;
LEDS.show();
FastLED.show();
// delay(10);
}

View File

@ -1,9 +1,11 @@
#include <FastLED.h>
#define kMatrixWidth 16
#define kMatrixHeight 16
// Params for width and height
const uint8_t kMatrixWidth = 16;
const uint8_t kMatrixHeight = 16;
#define NUM_LEDS (kMatrixWidth * kMatrixHeight)
// Param for different pixel layouts
#define kMatrixSerpentineLayout true
@ -37,11 +39,11 @@ int y_speed=1111;
void loop() {
// fill the led array 2/16-bit noise values
fill_2dnoise16(LEDS.leds(), kMatrixWidth, kMatrixHeight, kMatrixSerpentineLayout,
fill_2dnoise16(leds, kMatrixWidth, kMatrixHeight, kMatrixSerpentineLayout,
octaves,x,xscale,y,yscale,v_time,
hue_octaves,hxy,hue_scale,hxy,hue_scale,hue_time, false);
LEDS.show();
FastLED.show();
// adjust the intra-frame time values
x += x_speed;
@ -61,8 +63,8 @@ void setup() {
Serial.println("resetting!");
delay(3000);
LEDS.addLeds<WS2811,2,GRB>(leds,NUM_LEDS);
LEDS.setBrightness(96);
FastLED.addLeds<WS2811,2,GRB>(leds,NUM_LEDS);
FastLED.setBrightness(96);
hxy = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16();
x = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16();

View File

@ -5,8 +5,11 @@
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
// Params for width and height
const uint8_t kMatrixWidth = 16;
const uint8_t kMatrixHeight = 16;
// Param for different pixel layouts
const bool kMatrixSerpentineLayout = true;
@ -67,8 +70,8 @@ uint8_t colorLoop = 1;
void setup() {
delay(3000);
LEDS.addLeds<LED_TYPE,LED_PIN,COLOR_ORDER>(leds,NUM_LEDS);
LEDS.setBrightness(BRIGHTNESS);
FastLED.addLeds<LED_TYPE,LED_PIN,COLOR_ORDER>(leds,NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
// Initialize our coordinates to some random values
x = random16();
@ -163,7 +166,7 @@ void loop() {
// using the current palette
mapNoiseToLEDsUsingPalette();
LEDS.show();
FastLED.show();
// delay(10);
}

View File

@ -63,8 +63,8 @@ void setup() {
// Serial.begin(38400);
// Serial.println("resetting!");
delay(3000);
LEDS.addLeds<SMART_MATRIX>(leds,NUM_LEDS);
LEDS.setBrightness(96);
FastLED.addLeds<SMART_MATRIX>(leds,NUM_LEDS);
FastLED.setBrightness(96);
// Initialize our coordinates to some random values
x = random16();
@ -116,6 +116,6 @@ void loop() {
pSmartMatrix->fillCircle(circlex % 32,circley % 32,6,CRGB(CHSV(ihue+128,255,255)));
circlex += random16(2);
circley += random16(2);
LEDS.show();
FastLED.show();
// delay(10);
}

View File

@ -1,9 +1,5 @@
#include "FastLED.h"
#if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000)
#warning "Requires FastLED 3.1 or later; check github for latest code."
#endif
#define NUM_LEDS 100
#define LED_TYPE WS2811

View File

@ -15,7 +15,7 @@
// No error checking is performed on the ranges of x and y.
//
// XYsafe(x,y) takes x and y coordinates and returns an LED index number,
// for use like this: leds[ XY(x,y) ] == CRGB::Red;
// for use like this: leds[ XYsafe(x,y) ] == CRGB::Red;
// Error checking IS performed on the ranges of x and y, and an
// index of "-1" is returned. Special instructions below
// explain how to use this without having to do your own error
@ -31,6 +31,7 @@ const uint8_t kMatrixHeight = 16;
// Param for different pixel layouts
const bool kMatrixSerpentineLayout = true;
const bool kMatrixVertical = false;
// Set 'kMatrixSerpentineLayout' to false if your pixels are
// laid out all running the same way, like this:
//
@ -189,13 +190,13 @@ void loop()
FastLED.show();
}
void DrawOneFrame( byte startHue8, int8_t yHueDelta8, int8_t xHueDelta8)
void DrawOneFrame( uint8_t startHue8, int8_t yHueDelta8, int8_t xHueDelta8)
{
byte lineStartHue = startHue8;
for( byte y = 0; y < kMatrixHeight; y++) {
uint8_t lineStartHue = startHue8;
for( uint8_t y = 0; y < kMatrixHeight; y++) {
lineStartHue += yHueDelta8;
byte pixelHue = lineStartHue;
for( byte x = 0; x < kMatrixWidth; x++) {
uint8_t pixelHue = lineStartHue;
for( uint8_t x = 0; x < kMatrixWidth; x++) {
pixelHue += xHueDelta8;
leds[ XY(x, y)] = CHSV( pixelHue, 255, 255);
}