From f402493d276c29c4d2ec0a758fd3abb776c2c844 Mon Sep 17 00:00:00 2001 From: Nathan Friedly Date: Tue, 29 Mar 2016 10:59:10 -0400 Subject: [PATCH] formatting improvements to RGB example White space-only changes to fix indentation and general consistency withing example --- .../examples/DigisparkRGB/DigisparkRGB.ino | 62 +++++++++---------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/digistump-avr/libraries/DigisparkRGB/examples/DigisparkRGB/DigisparkRGB.ino b/digistump-avr/libraries/DigisparkRGB/examples/DigisparkRGB/DigisparkRGB.ino index 65fa1ca..2217985 100644 --- a/digistump-avr/libraries/DigisparkRGB/examples/DigisparkRGB/DigisparkRGB.ino +++ b/digistump-avr/libraries/DigisparkRGB/examples/DigisparkRGB/DigisparkRGB.ino @@ -13,46 +13,40 @@ byte GREEN = 1; byte COLORS[] = {RED, BLUE, GREEN}; // the setup routine runs once when you press reset: -void setup() { +void setup() { DigisparkRGBBegin(); } -void loop () -{ -//direction: up = true, down = false -boolean dir = true; -int i = 0; +void loop() { + //direction: up = true, down = false + boolean dir = true; + int i = 0; + + while(1) { + fade(COLORS[i%3], dir); + i++; + dir = !dir; + } +} -while(1) -{ -fade(COLORS[i%3], dir); -i++; -dir = !dir; -} -} -void fade(byte Led, boolean dir) -{ -int i; - -//if fading up -if (dir) -{ -for (i = 0; i < 256; i++) -{ -DigisparkRGB(Led, i); -DigisparkRGBDelay(25);//1); -} -} -else -{ -for (i = 255; i >= 0; i--) -{ -DigisparkRGB(Led, i); -DigisparkRGBDelay(25);//1); -} -} +void fade(byte Led, boolean dir) { + int i; + + //if fading up + if (dir) { + for (i = 0; i < 256; i++) { + DigisparkRGB(Led, i); + DigisparkRGBDelay(25);//1); + } + } else { + for (i = 255; i >= 0; i--) { + DigisparkRGB(Led, i); + DigisparkRGBDelay(25);//1); + } + } } +