Skip to content

Instantly share code, notes, and snippets.

@hpwit
Last active October 12, 2021 19:32
Show Gist options
  • Select an option

  • Save hpwit/820a19921d96890aa761083d6c59307a to your computer and use it in GitHub Desktop.

Select an option

Save hpwit/820a19921d96890aa761083d6c59307a to your computer and use it in GitHub Desktop.
#include "FastLED.h"
#define NUM_LEDS_PER_STRIP 21
#define NUMSTRIPS 7
#define NUM_LEDS NUM_STRIPS * NUM_LEDS_PER_STRIP
#define CLOCK_PIN 18 //needs to be higher than 16
#include "I2SHD108.h"
int Pins[16]={23,22,21,19,5,4,2};
HD108bLed leds[NUM_LEDS];
I2SHD108 controller(0);
//you can create one HD108Led as such
/*
HD108Led pix=HD108Led(brightnessred,red,brightnessgreen,green ,brightnessblue,bleu);
*/
int offset=0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
controller.initled((uint8_t*)leds,Pins,CLOCK_PIN,NUM_STRIPS,NUM_LEDS_PER_STRIP,HD108b,1); //start with 1Mhz if it goes you can increase the speed
//controller.initled(leds,Pins,CLOCK_PIN,NUM_STRIPS,NUM_LEDS_PER_STRIP,freq in MHZ);
//controller.initled(leds,Pins,CLOCK_PIN,NUM_STRIPS,NUM_LEDS_PER_STRIP,2); //for 2MHZ
delay(200);
//set the brightness to max for all of the leds
for(int i=0;i<NUM_STRIPS*(NUM_LEDS_PER_STRIP);i++)
{
leds[i]=Brightness(31); //all colors will be red
//you can do also leds[i]=Brightness(25,14,31)://brightness red ,brightness green,brightness blue
}
}
void loop() {
//memset(leds,0,NUM_STRIPS*(NUM_LEDS_PER_STRIP)*3);
for(int i=0;i<NUM_STRIPS*(NUM_LEDS_PER_STRIP);i++)
{
leds[i]=CRGB::Black;
}
for(int i=0;i<NUM_STRIPS;i++)
{
for (int j=0;j<(i+1);j++)
{
leds[i*(NUM_LEDS_PER_STRIP)+(j+offset)%NUM_LEDS_PER_STRIP]=HD108bLed(31,255,0,255);
}
}
long ts2=__clock_cycles();
controller.showPixels();
// Serial.printf("fps:%f\n",(float)240000000/(__clock_cycles()-ts2));
delay(400);
offset++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment