From a2c5fee6acc7bdc5017ef3b7089e076654ab170c Mon Sep 17 00:00:00 2001 From: Oliver Atkinson Date: Tue, 5 Sep 2023 08:49:30 -0600 Subject: [PATCH] Use 4 space tab like a normal person --- src/main.cpp | 73 +++++++++++++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 684e86c..e06d486 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,10 +9,10 @@ ws2812b 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(); + } }