Use 4 space tab like a normal person

This commit is contained in:
Oliver Atkinson 2023-09-05 08:49:30 -06:00
parent a6c46788df
commit a2c5fee6ac

View File

@ -9,10 +9,10 @@ ws2812b<D,6> strip;
grb pixels[NUM_LEDS] = {};
void setup() {
Serial.begin(BAUD); // baud is defined at build time
Serial.println("\nResetting!");
Serial.begin(BAUD); // baud is defined at build time
Serial.println("\nResetting!");
strip.clear(NUM_LEDS);
strip.clear(NUM_LEDS);
}
// Don't spend too long in this function, we need to read out
@ -20,44 +20,41 @@ void setup() {
void on_serial()
{
// How many times have we read?
static int read = 0;
// should be non blocking
int read_byte = Serial.read();
// How many times have we read?
static int read = 0;
// should be non blocking
int read_byte = Serial.read();
int index = (int) read / 3;
// the first, second, or third byte
switch (read % 3)
{
/*
Idk why it's weird like this RBG, but it's easier to change it here.
*/
case 0: // first
pixels[index].r = read_byte;
break;
case 1: // second
pixels[index].g = read_byte;
break;
default: // third
pixels[index].b = read_byte;
break;
}
// increment or loop
if (read < BUF_SIZE-1) {
read++;
} else {
// Whole frame as been read, send to the leds
strip.sendPixels(NUM_LEDS, pixels);
read=0;
}
int index = (int) read / 3;
// the first, second, or third byte
switch (read % 3)
{
/*
Idk why it's weird like this RBG, but it's easier to change it here.
*/
case 0: // first
pixels[index].r = read_byte;
break;
case 1: // second
pixels[index].g = read_byte;
break;
default: // third
pixels[index].b = read_byte;
break;
}
// increment or loop
if (read < BUF_SIZE-1) {
read++;
} else {
// Whole frame as been read, send to the leds
strip.sendPixels(NUM_LEDS, pixels);
read=0;
}
}
void loop() {
if (Serial.available() > 0) {
on_serial();
}
if (Serial.available() > 0) {
on_serial();
}
}