Fix indentation

Fix indentation

--- taurus.ino
+++ taurus.ino
@@ -51,39 +51,38 @@
 #define LED_PIN 13

 enum Scene {
-		SYMBOL_TAURUS = 0,
-		SYMBOLS_FAST,
-		PLANETS_SYMBOLS_FAST,
-		WORDS_FAST,
-		WORDS_FAST_INLINE,
-		STARS,
-		NOISE,
-		SYMBOL_FADE,
-		SYMBOL_CHECKERBOARD,
-		SYMBOL_GLITCH_SIZE,
-		SYMBOL_GLITCH_LOAD,
-		CONSTELLATIONS,
-		COMMANDS,
-		WORD_CURSOR,
-		WORMHOLE,
-		SYMBOLS_SNAKE,
-		SCROLL_STARS,
-		EYES,
-		CHANNEL,
-		VHS,
-		SYMBOL_SHIFT,
-		BLINDS,
-		FADE_IN,
-		//WHITE_BEAR, // Disable this scene
-		PARTY_WORDS,
-		FILL_LINES,
-		CIRCLES,
-		L_SYSTEM,
-		CLOCK,
-		CHART,
-    	HEX_SCENE,
-		PYRAMID,
-		TOTAL
+    SYMBOL_TAURUS = 0,
+    SYMBOLS_FAST,
+    PLANETS_SYMBOLS_FAST,
+    WORDS_FAST,
+    WORDS_FAST_INLINE,
+    STARS,
+    NOISE,
+    SYMBOL_FADE,
+    SYMBOL_CHECKERBOARD,
+    SYMBOL_GLITCH_SIZE,
+    SYMBOL_GLITCH_LOAD,
+    CONSTELLATIONS,
+    COMMANDS,
+    WORD_CURSOR,
+    WORMHOLE,
+    SYMBOLS_SNAKE,
+    SCROLL_STARS,
+    EYES,
+    CHANNEL,
+    VHS,
+    SYMBOL_SHIFT,
+    BLINDS,
+    FADE_IN,
+    PARTY_WORDS,
+    FILL_LINES,
+    CIRCLES,
+    L_SYSTEM,
+    CLOCK,
+    CHART,
+    HEX_SCENE,
+    PYRAMID,
+    TOTAL
 };

 Scene currentScene = PYRAMID; // Initial scene
@@ -96,196 +95,194 @@
 unsigned char backBuffer[HEIGHT][WIDTH / 8] = { 0 };

 unsigned char inline backBufferGet(int x, int y) {
-		return (backBuffer[y][x / 8] >> (7 - (x % 8))) & 0x01;
+    return (backBuffer[y][x / 8] >> (7 - (x % 8))) & 0x01;
 }

 void backBufferSet(int x, int y, unsigned char c) {
-		if (c == 1) {
-				backBuffer[y][x / 8] |= (0x01 << (7 - (x % 8)));
-		} else {
-				backBuffer[y][x / 8] &= ~(0x01 << (7 - (x % 8)));
-		}
+    if (c == 1) {
+        backBuffer[y][x / 8] |= (0x01 << (7 - (x % 8)));
+    } else {
+        backBuffer[y][x / 8] &= ~(0x01 << (7 - (x % 8)));
+    }
 }

 void screenToBackBuffer() {
-		for (int i = 0; i < WIDTH; i++) {
-				for (int j = 0; j < HEIGHT; j++) {
-						backBufferSet(i, j, TV.get_pixel(i, j));
-				}
-		}
+    for (int i = 0; i < WIDTH; i++) {
+        for (int j = 0; j < HEIGHT; j++) {
+            backBufferSet(i, j, TV.get_pixel(i, j));
+        }
+    }
 }

 void backBufferToScreen() {
-		for (int i = 0; i < WIDTH; i++) {
-				for (int j = 0; j < HEIGHT; j++) {
-						TV.set_pixel(i, j, backBufferGet(i, j));
-				}
-		}
+    for (int i = 0; i < WIDTH; i++) {
+        for (int j = 0; j < HEIGHT; j++) {
+            TV.set_pixel(i, j, backBufferGet(i, j));
+        }
+    }
 }

 const unsigned char* getPlanetSymbol(int i) {
-		switch (i) {
-				case 0:
-					return venus_planet;;
-				case 1:
-					return jupiter_planet;
-				case 2:
-					return mars_planet;
-				case 3:
-					return mercury_planet;
-				case 4:
-					return neptune_planet;
-				case 5:
-					return saturn_planet;
-				case 6:
-					return uranus_planet;
-				default:
-					return venus_planet;
-		}
+    switch (i) {
+        case 0:
+            return venus_planet;;
+        case 1:
+            return jupiter_planet;
+        case 2:
+            return mars_planet;
+        case 3:
+            return mercury_planet;
+        case 4:
+            return neptune_planet;
+        case 5:
+            return saturn_planet;
+        case 6:
+            return uranus_planet;
+        default:
+            return venus_planet;
+    }
 }

 const unsigned char* getSignSymbol(int i) {
-		switch (i) {
-				case 0:
-					return aries_sign;
-				case 1:
-					return taurus_sign;
-				case 2:
-					return gemini_sign;
-				case 3:
-					return cancer_sign;
-				case 4:
-					return leo_sign;
-				case 5:
-					return virgo_sign;
-				case 6:
-					return libra_sign;
-				case 7:
-					return scorpio_sign;
-				case 8:
-					return sagittarius_sign;
-				case 9:
-					return capricorn_sign;
-				case 10:
-					return aquarius_sign;
-				case 11:
-					return pisces_sign;
-				default:
-					return taurus_sign;
-		}
+    switch (i) {
+        case 0:
+            return aries_sign;
+        case 1:
+            return taurus_sign;
+        case 2:
+            return gemini_sign;
+        case 3:
+            return cancer_sign;
+        case 4:
+            return leo_sign;
+        case 5:
+            return virgo_sign;
+        case 6:
+            return libra_sign;
+        case 7:
+            return scorpio_sign;
+        case 8:
+            return sagittarius_sign;
+        case 9:
+            return capricorn_sign;
+        case 10:
+            return aquarius_sign;
+        case 11:
+            return pisces_sign;
+        default:
+            return taurus_sign;
+    }
 }

 const unsigned char* getRandomSymbol() {
-		if (random(2) == 0) {
-			return getSignSymbol(random(SIGN_COUNT));
-		} else {
-			return getPlanetSymbol(random(PLANET_COUNT));
-		}
+    if (random(2) == 0) {
+        return getSignSymbol(random(SIGN_COUNT));
+    } else {
+        return getPlanetSymbol(random(PLANET_COUNT));
+    }
 }

 void blinkForever() {
-		while (true) {
-				digitalWrite(LED_PIN, LOW);
-				delay(500);
-				digitalWrite(LED_PIN, HIGH);
-				delay(500);
-		}
+    while (true) {
+        digitalWrite(LED_PIN, LOW);
+        delay(500);
+        digitalWrite(LED_PIN, HIGH);
+        delay(500);
+    }
 }

 void toCartesian(int x, int y, double degrees, int len, int *endX, int *endY) {
-		int o = (int)(sin((degrees * PI) / 180.0) * len);
-		int a = (int)(cos((degrees * PI) / 180.0) * len);
-
-		*endX = x + a;
-		*endY = y - o;
+    int o = (int)(sin((degrees * PI) / 180.0) * len);
+    int a = (int)(cos((degrees * PI) / 180.0) * len);
+
+    *endX = x + a;
+    *endY = y - o;
 }

 void drawLineAngle(int x, int y, double degrees, int len, int color) {
-		int endX, endY;
-		toCartesian(x, y, degrees, len, &endX, &endY);
-		TV.draw_line(x, y, endX, endY, color);
+    int endX, endY;
+    toCartesian(x, y, degrees, len, &endX, &endY);
+    TV.draw_line(x, y, endX, endY, color);
 }

 void setup() {
-		pinMode(LED_PIN, OUTPUT);
-		digitalWrite(LED_PIN, LOW);
-
-		char err = TV.begin(PAL, WIDTH, HEIGHT);
-		if (err) {
-				blinkForever();
-		}
-
-		TV.clear_screen();
-  		//TV.select_font(font4x6);
-  		TV.select_font(font6x8);
-  		//TV.select_font(font8x8);
-		startTime = TV.millis();
-		randomSeed(analogRead(0) | analogRead(1));
+    pinMode(LED_PIN, OUTPUT);
+    digitalWrite(LED_PIN, LOW);
+
+    char err = TV.begin(PAL, WIDTH, HEIGHT);
+    if (err) {
+        blinkForever();
+    }
+
+    TV.clear_screen();
+    TV.select_font(font6x8);
+    startTime = TV.millis();
+    randomSeed(analogRead(0) | analogRead(1));
 }

 bool checkSceneEnded(long seconds) {
-		if (TV.millis() - startTime > seconds * 1000) {
-				sceneCounter++;
-				if (sceneCounter == TOTAL) {
-						sceneCounter = 0;
-						sequentialMode = !sequentialMode;
-				}
-
-				Scene nextScene = currentScene;
-
-				if (sequentialMode) {
-						nextScene = nextScene + 1;
-						if (nextScene == TOTAL) {
-							nextScene = 0;
-						}
-				}
-				else {
-						while (nextScene == currentScene) {
-							nextScene = (Scene)random(TOTAL);
-						}
-				}
-
-				currentScene = nextScene;
-				return true;
-		}
-
-		return false;
+    if (TV.millis() - startTime > seconds * 1000) {
+        sceneCounter++;
+        if (sceneCounter == TOTAL) {
+            sceneCounter = 0;
+            sequentialMode = !sequentialMode;
+        }
+
+        Scene nextScene = currentScene;
+
+        if (sequentialMode) {
+            nextScene = nextScene + 1;
+            if (nextScene == TOTAL) {
+                nextScene = 0;
+            }
+        }
+        else {
+            while (nextScene == currentScene) {
+                nextScene = (Scene)random(TOTAL);
+            }
+        }
+
+        currentScene = nextScene;
+        return true;
+    }
+
+    return false;
 }

 void testScene() {
-		TV.draw_line(0, 0, WIDTH - 1, HEIGHT - 1, 1);
-		TV.draw_line(0, HEIGHT - 1, WIDTH - 1, 0, 1);
-		TV.draw_line(0, HEIGHT / 2, WIDTH - 1, HEIGHT / 2, 1);
-		TV.draw_line(WIDTH / 2, 0, WIDTH / 2, HEIGHT - 1, 1);
-
-		TV.draw_circle(WIDTH / 2, HEIGHT / 2, 5, 1, 1);
+    TV.draw_line(0, 0, WIDTH - 1, HEIGHT - 1, 1);
+    TV.draw_line(0, HEIGHT - 1, WIDTH - 1, 0, 1);
+    TV.draw_line(0, HEIGHT / 2, WIDTH - 1, HEIGHT / 2, 1);
+    TV.draw_line(WIDTH / 2, 0, WIDTH / 2, HEIGHT - 1, 1);
+
+    TV.draw_circle(WIDTH / 2, HEIGHT / 2, 5, 1, 1);
 }

 void tauroSymbolScene() {
-		const char* s = getSignSymbol(1);
-		TV.bitmap(BMP_X, BMP_Y, s);
-		TV.delay(5000);
-		checkSceneEnded(5);
+    const char* s = getSignSymbol(1);
+    TV.bitmap(BMP_X, BMP_Y, s);
+    TV.delay(5000);
+    checkSceneEnded(5);
 }

 int pyramidBase = HF_WIDTH;
 int pyramidHeight = HEIGHT - 10;
 void pyramidScene(bool changed) {
-	TV.clear_screen();
-	pyramidBase = (sin(TV.millis() / 100.0f) + 1) / 2.0f * HF_WIDTH;
-
-	//base line
-	TV.draw_line(HF_WIDTH + pyramidBase, pyramidHeight, HF_WIDTH - pyramidBase, pyramidHeight, 1);
-
-	//top right line
-	TV.draw_line(HF_WIDTH + pyramidBase, pyramidHeight, HF_WIDTH, 0, 1);
-
-	//top left line
-	TV.draw_line(HF_WIDTH - pyramidBase, pyramidHeight, HF_WIDTH, 0, 1);
-
-	TV.delay(1);
-
-	checkSceneEnded(15);
+    TV.clear_screen();
+    pyramidBase = (sin(TV.millis() / 100.0f) + 1) / 2.0f * HF_WIDTH;
+
+    //base line
+    TV.draw_line(HF_WIDTH + pyramidBase, pyramidHeight, HF_WIDTH - pyramidBase, pyramidHeight, 1);
+
+    //top right line
+    TV.draw_line(HF_WIDTH + pyramidBase, pyramidHeight, HF_WIDTH, 0, 1);
+
+    //top left line
+    TV.draw_line(HF_WIDTH - pyramidBase, pyramidHeight, HF_WIDTH, 0, 1);
+
+    TV.delay(1);
+
+    checkSceneEnded(15);
 }

 const char* hexDigits = "ABCDEF0123456789 ";
@@ -305,260 +302,260 @@
     }
 }

-void starsScene() {
-		int sign = random(SIGN_COUNT);
-
-		TV.clear_screen();
-		TV.set_cursor(0, HEIGHT / 2);
-		TV.print(signs_words[sign + 12]);
-
-		TV.delay(500);
-		TV.clear_screen();
-		const char* s = getSignSymbol(sign);
-		TV.bitmap(BMP_X, BMP_Y, s);
-		TV.delay(500);
-
-		TV.clear_screen();
-		int starCount = random(7, 10);
-		for (int i = 0; i < starCount; i++) {
-				int x = random(WIDTH);
-				int y = random(HEIGHT);
-
-				TV.set_pixel(x, y, 1);
-		}
-		TV.delay(500);
-
-		checkSceneEnded(15);
+void starsScene() {
+    int sign = random(SIGN_COUNT);
+
+    TV.clear_screen();
+    TV.set_cursor(0, HEIGHT / 2);
+    TV.print(signs_words[sign + 12]);
+
+    TV.delay(500);
+    TV.clear_screen();
+    const char* s = getSignSymbol(sign);
+    TV.bitmap(BMP_X, BMP_Y, s);
+    TV.delay(500);
+
+    TV.clear_screen();
+    int starCount = random(7, 10);
+    for (int i = 0; i < starCount; i++) {
+        int x = random(WIDTH);
+        int y = random(HEIGHT);
+
+        TV.set_pixel(x, y, 1);
+    }
+    TV.delay(500);
+
+    checkSceneEnded(15);
 }

 int constellationI = 0;
 void constellationsScene() {
-		TV.clear_screen();
-		int rayCount = random(5, 9);
-
-		int x = random(WIDTH);
-		int y = random(HEIGHT);
-		int x2 = random(WIDTH);
-		int y2 = random(HEIGHT);
-
-		for (int i = 0; i < rayCount; i++) {
-				// Main star
-				TV.draw_line(x, y, x2, y2, 1);
-				x2 = random(WIDTH);
-				y2 = random(HEIGHT);
-		}
-
-		for (int i = 0; i < random(6, 14); i++) {
-				// Background stars
-				TV.set_pixel(random(WIDTH), random(HEIGHT), 1);
-		}
-
-		TV.set_cursor(0, HEIGHT - 8);
-		TV.print(stars_words[constellationI % STARS_WORDS_COUNT]);
-		constellationI++;
-
-		TV.delay(700);
-		//sp(1,1,1);
-
-		checkSceneEnded(20);
+    TV.clear_screen();
+    int rayCount = random(5, 9);
+
+    int x = random(WIDTH);
+    int y = random(HEIGHT);
+    int x2 = random(WIDTH);
+    int y2 = random(HEIGHT);
+
+    for (int i = 0; i < rayCount; i++) {
+        // Main star
+        TV.draw_line(x, y, x2, y2, 1);
+        x2 = random(WIDTH);
+        y2 = random(HEIGHT);
+    }
+
+    for (int i = 0; i < random(6, 14); i++) {
+        // Background stars
+        TV.set_pixel(random(WIDTH), random(HEIGHT), 1);
+    }
+
+    TV.set_cursor(0, HEIGHT - 8);
+    TV.print(stars_words[constellationI % STARS_WORDS_COUNT]);
+    constellationI++;
+
+    TV.delay(700);
+    //sp(1,1,1);
+
+    checkSceneEnded(20);
 }

 int signLoad = -1;
 void symbolGlitchLoadScene(bool changed) {
-		if (changed) {
-				signLoad = random(SIGN_COUNT);
-				const char* s = getSignSymbol(signLoad);
-				TV.bitmap(BMP_X, BMP_Y, s);
-				TV.delay(3000);
-				return;
-		}
-
-		const char* s = getSignSymbol(signLoad);
-		TV.bitmap(BMP_X, BMP_Y, s, 1, IMG_SIZE - random(1, 10), IMG_SIZE - random(1, 10));
-		TV.set_cursor(0, HEIGHT - 8);
-		TV.print(signs_words[12 + signLoad]);
-		TV.print("?");
-		TV.delay(random(100, 250));
-
-		TV.clear_screen();
-		TV.bitmap(BMP_X, BMP_Y, s);
-		TV.delay(1000);
-
-		checkSceneEnded(20);
+    if (changed) {
+        signLoad = random(SIGN_COUNT);
+        const char* s = getSignSymbol(signLoad);
+        TV.bitmap(BMP_X, BMP_Y, s);
+        TV.delay(3000);
+        return;
+    }
+
+    const char* s = getSignSymbol(signLoad);
+    TV.bitmap(BMP_X, BMP_Y, s, 1, IMG_SIZE - random(1, 10), IMG_SIZE - random(1, 10));
+    TV.set_cursor(0, HEIGHT - 8);
+    TV.print(signs_words[12 + signLoad]);
+    TV.print("?");
+    TV.delay(random(100, 250));
+
+    TV.clear_screen();
+    TV.bitmap(BMP_X, BMP_Y, s);
+    TV.delay(1000);
+
+    checkSceneEnded(20);
 }

 void symbolFadeScene(bool changed) {
-		if (changed) {
-				int sign = random(SIGN_COUNT);
-				const char* s = getSignSymbol(sign);
-				TV.bitmap(BMP_X, BMP_Y, s);
-				screenToBackBuffer();
-				TV.clear_screen();
-		}
-
-		int x = random(WIDTH);
-		int y = random(HEIGHT);
-		unsigned char c = backBufferGet(x, y);
-		TV.set_pixel(x, y, !c);
-
-		checkSceneEnded(20);
+    if (changed) {
+        int sign = random(SIGN_COUNT);
+        const char* s = getSignSymbol(sign);
+        TV.bitmap(BMP_X, BMP_Y, s);
+        screenToBackBuffer();
+        TV.clear_screen();
+    }
+
+    int x = random(WIDTH);
+    int y = random(HEIGHT);
+    unsigned char c = backBufferGet(x, y);
+    TV.set_pixel(x, y, !c);
+
+    checkSceneEnded(20);
 }

 int cmdIdx = 0;
 void commandsScene() {
-		if (cmdIdx < CMDS_WORDS_COUNT) {
-				TV.println(cmds_words[cmdIdx % CMDS_WORDS_COUNT]);
-				cmdIdx++;
-				TV.delay(900);
-		}
-
-		if (checkSceneEnded(15)) {
-				cmdIdx = 0;
-		}
+    if (cmdIdx < CMDS_WORDS_COUNT) {
+        TV.println(cmds_words[cmdIdx % CMDS_WORDS_COUNT]);
+        cmdIdx++;
+        TV.delay(900);
+    }
+
+    if (checkSceneEnded(15)) {
+        cmdIdx = 0;
+    }
 }

 int glitchSign = -1;
 void symbolCheckerboardScene(bool changed) {
-		if (changed) {
-				glitchSign = random(SIGN_COUNT);
-				const char* s = getSignSymbol(glitchSign);
-				TV.bitmap(BMP_X, BMP_Y, s);
-
-				for (int x = 0; x < WIDTH; x++) {
-						for (int y = 0; y < HEIGHT; y++) {
-								if ((x < WIDTH / 2 && y < HEIGHT / 2) || (x >= WIDTH / 2 && y >= HEIGHT / 2)) {
-										unsigned char c = TV.get_pixel(x, y);
-										TV.set_pixel(x, y, !c);
-								}
-						}
-				}
-		}
-
-		for (int x = 0; x < WIDTH; x++) {
-				for (int y = 0; y < HEIGHT; y++) {
-						unsigned char c = TV.get_pixel(x, y);
-						TV.set_pixel(x, y, !c);
-				}
-		}
-
-		TV.delay(50);
-
-		checkSceneEnded(10);
+    if (changed) {
+        glitchSign = random(SIGN_COUNT);
+        const char* s = getSignSymbol(glitchSign);
+        TV.bitmap(BMP_X, BMP_Y, s);
+
+        for (int x = 0; x < WIDTH; x++) {
+            for (int y = 0; y < HEIGHT; y++) {
+                if ((x < WIDTH / 2 && y < HEIGHT / 2) || (x >= WIDTH / 2 && y >= HEIGHT / 2)) {
+                    unsigned char c = TV.get_pixel(x, y);
+                    TV.set_pixel(x, y, !c);
+                }
+            }
+        }
+    }
+
+    for (int x = 0; x < WIDTH; x++) {
+        for (int y = 0; y < HEIGHT; y++) {
+            unsigned char c = TV.get_pixel(x, y);
+            TV.set_pixel(x, y, !c);
+        }
+    }
+
+    TV.delay(50);
+
+    checkSceneEnded(10);
 }

 void symbolGlitchSizeScene() {
-		TV.clear_screen();
-		const char* s = getSignSymbol(random(SIGN_COUNT));
-		TV.bitmap(BMP_X, BMP_Y, s, 0, IMG_SIZE - random(0, 10), IMG_SIZE - random(0, 10));
-		TV.delay(random(20, 250));
-
-		if (checkSceneEnded(20)) {
-				int mid = HEIGHT / 2;
-				const char* word = errors_words[random(ERRORS_WORDS_COUNT)];
-				int xOffset = (strlen(word) * FONT_W) / 2;
-				int yOffset = FONT_H / 2;
-
-				for (int i = 0; i < 50; i++) { //flashes
-						TV.draw_rect(0, mid - FONT_H, WIDTH, FONT_H * 2, 0, 0);
-						TV.set_cursor((WIDTH / 2) - xOffset, (HEIGHT / 2) - yOffset);
-						if (i % 2 == 0) {
-								TV.print(word);
-						}
-
-						TV.delay(200);
-				}
-		}
+    TV.clear_screen();
+    const char* s = getSignSymbol(random(SIGN_COUNT));
+    TV.bitmap(BMP_X, BMP_Y, s, 0, IMG_SIZE - random(0, 10), IMG_SIZE - random(0, 10));
+    TV.delay(random(20, 250));
+
+    if (checkSceneEnded(20)) {
+        int mid = HEIGHT / 2;
+        const char* word = errors_words[random(ERRORS_WORDS_COUNT)];
+        int xOffset = (strlen(word) * FONT_W) / 2;
+        int yOffset = FONT_H / 2;
+
+        for (int i = 0; i < 50; i++) { //flashes
+            TV.draw_rect(0, mid - FONT_H, WIDTH, FONT_H * 2, 0, 0);
+            TV.set_cursor((WIDTH / 2) - xOffset, (HEIGHT / 2) - yOffset);
+            if (i % 2 == 0) {
+                TV.print(word);
+            }
+
+            TV.delay(200);
+        }
+    }
 }

 void noiseScene() {
-		for (int i = 0; i < 30; i++) {
-				TV.set_pixel(random(WIDTH), random(HEIGHT), random(3));
-		}
-
-		if (checkSceneEnded(8)) {
-				TV.delay(1000);
-		}
+    for (int i = 0; i < 30; i++) {
+        TV.set_pixel(random(WIDTH), random(HEIGHT), random(3));
+    }
+
+    if (checkSceneEnded(8)) {
+        TV.delay(1000);
+    }
 }

 void fastWordsScene() {
-		if (random(4) == 0) {
-				TV.print("_");
-		}
-		TV.println(signs_words[random(SIGNS_WORDS_COUNT)]);
-		TV.delay(150);
-		checkSceneEnded(10);
+    if (random(4) == 0) {
+        TV.print("_");
+    }
+    TV.println(signs_words[random(SIGNS_WORDS_COUNT)]);
+    TV.delay(150);
+    checkSceneEnded(10);
 }

 void wordsFastInlineScene() {
-		TV.clear_screen();
-		TV.set_cursor(0, (HEIGHT / 2) - (FONT_H / 2));
-		TV.print(signs_words[SIGN_COUNT + random(SIGN_COUNT)]);
-		TV.delay(120);
-
-		checkSceneEnded(10);
+    TV.clear_screen();
+    TV.set_cursor(0, (HEIGHT / 2) - (FONT_H / 2));
+    TV.print(signs_words[SIGN_COUNT + random(SIGN_COUNT)]);
+    TV.delay(120);
+
+    checkSceneEnded(10);
 }

 int fssI = 0;
 void fastSymbolsScene() {
-		const char* s = getSignSymbol(fssI % SIGN_COUNT);
-		TV.bitmap(BMP_X, BMP_Y, s);
-		TV.delay(150);
-		fssI++;
-
-		checkSceneEnded(20);
+    const char* s = getSignSymbol(fssI % SIGN_COUNT);
+    TV.bitmap(BMP_X, BMP_Y, s);
+    TV.delay(150);
+    fssI++;
+
+    checkSceneEnded(20);
 }

 void planetSymbolsFastScene() {
-		const char* s = getPlanetSymbol(fssI % PLANET_COUNT);
-		TV.bitmap(BMP_X, BMP_Y, s);
-		TV.delay(150);
-		fssI++;
-
-		checkSceneEnded(20);
+    const char* s = getPlanetSymbol(fssI % PLANET_COUNT);
+    TV.bitmap(BMP_X, BMP_Y, s);
+    TV.delay(150);
+    fssI++;
+
+    checkSceneEnded(20);
 }

 char *cursorWord = NULL;
 int cursorIdx = 0;
 void wordCursorScene(bool changed) {
-		if (changed) {
-				cursorWord = signs_words[SIGN_COUNT + random(SIGN_COUNT)];
-				cursorIdx = 0;
-		}
-
-		if (cursorWord[cursorIdx]) {
-				char randChar = random(65, 91);
-				TV.set_cursor(cursorIdx * FONT_W, (HEIGHT / 2) - (FONT_H / 2));
-
-				TV.print(randChar);
-
-				if (cursorWord[cursorIdx] == randChar) {
-					cursorIdx++;
-				}
-
-				TV.delay(50);
-
-				if (!cursorWord[cursorIdx]) {
-					TV.print(" LOADED.");
-				}
-		}
-
-		checkSceneEnded(15);
+    if (changed) {
+        cursorWord = signs_words[SIGN_COUNT + random(SIGN_COUNT)];
+        cursorIdx = 0;
+    }
+
+    if (cursorWord[cursorIdx]) {
+        char randChar = random(65, 91);
+        TV.set_cursor(cursorIdx * FONT_W, (HEIGHT / 2) - (FONT_H / 2));
+
+        TV.print(randChar);
+
+        if (cursorWord[cursorIdx] == randChar) {
+            cursorIdx++;
+        }
+
+        TV.delay(50);
+
+        if (!cursorWord[cursorIdx]) {
+            TV.print(" LOADED.");
+        }
+    }
+
+    checkSceneEnded(15);
 }

 void wormholeScene(bool changed) {
-		TV.clear_screen();
-		int circleCount = random(3, 7);
-		for (int i = 0; i < circleCount; i++) {
-				TV.draw_circle(WIDTH / 2, HEIGHT / 2, random(HEIGHT / 2), WHITE, BLACK);
-		}
-
-		TV.delay(120);
-
-		checkSceneEnded(8);
+    TV.clear_screen();
+    int circleCount = random(3, 7);
+    for (int i = 0; i < circleCount; i++) {
+        TV.draw_circle(WIDTH / 2, HEIGHT / 2, random(HEIGHT / 2), WHITE, BLACK);
+    }
+
+    TV.delay(120);
+
+    checkSceneEnded(8);
 }

 enum Orientation {
-	Tau_NE, Tau_SE, Tau_SW, Tau_NW, TOTAL_ORIENTATION
+    Tau_NE, Tau_SE, Tau_SW, Tau_NW, TOTAL_ORIENTATION
 };

 unsigned char *lastSnakeBmp = NULL;
@@ -567,179 +564,179 @@
 int snakeY = HEIGHT / 2;
 unsigned long lastReset = 0;
 void symbolsSnakeScene(bool changed) {
-		if (changed) {
-				lastSnakeBmp = getRandomSymbol();
-
-				TV.bitmap(BMP_X, BMP_Y, lastSnakeBmp);
-
-				lastReset = TV.millis();
-				snakeX = WIDTH / 2;
-				snakeY = HEIGHT / 2;
-		}
-
-		if (TV.millis() - lastReset > 2000) {
-				TV.clear_screen();
-				TV.bitmap(BMP_X, BMP_Y, lastSnakeBmp);
-				lastReset = TV.millis();
-				snakeX = WIDTH / 2;
-				snakeY = HEIGHT / 2;
-				orientation = random((int)TOTAL_ORIENTATION);
-		}
-
-		unsigned char currentColor = TV.get_pixel(snakeX, snakeY);
-		TV.set_pixel(snakeX, snakeY, !currentColor);
-
-		switch (orientation) {
-				case Tau_NE:
-					snakeY--;
-					snakeX++;
-				break;
-				case Tau_SE:
-					snakeY++;
-					snakeX++;
-				break;
-				case Tau_SW:
-					snakeX--;
-					snakeY++;
-				break;
-				case Tau_NW:
-					snakeX--;
-					snakeY--;
-				break;
-		}
-
-		if (snakeX < 0) {
-				snakeX = WIDTH;
-		} else if (snakeX > WIDTH) {
-				snakeX = 0;
-		}
-
-		if (snakeY < 0) {
-				snakeY = HEIGHT;
-		} else if (snakeY > HEIGHT) {
-				snakeY = 0;
-		}
-
-		unsigned char newColor = TV.get_pixel(snakeX, snakeY);
-
-		if (newColor != currentColor) {
-				orientation = orientation + 1;
-				orientation = orientation % TOTAL_ORIENTATION;
-		}
-
-		checkSceneEnded(20);
+    if (changed) {
+        lastSnakeBmp = getRandomSymbol();
+
+        TV.bitmap(BMP_X, BMP_Y, lastSnakeBmp);
+
+        lastReset = TV.millis();
+        snakeX = WIDTH / 2;
+        snakeY = HEIGHT / 2;
+    }
+
+    if (TV.millis() - lastReset > 2000) {
+        TV.clear_screen();
+        TV.bitmap(BMP_X, BMP_Y, lastSnakeBmp);
+        lastReset = TV.millis();
+        snakeX = WIDTH / 2;
+        snakeY = HEIGHT / 2;
+        orientation = random((int)TOTAL_ORIENTATION);
+    }
+
+    unsigned char currentColor = TV.get_pixel(snakeX, snakeY);
+    TV.set_pixel(snakeX, snakeY, !currentColor);
+
+    switch (orientation) {
+        case Tau_NE:
+            snakeY--;
+            snakeX++;
+        break;
+        case Tau_SE:
+            snakeY++;
+            snakeX++;
+        break;
+        case Tau_SW:
+            snakeX--;
+            snakeY++;
+        break;
+        case Tau_NW:
+            snakeX--;
+            snakeY--;
+        break;
+    }
+
+    if (snakeX < 0) {
+        snakeX = WIDTH;
+    } else if (snakeX > WIDTH) {
+        snakeX = 0;
+    }
+
+    if (snakeY < 0) {
+        snakeY = HEIGHT;
+    } else if (snakeY > HEIGHT) {
+        snakeY = 0;
+    }
+
+    unsigned char newColor = TV.get_pixel(snakeX, snakeY);
+
+    if (newColor != currentColor) {
+        orientation = orientation + 1;
+        orientation = orientation % TOTAL_ORIENTATION;
+    }
+
+    checkSceneEnded(20);
 }

 void scrollStarsScene(bool changed) {
-		if (changed) {
-				// Draw the earth
-				TV.draw_circle(WIDTH / 2, HEIGHT / 2, HEIGHT / 2, WHITE, WHITE);
-		}
-
-		TV.shift(1, 1);
-
-		// Place a new star on top line
-		if (random(7) == 0) {
-				TV.set_pixel(random(WIDTH), 0, 1);
-		}
-
-		TV.delay(100);
-
-		if (checkSceneEnded(12)) {
-				TV.delay(1000);
-		}
+    if (changed) {
+        // Draw the earth
+        TV.draw_circle(WIDTH / 2, HEIGHT / 2, HEIGHT / 2, WHITE, WHITE);
+    }
+
+    TV.shift(1, 1);
+
+    // Place a new star on top line
+    if (random(7) == 0) {
+        TV.set_pixel(random(WIDTH), 0, 1);
+    }
+
+    TV.delay(100);
+
+    if (checkSceneEnded(12)) {
+        TV.delay(1000);
+    }
 }

 void eyesScene(bool changed) {
-		TV.bitmap(BMP_X, BMP_Y, open_eye);
-
-		int irisRadius = 6;
-		int irisOffset = -irisRadius + random(irisRadius * 2);
-		TV.draw_circle((WIDTH / 2) + irisOffset, HEIGHT / 2, irisRadius, 1, 1);
-
-		TV.delay(1200);
-
-		TV.bitmap(BMP_X, BMP_Y, closed_eye);
-
-		TV.delay(random(200, 600));
-
-		checkSceneEnded(20);
+    TV.bitmap(BMP_X, BMP_Y, open_eye);
+
+    int irisRadius = 6;
+    int irisOffset = -irisRadius + random(irisRadius * 2);
+    TV.draw_circle((WIDTH / 2) + irisOffset, HEIGHT / 2, irisRadius, 1, 1);
+
+    TV.delay(1200);
+
+    TV.bitmap(BMP_X, BMP_Y, closed_eye);
+
+    TV.delay(random(200, 600));
+
+    checkSceneEnded(20);
 }

 void channelScene(bool changed) {
-		if (changed) {
-				char *s = "VIDEO 1";
-				TV.set_cursor(WIDTH - (strlen(s) * FONT_W) - 2, FONT_H + 2);
-				TV.print(s);
-		}
-
-		TV.delay(1);
-
-		checkSceneEnded(8);
+    if (changed) {
+        char *s = "VIDEO 1";
+        TV.set_cursor(WIDTH - (strlen(s) * FONT_W) - 2, FONT_H + 2);
+        TV.print(s);
+    }
+
+    TV.delay(1);
+
+    checkSceneEnded(8);
 }

 int vhsTime = 0;
 void vhsScene(bool changed) {
-		char *stop = "STOP";
-		char *play = "PLAY";
-		const int timerWidth = 5;
-		char *timer = "--:--";
-
-		if (changed) {
-				vhsTime = 0;
-				TV.set_cursor(2, FONT_H + 2);
-				TV.print(stop);
-
-				TV.set_cursor(WIDTH - (timerWidth * FONT_W) - 2, FONT_H + 2);
-				TV.print(timer);
-
-				TV.delay(3500);
-				TV.clear_screen();
-
-				TV.set_cursor(2, FONT_H + 2);
-				TV.print(play);
-
-				return;
-		}
-
-		TV.set_cursor(WIDTH - (timerWidth * FONT_W) - 2, FONT_H + 2);
-		TV.print("00:0");
-		TV.print(vhsTime % 10);
-		vhsTime++;
-
-		TV.delay(1000);
-
-		checkSceneEnded(9);
+    char *stop = "STOP";
+    char *play = "PLAY";
+    const int timerWidth = 5;
+    char *timer = "--:--";
+
+    if (changed) {
+        vhsTime = 0;
+        TV.set_cursor(2, FONT_H + 2);
+        TV.print(stop);
+
+        TV.set_cursor(WIDTH - (timerWidth * FONT_W) - 2, FONT_H + 2);
+        TV.print(timer);
+
+        TV.delay(3500);
+        TV.clear_screen();
+
+        TV.set_cursor(2, FONT_H + 2);
+        TV.print(play);
+
+        return;
+    }
+
+    TV.set_cursor(WIDTH - (timerWidth * FONT_W) - 2, FONT_H + 2);
+    TV.print("00:0");
+    TV.print(vhsTime % 10);
+    vhsTime++;
+
+    TV.delay(1000);
+
+    checkSceneEnded(9);
 }

 void shiftLine(int orientation, int direction, int index, int step) {
-		if (orientation == 0) {
-				// Shift column
-				if (direction == 1) {
-						for (int i = HEIGHT - 2; i >= 0; i--) {
-								unsigned char pix = TV.get_pixel(index, i);
-								TV.set_pixel(index, i + step, pix);
-						}
-				} else {
-						for (int i = 1; i <= HEIGHT - 1; i++) {
-								unsigned char pix = TV.get_pixel(index, i);
-								TV.set_pixel(index, i - step, pix);
-						}
-				}
-		} else {
-				// Shift row
-				if (direction == 1) {
-						for (int i = WIDTH - 2; i >= 0; i--) {
-								unsigned char pix = TV.get_pixel(i, index);
-								TV.set_pixel(i + step, index, pix);
-						}
-				} else {
-						for (int i = 1; i <= WIDTH - 1; i++) {
-								unsigned char pix = TV.get_pixel(i, index);
-								TV.set_pixel(i - step, index, pix);
-						}
-				}
-		}
+    if (orientation == 0) {
+        // Shift column
+        if (direction == 1) {
+            for (int i = HEIGHT - 2; i >= 0; i--) {
+                unsigned char pix = TV.get_pixel(index, i);
+                TV.set_pixel(index, i + step, pix);
+            }
+        } else {
+            for (int i = 1; i <= HEIGHT - 1; i++) {
+                unsigned char pix = TV.get_pixel(index, i);
+                TV.set_pixel(index, i - step, pix);
+            }
+        }
+    } else {
+        // Shift row
+        if (direction == 1) {
+            for (int i = WIDTH - 2; i >= 0; i--) {
+                unsigned char pix = TV.get_pixel(i, index);
+                TV.set_pixel(i + step, index, pix);
+            }
+        } else {
+            for (int i = 1; i <= WIDTH - 1; i++) {
+                unsigned char pix = TV.get_pixel(i, index);
+                TV.set_pixel(i - step, index, pix);
+            }
+        }
+    }
 }

 #define STEP_COUNT 300
@@ -748,180 +745,163 @@
 int stepIdx = 0;
 unsigned char *shiftSymbol = NULL;
 void symbolShiftScene(bool changed) {
-		if (changed) {
-				rewinding = false;
-				stepIdx = 0;
-
-				shiftSymbol = getRandomSymbol();
-
-				TV.bitmap(BMP_X, BMP_Y, shiftSymbol);
-				TV.delay(1000);
-		}
-
-		int direction, step, col, row, orientation;
-
-		if (!rewinding) {
-				direction = random(2);
-				step = random(1, 6);
-				col = random(WIDTH);
-				row = random(HEIGHT);
-				orientation = random(2);
-
-				steps[stepIdx][0] = orientation;
-				steps[stepIdx][1] = direction;
-				steps[stepIdx][2] = (orientation == 0) ? col : row;
-				steps[stepIdx][3] = step;
-
-				stepIdx++;
-				if (stepIdx == STEP_COUNT) {
-						rewinding = true;
-				}
-		} else if (stepIdx >= 0) {
-				orientation = steps[stepIdx][0];
-				direction = (steps[stepIdx][1] == 0) ? 1 : 0;
-				col = row = steps[stepIdx][2];
-				step = steps[stepIdx][3];
-
-				stepIdx--;
-		} else {
-				TV.bitmap(BMP_X, BMP_Y, shiftSymbol);
-				rewinding = false;
-				stepIdx = 0;
-				TV.delay(200);
-		}
-
-		shiftLine(orientation, direction, (orientation == 0) ? col : row, step);
-
-		if (checkSceneEnded(30)) {
-				TV.delay(1500);
-		}
+    if (changed) {
+        rewinding = false;
+        stepIdx = 0;
+
+        shiftSymbol = getRandomSymbol();
+
+        TV.bitmap(BMP_X, BMP_Y, shiftSymbol);
+        TV.delay(1000);
+    }
+
+    int direction, step, col, row, orientation;
+
+    if (!rewinding) {
+        direction = random(2);
+        step = random(1, 6);
+        col = random(WIDTH);
+        row = random(HEIGHT);
+        orientation = random(2);
+
+        steps[stepIdx][0] = orientation;
+        steps[stepIdx][1] = direction;
+        steps[stepIdx][2] = (orientation == 0) ? col : row;
+        steps[stepIdx][3] = step;
+
+        stepIdx++;
+        if (stepIdx == STEP_COUNT) {
+            rewinding = true;
+        }
+    } else if (stepIdx >= 0) {
+        orientation = steps[stepIdx][0];
+        direction = (steps[stepIdx][1] == 0) ? 1 : 0;
+        col = row = steps[stepIdx][2];
+        step = steps[stepIdx][3];
+
+        stepIdx--;
+    } else {
+        TV.bitmap(BMP_X, BMP_Y, shiftSymbol);
+        rewinding = false;
+        stepIdx = 0;
+        TV.delay(200);
+    }
+
+    shiftLine(orientation, direction, (orientation == 0) ? col : row, step);
+
+    if (checkSceneEnded(30)) {
+        TV.delay(1500);
+    }
 }

 void blindsScene(bool changed) {
-		if (changed) {
-				TV.bitmap(BMP_X, BMP_Y, getRandomSymbol());
-				screenToBackBuffer();
-				TV.clear_screen();
-		}
-
-		for (int i = 0; i < HEIGHT; i++) {
-				for (int j = 0; j < WIDTH / 8; j++) {
-						backBuffer[i][j] += 1;
-				}
-		}
-
-		backBufferToScreen();
-
-		checkSceneEnded(20);
+    if (changed) {
+        TV.bitmap(BMP_X, BMP_Y, getRandomSymbol());
+        screenToBackBuffer();
+        TV.clear_screen();
+    }
+
+    for (int i = 0; i < HEIGHT; i++) {
+        for (int j = 0; j < WIDTH / 8; j++) {
+            backBuffer[i][j] += 1;
+        }
+    }
+
+    backBufferToScreen();
+
+    checkSceneEnded(20);
 }

 void fadeInScene(bool changed) {
-		if (changed) {
-				TV.bitmap(BMP_X, BMP_Y, getRandomSymbol());
-				screenToBackBuffer();
-				TV.clear_screen();
-		}
-
-		int x = random(WIDTH);
-		int y = random(HEIGHT);
-
-		if (backBufferGet(x, y)) {
-				TV.set_pixel(x, y, 1);
-		}
-
-		if (checkSceneEnded(20)) {
-				TV.delay(1000);
-		}
-}
-
-void whiteBearScene(bool changed) {
-		if (changed) {
-				TV.bitmap(BMP_X, BMP_Y, white_bear);
-				TV.delay(3000);
-				return;
-		}
-
-		TV.bitmap(BMP_X, BMP_Y, white_bear, 0, IMG_SIZE - random(1, 10), IMG_SIZE - random(1, 10));
-		TV.delay(random(50, 200));
-
-		TV.clear_screen();
-		TV.bitmap(BMP_X, BMP_Y, white_bear);
-		TV.delay(1000);
-
-		checkSceneEnded(15);
+    if (changed) {
+        TV.bitmap(BMP_X, BMP_Y, getRandomSymbol());
+        screenToBackBuffer();
+        TV.clear_screen();
+    }
+
+    int x = random(WIDTH);
+    int y = random(HEIGHT);
+
+    if (backBufferGet(x, y)) {
+        TV.set_pixel(x, y, 1);
+    }
+
+    if (checkSceneEnded(20)) {
+        TV.delay(1000);
+    }
 }

 int partyIdx = 0;
 void partyWordsScene() {
-		TV.clear_screen();
-		TV.set_cursor(0, (HEIGHT / 2) - (FONT_H / 2));
-		TV.print(event_words[partyIdx % EVENT_WORDS_COUNT]);
-		TV.delay(140);
-
-		partyIdx++;
-
-		if (checkSceneEnded(10)) {
-				TV.set_cursor(0, (HEIGHT / 2) - (FONT_H / 2));
-				TV.print("ORGULLO TAURINO II.");
-				TV.delay(3000);
-		}
+    TV.clear_screen();
+    TV.set_cursor(0, (HEIGHT / 2) - (FONT_H / 2));
+    TV.print(event_words[partyIdx % EVENT_WORDS_COUNT]);
+    TV.delay(140);
+
+    partyIdx++;
+
+    if (checkSceneEnded(10)) {
+        TV.set_cursor(0, (HEIGHT / 2) - (FONT_H / 2));
+        TV.print("ORGULLO TAURINO II.");
+        TV.delay(3000);
+    }
 }

 int fillLinesDirection = 0;
 void fillLinesScene(bool changed) {
-		if (changed) {
-				TV.bitmap(BMP_X, BMP_Y, getRandomSymbol());
-				screenToBackBuffer();
-				TV.clear_screen();
-				fillLinesDirection = random(4);
-		}
-
-		int x = random(WIDTH);
-		int y = random(HEIGHT);
-
-		while (!backBufferGet(x, y)) {
-				TV.set_pixel(x, y, 1);
-
-				switch (fillLinesDirection) {
-						case UP:
-								y--;
-								break;
-						case DOWN:
-								y++;
-								break;
-						case RIGHT:
-								x++;
-								break;
-						case LEFT:
-								x--;
-								break;
-				}
-
-				if (x < 0 || x > WIDTH - 1 || y < 0 || y > HEIGHT - 1) {
-						break;
-				}
-		}
-
-		TV.delay_frame(1);
-
-		checkSceneEnded(25);
+    if (changed) {
+        TV.bitmap(BMP_X, BMP_Y, getRandomSymbol());
+        screenToBackBuffer();
+        TV.clear_screen();
+        fillLinesDirection = random(4);
+    }
+
+    int x = random(WIDTH);
+    int y = random(HEIGHT);
+
+    while (!backBufferGet(x, y)) {
+        TV.set_pixel(x, y, 1);
+
+        switch (fillLinesDirection) {
+            case UP:
+                y--;
+                break;
+            case DOWN:
+                y++;
+                break;
+            case RIGHT:
+                x++;
+                break;
+            case LEFT:
+                x--;
+                break;
+        }
+
+        if (x < 0 || x > WIDTH - 1 || y < 0 || y > HEIGHT - 1) {
+            break;
+        }
+    }
+
+    TV.delay_frame(1);
+
+    checkSceneEnded(25);
 }

 unsigned int circleCounter = 0;
 void circlesScene(bool changed) {
-		if (changed) {
-
-		}
-
-		for (int i = 0; i < HEIGHT / 2; i++) {
-				TV.draw_circle(WIDTH / 2, HEIGHT / 2, i, (i + circleCounter) % 2);
-				TV.delay_frame(1);
-		}
-
-		circleCounter++;
-
-		checkSceneEnded(15);
+    if (changed) {
+
+    }
+
+    for (int i = 0; i < HEIGHT / 2; i++) {
+        TV.draw_circle(WIDTH / 2, HEIGHT / 2, i, (i + circleCounter) % 2);
+        TV.delay_frame(1);
+    }
+
+    circleCounter++;
+
+    checkSceneEnded(15);
 }

 int startLen = 40;
@@ -932,39 +912,39 @@
 int treeXOffset = 0;

 void lSystemRecursive(int x, int y, double angle, int len) {
-		if (len < 1) {
-				return;
-		}
-
-		drawLineAngle(x, y, angle, len, 1);
-		int endX, endY;
-		toCartesian(x, y, angle, len, &endX, &endY);
-
-		double startAngle = angle + ((branchAngle * (branches - 1)) / 2.0) + angleOffset;
-		for (int i = 0; i < branches; i++) {
-				double a = startAngle - (i * branchAngle);
-				if (random(rouletteDenominator) != 0) {
-						lSystemRecursive(endX, endY, a, len / 2);
-				}
-		}
+    if (len < 1) {
+        return;
+    }
+
+    drawLineAngle(x, y, angle, len, 1);
+    int endX, endY;
+    toCartesian(x, y, angle, len, &endX, &endY);
+
+    double startAngle = angle + ((branchAngle * (branches - 1)) / 2.0) + angleOffset;
+    for (int i = 0; i < branches; i++) {
+        double a = startAngle - (i * branchAngle);
+        if (random(rouletteDenominator) != 0) {
+            lSystemRecursive(endX, endY, a, len / 2);
+        }
+    }
 }

 void drawLSystem() {
-		startLen = random(30, 50);
-		branches = random(3, 5);
-		branchAngle = random(25, 40);
-		angleOffset = -10 + random(20);
-		rouletteDenominator = random(3, 5);
-		treeXOffset = -20 + random(40);
-		lSystemRecursive(treeXOffset + (WIDTH / 2), HEIGHT - 1, 90.0 + angleOffset, startLen);
+    startLen = random(30, 50);
+    branches = random(3, 5);
+    branchAngle = random(25, 40);
+    angleOffset = -10 + random(20);
+    rouletteDenominator = random(3, 5);
+    treeXOffset = -20 + random(40);
+    lSystemRecursive(treeXOffset + (WIDTH / 2), HEIGHT - 1, 90.0 + angleOffset, startLen);
 }

 void lSystemScene() {
-		drawLSystem();
-		TV.delay(200);
-		TV.clear_screen();
-
-		checkSceneEnded(20);
+    drawLSystem();
+    TV.delay(200);
+    TV.clear_screen();
+
+    checkSceneEnded(20);
 }

 double currentAngle, hourAngle, minuteAngle;
@@ -974,172 +954,169 @@
 const int minutesLen = maxRadius - 13;
 const int hoursLen = maxRadius - 22;
 void clockScene(bool changed) {
-		if (changed) {
-				TV.draw_circle(WIDTH / 2, HEIGHT / 2, maxRadius, 1, 0);
-
-				currentAngle = random(60) * angleDiff;
-				hourAngle = random(60) * angleDiff;
-				minuteAngle = random(60) * angleDiff;
-		}
-
-		drawLineAngle(WIDTH / 2, HEIGHT / 2, currentAngle, secondsLen, 0);
-		drawLineAngle(WIDTH / 2, HEIGHT / 2, minuteAngle, minutesLen, 0);
-
-		currentAngle -= angleDiff;
-		minuteAngle -= angleDiff / 60.0;
-		// Dont bother updating hours
-
-		drawLineAngle(WIDTH / 2, HEIGHT / 2, currentAngle, secondsLen, 1);
-		drawLineAngle(WIDTH / 2, HEIGHT / 2, hourAngle, hoursLen, 1);
-		drawLineAngle(WIDTH / 2, HEIGHT / 2, minuteAngle, minutesLen, 1);
-
-		checkSceneEnded(15);
+    if (changed) {
+        TV.draw_circle(WIDTH / 2, HEIGHT / 2, maxRadius, 1, 0);
+
+        currentAngle = random(60) * angleDiff;
+        hourAngle = random(60) * angleDiff;
+        minuteAngle = random(60) * angleDiff;
+    }
+
+    drawLineAngle(WIDTH / 2, HEIGHT / 2, currentAngle, secondsLen, 0);
+    drawLineAngle(WIDTH / 2, HEIGHT / 2, minuteAngle, minutesLen, 0);
+
+    currentAngle -= angleDiff;
+    minuteAngle -= angleDiff / 60.0;
+    // Dont bother updating hours
+
+    drawLineAngle(WIDTH / 2, HEIGHT / 2, currentAngle, secondsLen, 1);
+    drawLineAngle(WIDTH / 2, HEIGHT / 2, hourAngle, hoursLen, 1);
+    drawLineAngle(WIDTH / 2, HEIGHT / 2, minuteAngle, minutesLen, 1);
+
+    checkSceneEnded(15);
 }

 double chartRayLen = 0;
 void chartScene(bool changed) {
-		const int chartRadius = (HEIGHT / 2) - 6;
-		if (changed) {
-				chartRayLen = 0;
-				TV.draw_circle(WIDTH / 2, HEIGHT / 2, chartRadius, 1, 0);
-				TV.draw_circle(WIDTH / 2, HEIGHT / 2, chartRadius - 7, 1, 0);
-				TV.draw_circle(WIDTH / 2, HEIGHT / 2, 12, 1, 0);
-
-				for (int i = 0; i < 12; i++) {
-						drawLineAngle(WIDTH / 2, HEIGHT / 2, i * (360.0 / 12), chartRadius, 1);
-				}
-
-				TV.delay(2000);
-		}
-
-		int rays = random(2, 7);
-		double offset = random(180);
-		for (int i = 0; i < rays; i++) {
-				drawLineAngle(WIDTH / 2, HEIGHT / 2, (i * (360.0 / rays)) + offset, chartRayLen + (chartRadius / 2), 1);
-		}
-
-		TV.delay(50);
-		chartRayLen += 0.2;
-
-		checkSceneEnded(20);
+    const int chartRadius = (HEIGHT / 2) - 6;
+    if (changed) {
+        chartRayLen = 0;
+        TV.draw_circle(WIDTH / 2, HEIGHT / 2, chartRadius, 1, 0);
+        TV.draw_circle(WIDTH / 2, HEIGHT / 2, chartRadius - 7, 1, 0);
+        TV.draw_circle(WIDTH / 2, HEIGHT / 2, 12, 1, 0);
+
+        for (int i = 0; i < 12; i++) {
+            drawLineAngle(WIDTH / 2, HEIGHT / 2, i * (360.0 / 12), chartRadius, 1);
+        }
+
+        TV.delay(2000);
+    }
+
+    int rays = random(2, 7);
+    double offset = random(180);
+    for (int i = 0; i < rays; i++) {
+        drawLineAngle(WIDTH / 2, HEIGHT / 2, (i * (360.0 / rays)) + offset, chartRayLen + (chartRadius / 2), 1);
+    }
+
+    TV.delay(50);
+    chartRayLen += 0.2;
+
+    checkSceneEnded(20);
 }

 void loop() {
-		bool changed = false;
-		if (currentScene != lastScene) {
-				TV.clear_screen();
-				TV.set_cursor(0, 0);
-
-				digitalWrite(LED_PIN, HIGH);
-				TV.delay(100);
-				digitalWrite(LED_PIN, LOW);
-
-				startTime = TV.millis();
-				changed = true;
-		}
-
-		lastScene = currentScene;
-
-		switch (currentScene) {
-				case SYMBOL_TAURUS:
-						tauroSymbolScene();
-						break;
-				case SYMBOLS_FAST:
-						fastSymbolsScene();
-						break;
-				case PLANETS_SYMBOLS_FAST:
-						planetSymbolsFastScene();
-						break;
-				case WORDS_FAST:
-						fastWordsScene();
-						break;
-				case WORDS_FAST_INLINE:
-						wordsFastInlineScene();
-						break;
-				case STARS:
-						starsScene();
-						break;
-				case NOISE:
-						noiseScene();
-						break;
-				case SYMBOL_FADE:
-						symbolFadeScene(changed);
-						break;
-				case SYMBOL_CHECKERBOARD:
-						symbolCheckerboardScene(changed);
-						break;
-				case SYMBOL_GLITCH_SIZE:
-						symbolGlitchSizeScene();
-						break;
-				case CONSTELLATIONS:
-						constellationsScene();
-						break;
-				case COMMANDS:
-						commandsScene();
-						break;
-				case SYMBOL_GLITCH_LOAD:
-						symbolGlitchLoadScene(changed);
-						break;
-				case WORD_CURSOR:
-						wordCursorScene(changed);
-						break;
-				case WORMHOLE:
-						wormholeScene(changed);
-						break;
-				case SYMBOLS_SNAKE:
-						symbolsSnakeScene(changed);
-						break;
-				case SCROLL_STARS:
-						scrollStarsScene(changed);
-						break;
-				case EYES:
-						eyesScene(changed);
-						break;
-				case CHANNEL:
-						channelScene(changed);
-						break;
-				case VHS:
-						vhsScene(changed);
-						break;
-				case SYMBOL_SHIFT:
-						symbolShiftScene(changed);
-						break;
-				case BLINDS:
-						blindsScene(changed);
-						break;
-				case FADE_IN:
-						fadeInScene(changed);
-						break;
-				// case WHITE_BEAR:
-				// 		whiteBearScene(changed);
-				// 		break;
-				case PARTY_WORDS:
-						partyWordsScene();
-						break;
-				case FILL_LINES:
-						fillLinesScene(changed);
-						break;
-				case CIRCLES:
-						circlesScene(changed);
-						break;
-				case L_SYSTEM:
-						lSystemScene();
-						break;
-				case CLOCK:
-						clockScene(changed);
-						break;
-				case CHART:
-						chartScene(changed);
-						break;
-        		case HEX_SCENE:
-            			hexScene(changed);
-            			break;
-				case PYRAMID:
-						pyramidScene(changed);
-						break;
-				default:
-						TV.print("Invalid scene. ");
-						TV.delay(1000);
-						break;
-		}
-}
+    bool changed = false;
+    if (currentScene != lastScene) {
+        TV.clear_screen();
+        TV.set_cursor(0, 0);
+
+        digitalWrite(LED_PIN, HIGH);
+        TV.delay(100);
+        digitalWrite(LED_PIN, LOW);
+
+        startTime = TV.millis();
+        changed = true;
+    }
+
+    lastScene = currentScene;
+
+    switch (currentScene) {
+        case SYMBOL_TAURUS:
+            tauroSymbolScene();
+            break;
+        case SYMBOLS_FAST:
+            fastSymbolsScene();
+            break;
+        case PLANETS_SYMBOLS_FAST:
+            planetSymbolsFastScene();
+            break;
+        case WORDS_FAST:
+            fastWordsScene();
+            break;
+        case WORDS_FAST_INLINE:
+            wordsFastInlineScene();
+            break;
+        case STARS:
+            starsScene();
+            break;
+        case NOISE:
+            noiseScene();
+            break;
+        case SYMBOL_FADE:
+            symbolFadeScene(changed);
+            break;
+        case SYMBOL_CHECKERBOARD:
+            symbolCheckerboardScene(changed);
+            break;
+        case SYMBOL_GLITCH_SIZE:
+            symbolGlitchSizeScene();
+            break;
+        case CONSTELLATIONS:
+            constellationsScene();
+            break;
+        case COMMANDS:
+            commandsScene();
+            break;
+        case SYMBOL_GLITCH_LOAD:
+            symbolGlitchLoadScene(changed);
+            break;
+        case WORD_CURSOR:
+            wordCursorScene(changed);
+            break;
+        case WORMHOLE:
+            wormholeScene(changed);
+            break;
+        case SYMBOLS_SNAKE:
+            symbolsSnakeScene(changed);
+            break;
+        case SCROLL_STARS:
+            scrollStarsScene(changed);
+            break;
+        case EYES:
+            eyesScene(changed);
+            break;
+        case CHANNEL:
+            channelScene(changed);
+            break;
+        case VHS:
+            vhsScene(changed);
+            break;
+        case SYMBOL_SHIFT:
+            symbolShiftScene(changed);
+            break;
+        case BLINDS:
+            blindsScene(changed);
+            break;
+        case FADE_IN:
+            fadeInScene(changed);
+            break;
+        case PARTY_WORDS:
+            partyWordsScene();
+            break;
+        case FILL_LINES:
+            fillLinesScene(changed);
+            break;
+        case CIRCLES:
+            circlesScene(changed);
+            break;
+        case L_SYSTEM:
+            lSystemScene();
+            break;
+        case CLOCK:
+            clockScene(changed);
+            break;
+        case CHART:
+            chartScene(changed);
+            break;
+        case HEX_SCENE:
+            hexScene(changed);
+            break;
+        case PYRAMID:
+            pyramidScene(changed);
+            break;
+        default:
+            TV.print("Invalid scene. ");
+            blinkForever();
+            break;
+    }
+}


Just a test comment

Just a test comment

Want to test Github for Windows

--- pHPhotometerBTLE.ino
+++ pHPhotometerBTLE.ino
@@ -1,3 +1,5 @@
+// pH Photometer
+
 #include "Photometer.h"

 #include <SPI.h>


haptic feedback works

haptic feedback works

--- StuntCarRacer/Arduino_Code/HapkitController/HapkitController.ino
+++ StuntCarRacer/Arduino_Code/HapkitController/HapkitController.ino
@@ -207,8 +207,8 @@
 	byte result = 0;
 	digitalRead(joyFwdPin) == LOW ? result += 1 : 0;
 	digitalRead(joyBackPin) == LOW ? result += 2 : 0;
-	(xh>2.0f) == LOW ? result += 4 : 0;
-	(xh<-2.0f) == LOW ? result += 8 : 0;
+	//(xh>2.0f) == LOW ? result += 4 : 0;
+	//(xh<-2.0f) == LOW ? result += 8 : 0;
 	//digitalRead(joyFirePin) == LOW ? result += 16 : 0;
 	return result;
 }
@@ -255,9 +255,11 @@
     Loop function
 */
 bool dir;
-uint32_t nextcall = 1000;
+uint32_t nextcall = 0;
 const uint16_t intervalperiod = 50*64; // 100 milliseconds
 uint32_t nextcall2 = 1000;
+float vibrationfrequency = 10.0f;
+float amplitude = 1.0f;
 bool on_off = true;
 void loop() {
   // read the position in count
@@ -271,9 +273,11 @@

   if(millis() > nextcall2){
     nextcall2 += intervalperiod;
-    Serial.println(readJoystick());
-  }
-  on_off ? set_position = xh + sin(10.0f*2.0f*M_PI*millis()/64000.0f) : force = 0;
+    Serial.print(readJoystick());
+    Serial.print(" ");
+    Serial.println(xh);
+  }
+  on_off ? set_position = xh + amplitude * sin(vibrationfrequency*2.0f*M_PI*millis()/64000.0f) : force = 0;
   motorControl();

 }
@@ -299,10 +303,10 @@
   } else if (fbEvent.startsWith("HitCar")) {
 	//TODO rendering
   } else if (fbEvent.startsWith("Creak")) {
-	static bool fb = false;
-	fb = !fb;
-	digitalWrite(feedbackLEDPin, fb);//XXX debug
-	//TODO rendering
+    vibrationfrequency = 100.0f;
+    nextcall = millis() + 500UL*64UL;
+    amplitude = 2.0f;
+    on_off = true;
   } else if (fbEvent.startsWith("Smash")) {
 	//TODO rendering
   } else if (fbEvent.startsWith("Wreck")) {


Fixed bug with waiting for serial to be ready

--- ivd/ivd.ino
+++ ivd/ivd.ino
@@ -23,17 +23,22 @@
 void setup() {
     // connect at 115200 so we can read the GPS fast enough
     Serial.begin(115200);
-    while (!Serial); // wait for leo to be ready
+    //while (!Serial); // wait for leo to be ready
+    delay(5000);
+
+    pinMode(VOLTAGE_PIN, INPUT);
+    pinMode(CURRENT_PIN, INPUT);

     // SD card: pin 10 for chip select, 11 for MOSI, 12 for MISO and 13 for SCK
     //if (!SD.begin(10)) {
     if (!SD.begin(10, 11, 12, 13)) {
         Serial.println("SD initialization failed!");
-        return;
+        while(1);
     }
     logFile = SD.open("data.csv", FILE_WRITE);
     if (!logFile) {
         Serial.println("Failed to open log file!");
+        while(1);
     }

     // 9600 NMEA is the default baud rate for Adafruit MTK GPS's
@@ -51,9 +56,6 @@
     // For the parsing code to work nicely and have time to sort thru the data, and
     // print it out we don't suggest using anything higher than 1 Hz
     delay(1000);
-
-    pinMode(VOLTAGE_PIN, INPUT);
-    pinMode(CURRENT_PIN, INPUT);
 }

 void log_data(float latitude, float longitude, float speed, float angle, float altitude, float voltage, float current) {


Updated KeyboardMessage example

Updated KeyboardMessage example

--- build/shared/examples/09.USB/Keyboard/KeyboardMessage/KeyboardMessage.ino
+++ build/shared/examples/09.USB/Keyboard/KeyboardMessage/KeyboardMessage.ino
@@ -1,21 +1,23 @@
 /*
- Keyboard Button test
+ Keyboard Message test

  For the Arduino Leonardo and Micro.

  Sends a text string when a button is pressed.

  The circuit:
- * pushbutton attached from pin 2 to +5V
+ * pushbutton attached from pin 4 to +5V
  * 10-kilohm resistor attached from pin 4 to ground

  created 24 Oct 2011
  modified 27 Mar 2012
  by Tom Igoe
+ modified 11 Nov 2013
+ by Scott Fitzgerald

  This example code is in the public domain.

- http://www.arduino.cc/en/Tutorial/KeyboardButton
+ http://www.arduino.cc/en/Tutorial/KeyboardMessage
  */

 const int buttonPin = 4;          // input pin for pushbutton


Update magnetometer.ino

Update magnetometer.ino

--- code/magnetometer.ino
+++ code/magnetometer.ino
@@ -7,6 +7,9 @@
 #define YAXIS 1
 #define ZAXIS 2

+#define M1
+#define M1
+#define M1
 #define M1
 #define M1
 #define M1


Assign TLC the right pins and initialise

--- src/Full_decoder/Full_decoder.ino
+++ src/Full_decoder/Full_decoder.ino
@@ -24,14 +24,12 @@
 // How many boards do you have chained?
 #define NUM_TLC5974 1

-#define data   4
-#define clock   5
-#define latch   6
+#define data   10
+#define clock   16
+#define latch   14
 #define oe  -1  // set to -1 to not use the enable pin (its optional)

 Adafruit_TLC5947 tlc = Adafruit_TLC5947(NUM_TLC5974, clock, data, latch);
-int channel, pwm;
-

 void enableServos();
 void disableServos();
@@ -142,6 +140,8 @@
   for (i = 0; i < pins_conf; i++) {
     configureSlot(i);
   }
+  tlc.begin();
+
   programmingMode = false;
 }


Update nodemcu_bme280.ino

Update nodemcu_bme280.ino

fixed negative value error

--- nodemcu_bme280.ino
+++ nodemcu_bme280.ino
@@ -97,8 +97,8 @@
 void sendDataToCorlysis(float temperature, float pressure, float humidity) {

     char payload_str[150];
-    sprintf(payload_str, "bme280_data temperature=%d.%02d,pressure=%d.%02d,humidity=%d.%02d", (int)temperature, (int)(temperature*100)%100,
-    (int)pressure, (int)(pressure*100)%100, (int)humidity, (int)(humidity*100)%100);
+    sprintf(payload_str, "bme280_data temperature=%d.%02d,pressure=%d.%02d,humidity=%d.%02d", (int)temperature, (int)abs(temperature*100)%100,
+    (int)pressure, (int)abs(pressure*100)%100, (int)humidity, (int)abs(humidity*100)%100);
     Serial.println(payload_str);

     char corlysis_url[200];


Update Arduino_Zero_M0_Serial.ino

Update Arduino_Zero_M0_Serial.ino

--- examples/BoardsAndShields/Arduino_Zero_M0_Serial/Arduino_Zero_M0_Serial.ino
+++ examples/BoardsAndShields/Arduino_Zero_M0_Serial/Arduino_Zero_M0_Serial.ino
@@ -27,9 +27,11 @@
  *
  *      for Windows:
  *                     1. Open cmd.exe
- *                     2. write : (your way to blynk-ser.bat folder) example: "cd C:\blynk-library-0.3.1\blynk-library-0.3.1\scripts"
- *                     3. write : "blynk-ser.bat -c COM4" (where COM4 is port with your Arduino)
- *                     4. And press "Enter" , press "Enter" and press "Enter"
+ *                     2. Write (put your path to the blynk-ser.bat folder):
+ *                          cd C:\blynk-library\scripts
+ *                     3. Write (COM4 is port with your Arduino):
+ *                          blynk-ser.bat -c COM4
+ *                     4. And press "Enter", press "Enter" and press "Enter"
  *
  *      for Linux and OSX:
  *


First, untested implementation of reading loconet en memory usage statistics

--- src/Full_decoder/Full_decoder.ino
+++ src/Full_decoder/Full_decoder.ino
@@ -51,6 +51,14 @@
 boolean programmingMode;

 #define LOCONET_TX_PIN 5
+
+extern int __bss_start, __bss_end;
+
+int freeRam () {
+  extern int __heap_start, *__brkval;
+  int v;
+  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
+};

 void reportSlot(uint16_t slot, uint16_t state) {
   DEBUG("Reporting slot ");
@@ -225,6 +233,32 @@
         DEBUG("\n");

         return LNCV_LACK_OK;
+      } else if (lncvAddress == 1024) {
+        lncvValue = freeRam();
+      } else if (lncvAddress == 1025) {
+        lncvValue = __bss_start;
+      } else if (lncvAddress == 1026) {
+        lncvValue = __bss_end;
+      } else if (lncvAddress == 1027) {
+        lncvValue = SP;
+      } else if ((lncvAddress > 1027) && (lncvAddress < 1033)){
+        LnBufStats* stats = LocoNet.getStats();
+        switch (lncvAddress) {
+          case 1028:
+          lncvValue = stats->RxPackets;
+          break;
+          case 1029:
+          lncvValue = stats->RxErrors;
+          break;
+          case 1030:
+          lncvValue = stats->TxPackets;
+          break;
+          case 1031:
+          lncvValue = stats->TxErrors;
+          break;
+          case 1032:
+          lncvValue = stats->Collisions;
+        }
       } else {
         // Invalid LNCV address, request a NAXK
         return LNCV_LACK_ERROR_UNSUPPORTED;


Spaces => Tabs

Spaces => Tabs

--- libraries/ESP8266WebServer/examples/AdvancedWebServer/AdvancedWebServer.ino
+++ libraries/ESP8266WebServer/examples/AdvancedWebServer/AdvancedWebServer.ino
@@ -93,7 +93,7 @@
 	pinMode ( led, OUTPUT );
 	digitalWrite ( led, 0 );
 	Serial.begin ( 115200 );
-    WiFi.mode ( WIFI_STA );
+	WiFi.mode ( WIFI_STA );
 	WiFi.begin ( ssid, password );
 	Serial.println ( "" );


refine target cmd determine clause

refine target cmd determine clause

--- client/client.ino
+++ client/client.ino
@@ -189,8 +189,10 @@
           statePending = true;
           eighty_twenty = true;
         }
-      } else if(strcmp(p.data, "TAR")) {
+      } else if(strcmp(p.data, "TAR") == 0 && strcmp(p.id, deviceId) == 0) {
         //turn on target light and return ack
+
+        DEBUG_TAGGING("Target received", "");
         sendXBeePacketFromRaw(&XBee, deviceId, "A", "SEL", "TAR");
         digitalWrite(ledTargetPin, HIGH);


Update E00_KY-040_RotaryEncoder.ino

Update E00_KY-040_RotaryEncoder.ino

--- RotaryEncoder/examples/E00_KY-040_RotaryEncoder/E00_KY-040_RotaryEncoder.ino
+++ RotaryEncoder/examples/E00_KY-040_RotaryEncoder/E00_KY-040_RotaryEncoder.ino
@@ -19,7 +19,8 @@
 //    |             |--- GND  >   o GND
 //    +-------------+
 //
-//     No external RC- or R-parts are used. Debouncing will be supported by Rotary Encoder library 'RotaryEncoder.h'
+//     No external RC- or R-parts are used. Debouncing will be supported by Rotary
+//     Encoder Interrupt Handler 'RotaryEncoder.ino'
 //
 //  Copyright (c) 2015 Thomas Walloschke (artkeller at gmx.de). All rights reserved.
 //


version 19 without bug

version 19 without bug

--- src/resource/Arduino/MRLComm.ino
+++ src/resource/Arduino/MRLComm.ino
@@ -41,7 +41,7 @@
 #endif

 // ----------  MRLCOMM FUNCTION INTERFACE BEGIN -----------
-#define MRLCOMM_VERSION				18
+#define MRLCOMM_VERSION				19

 // serial protocol functions
 #define MAGIC_NUMBER  					170 // 10101010


Fixed blatant typos

Fixed blatant typos

--- ps2_controller/ps2_controller.ino
+++ ps2_controller/ps2_controller.ino
@@ -277,7 +277,7 @@
   //  The Arduino then sends Reconnect Successful to tell the computer Connection is working as intended
   //  Or:
   //  Computer sends Disconnect to the Arduino in case of PING timeout (The Arduino didn't respond with PONG in time)
-  //  The Arduino then sends Disconnect Ungderstood back to the Computer, both close connections on their ends, then start connection again
+  //  The Arduino then sends Disconnect Understood back to the Computer, both close connections on their ends, then start connection again
   //  The Computer then sends Reconnect Successful to tell the Arduino Connection is working as intended
   if (Serial.available() > 0) {


Another Analog Button Bugfix

Another Analog Button Bugfix

--- ps2_controller/ps2_controller.ino
+++ ps2_controller/ps2_controller.ino
@@ -205,11 +205,13 @@
     delay(powerRelayDelay);
     digitalWrite(relayPin, HIGH);
   }
+  /*
   digitalWrite(buttonAnalog, HIGH);
   delay(powerRelayDelay);
   digitalWrite(buttonAnalog, LOW);
   delay(powerRelayDelay);
   digitalWrite(buttonAnalog, HIGH);
+  */
   readMotors();
   if (analogLedVal > 108)
   {


Clarified that DATA_PIN and CLOCK_PIN can be changed

The FastLED library allows you to define which pins you want to use for Data and Clock.  You don't have to use the ones I selected if you don't want to.  Be aware that the Ethernet chip is hardwired to

--- AndyMark_LED_Lightchaser_Example/AndyMark_LED_Lightchaser_Example.ino
+++ AndyMark_LED_Lightchaser_Example/AndyMark_LED_Lightchaser_Example.ino
@@ -35,7 +35,9 @@
 // This is an array of leds. One item for each led in your strip.
 CRGB leds[NUM_LEDS];

-//CSK 3/17/2014 I moved these to pins that don't conflict with Ethernet functions in case you want to control LEDs via Ethernet
+//CSK 3/17/2014 I moved these to pins that don't conflict with Ethernet functions
+//in case you want to control LEDs via Ethernet.
+//You can change the Data and Clock pins to whatever pins work for you.
 #define DATA_PIN 3 //Green wire from AM-2640's power connector
 // Clock pin SPI
 #define CLOCK_PIN 4 //Blue wire from AM-2640's power connector


update and add comments

update and add comments

--- arduino/opencr_arduino/opencr/libraries/turtlebot3/turtlebot3_burger/turtlebot3_core/turtlebot3_core.ino
+++ arduino/opencr_arduino/opencr/libraries/turtlebot3/turtlebot3_burger/turtlebot3_core/turtlebot3_core.ino
@@ -45,15 +45,19 @@
 geometry_msgs::Twist cmd_vel_rc100_msg;
 ros::Publisher cmd_vel_rc100_pub("cmd_vel_rc100", &cmd_vel_rc100_msg);

+// Odometry of Turtlebot3
 nav_msgs::Odometry odom;
 ros::Publisher odom_pub("odom", &odom);

+// Joint(Dynamixel) state of Turtlebot3
 sensor_msgs::JointState joint_states;
 ros::Publisher joint_states_pub("joint_states", &joint_states);

+// Battey state of Turtlebot3
 sensor_msgs::BatteryState battery_state_msg;
 ros::Publisher battery_state_pub("battery_state", &battery_state_msg);

+// Magnetic field
 sensor_msgs::MagneticField mag_msg;
 ros::Publisher mag_pub("magnetic_field", &mag_msg);

@@ -133,9 +137,6 @@
 static float   battery_valtage_raw = 0;
 static uint8_t battery_state   = BATTERY_POWER_OFF;

-
-
-
 /*******************************************************************************
 * Time Interpolation function
 *******************************************************************************/
@@ -143,10 +144,6 @@
 {
   uint32_t sec, nsec;

-  /*
-   * the interpolation floors the current time
-   * stamp for integrity of precision.
-   */
   sec  = _micros / 1000000 + t.sec;
   nsec = _micros % 1000000 + 1000 * (t.nsec / 1000);
   if (nsec >= 1e9) {
@@ -209,13 +206,13 @@
   odom_pose[1] = 0.0;
   odom_pose[2] = 0.0;

-  joint_states.header.frame_id = "base_footprint";
+  joint_states.header.frame_id = "base_link";
   joint_states.name            = joint_states_name;

-  joint_states.name_length     = 2;
-  joint_states.position_length = 2;
-  joint_states.velocity_length = 2;
-  joint_states.effort_length   = 2;
+  joint_states.name_length     = WHEEL_NUM;
+  joint_states.position_length = WHEEL_NUM;
+  joint_states.velocity_length = WHEEL_NUM;
+  joint_states.effort_length   = WHEEL_NUM;

   // Initialize Battery States
   battery_state_msg.current         = NAN;
@@ -238,17 +235,9 @@
 *******************************************************************************/
 void loop()
 {
-  receiveRemoteControlData();
-  /*
-   * the update_time() call below
-   * reduces the amount of calls to
-   * nh.now(), and allows the returned
-   * time to be interpolated on an
-   * as-needed basis with the ros_now()
-   * function.
-   */
   uint32_t t = millis();
   update_time();
+
   if ((t-tTime[0]) >= (1000 / CONTROL_MOTOR_SPEED_PERIOD))
   {
     controlMotorSpeed();
@@ -273,6 +262,9 @@
     publishImuMsg();
     tTime[3] = t;
   }
+
+  // Receive data from RC100
+  receiveRemoteControlData();

   // Check push button pressed for simple test drive
   checkPushButtonState();
@@ -384,7 +376,7 @@

   tfs_msg.transform.translation.x = -0.032;
   tfs_msg.transform.translation.y = 0.0;
-  tfs_msg.transform.translation.z = 0.068;
+  tfs_msg.transform.translation.z = 0.058;

   tfbroadcaster.sendTransform(tfs_msg);
 }
@@ -402,13 +394,13 @@
   sensor_state_msg.battery = checkVoltage();

   battery_state_msg.voltage = sensor_state_msg.battery;
+  battery_state_pub.publish(&battery_state_msg);

   dxl_comm_result = motor_driver.readEncoder(sensor_state_msg.left_encoder, sensor_state_msg.right_encoder);

   if (dxl_comm_result == true)
   {
     sensor_state_pub.publish(&sensor_state_msg);
-    battery_state_pub.publish(&battery_state_msg);
   }
   else
   {
@@ -473,7 +465,7 @@
   double odom_vel[3];

   double wheel_l, wheel_r;      // rotation value of wheel [rad]
-  double delta_s, delta_theta;
+  double delta_s, theta, delta_theta;
   static double last_theta = 0.0;
   double v, w;                  // v = translational velocity [m/s], w = rotational velocity [rad/s]
   double step_time;
@@ -498,8 +490,9 @@
     wheel_r = 0.0;

   delta_s     = WHEEL_RADIUS * (wheel_r + wheel_l) / 2.0;
-  delta_theta = atan2f(imu.quat[1]*imu.quat[2] + imu.quat[0]*imu.quat[3],
-                       0.5f - imu.quat[2]*imu.quat[2] - imu.quat[3]*imu.quat[3]) - last_theta;
+  theta       = atan2f(imu.quat[1]*imu.quat[2] + imu.quat[0]*imu.quat[3],
+                       0.5f - imu.quat[2]*imu.quat[2] - imu.quat[3]*imu.quat[3]);
+  delta_theta = theta - last_theta;

   v = delta_s / step_time;
   w = delta_theta / step_time;
@@ -526,8 +519,7 @@
   odom.twist.twist.linear.x  = odom_vel[0];
   odom.twist.twist.angular.z = odom_vel[2];

-  last_theta = atan2f(imu.quat[1]*imu.quat[2] + imu.quat[0]*imu.quat[3],
-                      0.5f - imu.quat[2]*imu.quat[2] - imu.quat[3]*imu.quat[3]);
+  last_theta = theta;

   return true;
 }


update to the demo sketch

update to the demo sketch

--- examples/LightBlueBean/01.Basics/AccelerometerEvent/AccelerometerEvent.ino
+++ examples/LightBlueBean/01.Basics/AccelerometerEvent/AccelerometerEvent.ino
@@ -1,9 +1,9 @@
 /*
   This sketch demonstrates the Bean's ability to detect motion events.

-  In this demo we assign motions with corresponding LED colors.
-  The Bean's LED color shows what motion event it's waiting to detect.
-  After detecting the event, it will cycle to the next color and wait for the next event.
+  In this demo we assign a unique LED color with each motion event.
+  The Bean's active LED color indicates what motion event it's waiting to detect.
+  After detecting the event, the sketch will cycle to the next color and wait for the next event.

   We start by waiting for "double tap" indicated by a red LED color


WebSocketClientSocketIOack.ino:150:25: ARDUINOJSON_USE_LONG_LONG fix

--- examples/esp8266/WebSocketClientSocketIOack/WebSocketClientSocketIOack.ino
+++ examples/esp8266/WebSocketClientSocketIOack/WebSocketClientSocketIOack.ino
@@ -147,7 +147,7 @@

         // add payload (parameters) for the event
         JsonObject param1 = array.createNestedObject();
-        param1["now"] = now;
+        param1["now"] = (utin32_t) now;

         // JSON to String (serializion)
         String output;


wrote simple demo, needs testing.

wrote simple demo, needs testing.

--- simple_bt_demo/simple_bt_demo.ino
+++ simple_bt_demo/simple_bt_demo.ino
@@ -9,3 +9,52 @@
     simple_bt_demo.ino
 */

+#include "Bluetooth.h"
+
+/*
+ * BLUETOOTH
+ */
+#define pinBT_RX 8
+#define pinBT_TX 9
+Bluetooth bt = Bluetooth(pinBT_RX, pinBT_TX);
+
+static int count = 0;
+
+/*
+ * ENERGIA REQUIRED
+ */
+
+void
+setup (void)
+{
+    Serial.begin(9600);
+    bt.begin();
+}
+
+void
+loop (void)
+{
+    char r;
+    while (true)
+    {
+        if (bt.available())
+        {
+            r = bt.read();
+
+            bt.print(r);
+
+            if (r == 'i')
+            {
+                count++;
+            }
+            else if (r == 'd')
+            {
+                count --;
+            }
+
+            bt.print(count);
+            bt.print("\n");
+            bt.print("count : ");
+        }
+    }
+}


Moved sensor reading to new alert only command when rules fail. Reading command will be return eventually for polling.

--- freezer_monitor_v0_7/freezer_monitor_v0_7.ino
+++ freezer_monitor_v0_7/freezer_monitor_v0_7.ino
@@ -36,19 +36,23 @@
 #define CMD_BOOT     0x10
 #define CMD_CONFIG   0x11
 #define CMD_READING  0x21
+#define CMD_ALERT    0x31
 #define PRECISION    100

-#define APIN_BATTERY    0  // data connection for photocell
+#define APIN_BATTERY    0  // data connection for battery
 #define APIN_LDR        1  // data connection for photocell
 #define DPIN_ONEWIRE    3  // data connection for the Dallas OneWire bus
 #define DPIN_HALL       7  // data connection for hall effect
 #define DPIN_SENSOR_LED 8
 #define DPIN_RF_LED     9

+#define DEFAULT_LED_DELAY 5
+
 #define VDD_RATIO 1.622

 struct SensorData {
   boolean available;
+  boolean status;
   unsigned int ldr;
   unsigned int hall;
   float tempInsideC;
@@ -66,14 +70,8 @@
 };

 // rfm12b radio
-char input = 0;
 RFM12B radio;
-
-boolean requestACK = false;
-byte sendSize=0;
-char payload[] = "123 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 char buffer[BUFFER_SIZE];
-
 long lastPeriod = -1;

 // dallas onewire configuration
@@ -132,7 +130,7 @@
         radio.SendACK();
         Serial.print(" - ACK sent.");
       }
-      blink_led(DPIN_RF_LED, 5);
+      blink_led(DPIN_RF_LED, DEFAULT_LED_DELAY);
     }
   }

@@ -140,6 +138,96 @@
   if ((int)(millis()/TRANSMITPERIOD) > lastPeriod) {
     lastPeriod++;

+    if (!sensorData.status) {
+      send_reading(CMD_ALERT);
+      blink_led(DPIN_RF_LED, DEFAULT_LED_DELAY);
+      log();
+    }
+
+  }
+
+}
+
+//------------------------------------------------------------------------------
+void blink_led(byte pin, int delay_ms) {
+  digitalWrite(pin, HIGH);
+  delay(delay_ms);
+  digitalWrite(pin, LOW);
+}
+
+//------------------------------------------------------------------------------
+// Compares each sensor's value against its expectation, returning true if the
+// values are acceptable or false if they fall outside the expectations.
+int check_status() {
+  int status = HIGH;
+  if (sensorData.ldr > sensorThresholds.light) {
+    status = LOW;
+  }
+  if (sensorData.hall == sensorThresholds.door) {
+    status = LOW;
+  }
+  if (sensorData.tempInsideC < sensorThresholds.minTempInsideC) {
+    status = LOW;
+  }
+  if (sensorData.tempInsideC > sensorThresholds.maxTempInsideC) {
+    status = LOW;
+  }
+  return status;
+}
+
+//------------------------------------------------------------------------------
+// Logs the current sensor values.
+void log() {
+  Serial.print("Status: ");
+  Serial.print(sensorData.status);
+  Serial.print(", Light: ");
+  Serial.print(sensorData.ldr);
+  Serial.print(", Hall: ");
+  Serial.print(sensorData.hall);
+  Serial.print(", Temp: ");
+  Serial.print(sensorData.tempInsideC);
+  Serial.print("C, ");
+  Serial.print(sensorData.tempOutsideC);
+  Serial.print("C");
+  Serial.print(", Battery: ");
+  Serial.println(sensorData.batteryVoltage);
+}
+
+//------------------------------------------------------------------------------
+// Retrieves the new sensor values.
+void interogate_sensors() {
+
+  // block access to sensor data
+  sensorData.available = false;
+
+  // read light level
+  sensorData.ldr = map(analogRead(APIN_LDR), 0, 1023, 0, 255);
+
+  // read door status
+  sensorData.hall = digitalRead(DPIN_HALL);
+
+  // read one-wire sensors
+  oneWireSensors.requestTemperatures();
+  sensorData.tempInsideC = oneWireSensors.getTempC(thermometerInside);
+  sensorData.tempOutsideC = oneWireSensors.getTempC(thermometerOutside);
+
+  // read battery voltage
+  int val = analogRead(APIN_BATTERY);
+  float pinVoltage = val * 0.00488;
+  sensorData.batteryVoltage = pinVoltage * VDD_RATIO;
+
+  // enable access to sensor data
+  sensorData.available = true;
+
+  // update status led
+  sensorData.status = check_status();
+  digitalWrite(DPIN_SENSOR_LED, !sensorData.status);
+
+}
+
+//------------------------------------------------------------------------------
+void send_reading(unsigned int command) {
+
     // assemble sensor reading message
     int decBatteryVoltage = int(sensorData.batteryVoltage);
     unsigned int fracBatteryVoltage;
@@ -162,8 +250,9 @@
     } else {
         fracTempOutsideC = (int(sensorData.tempOutsideC) - sensorData.tempOutsideC) * PRECISION;
     }
-    sprintf(buffer, "0x%02x:0x%02x:%x:%d.%02d:%d.%02d:%d.%02d",
-      CMD_READING,
+    sprintf(buffer, "0x%02x:%x:0x%02x:%x:%d.%02d:%d.%02d:%d.%02d",
+      command,
+      sensorData.status,
       sensorData.ldr,
       sensorData.hall,
       decBatteryVoltage, fracBatteryVoltage,
@@ -172,91 +261,12 @@
     Serial.print("reading [");
     Serial.print(buffer);
     Serial.print("]");
-
-    // send sensor reading message to gateway
+
+    // transmit reading to gateway
     radio.Send(GATEWAYID, buffer, strlen(buffer), true);
-    Serial.print(" - waiting for ACK...");
-    if (waitForAck(GATEWAYID)) Serial.println("ok!");
-    else Serial.println("nothing...");
-
-    blink_led(DPIN_RF_LED, 5);
-    log();
-  }
-
-}
-
-//------------------------------------------------------------------------------
-void blink_led(byte pin, int delay_ms) {
-  digitalWrite(pin, HIGH);
-  delay(delay_ms);
-  digitalWrite(pin, LOW);
-}
-
-//------------------------------------------------------------------------------
-// Compares each sensor's value against its expectation, returning true if the
-// values are acceptable or false if they fall outside the expectations.
-int check_status() {
-  int status = LOW;
-  if (sensorData.ldr > sensorThresholds.light) {
-    status = HIGH;
-  }
-  if (sensorData.hall == sensorThresholds.door) {
-    status = HIGH;
-  }
-  if (sensorData.tempInsideC < sensorThresholds.minTempInsideC) {
-    status = HIGH;
-  }
-  if (sensorData.tempInsideC > sensorThresholds.maxTempInsideC) {
-    status = HIGH;
-  }
-  return status;
-}
-
-//------------------------------------------------------------------------------
-// Logs the current sensor values.
-void log() {
-  Serial.print("Light: ");
-  Serial.print(sensorData.ldr);
-  Serial.print(" Hall: ");
-  Serial.print(sensorData.hall);
-  Serial.print(" Temp: ");
-  Serial.print(sensorData.tempInsideC);
-  Serial.print("C, ");
-  Serial.print(sensorData.tempOutsideC);
-  Serial.print("C");
-  Serial.print(" Battery: ");
-  Serial.println(sensorData.batteryVoltage);
-}
-
-//------------------------------------------------------------------------------
-// Retrieves the new sensor values.
-void interogate_sensors() {
-
-  // block access to sensor data
-  sensorData.available = false;
-
-  // read light level
-  sensorData.ldr = map(analogRead(APIN_LDR), 0, 1023, 0, 255);
-
-  // read door status
-  sensorData.hall = digitalRead(DPIN_HALL);
-
-  // read one-wire sensors
-  oneWireSensors.requestTemperatures();
-  sensorData.tempInsideC = oneWireSensors.getTempC(thermometerInside);
-  sensorData.tempOutsideC = oneWireSensors.getTempC(thermometerOutside);
-
-  // read battery voltage
-  int val = analogRead(APIN_BATTERY);
-  float pinVoltage = val * 0.00488;
-  sensorData.batteryVoltage = pinVoltage * VDD_RATIO;
-
-  // enable access to sensor data
-  sensorData.available = true;
-
-  // update status led
-  digitalWrite(DPIN_SENSOR_LED, check_status());
-
+    Serial.print(" : waiting for ACK - ");
+    if (waitForAck(GATEWAYID)) Serial.println("<OK>");
+    else Serial.println("<NONE>");
 }

 //------------------------------------------------------------------------------
@@ -289,7 +299,7 @@
   buffer[0] = MYID;
   buffer[1] = CMD_BOOT;
   radio.Wakeup();
-  radio.Send(GATEWAYID, payload, 10, true);
+  radio.Send(GATEWAYID, buffer, 10, true);
   if (waitForAck(GATEWAYID)) {
     Serial.println("RF Gateway Found - Loading sensor defaults...");
   } else {


Removed tests

Removed tests

--- test-buttons/test-buttons.ino
+++ test-buttons/test-buttons.ino
@@ -1,72 +0,0 @@
-int pinButton[4] = {4,5,6,7}; // array of button pin
-int before[4]; // array of before value
-
-int index; // index array
-int val; // button value
-
-// ========== VOID SETUP ========== //
-void setup() {
-  for (index = 0; index < 4; index++)
-  {
-    pinMode(pinButton[index], INPUT_PULLUP); // set button pin as INPUT_PULLUP
-    before[index] = HIGH; // set before value as HIGH
-  }
-
-  Serial.begin(9600);
-  Serial.println("Iniziamo:"); // start serial communication
-}
-
-// ========== VOID LOOP ========== //
-void loop() {
-
-  if (digitalRead(pinButton[0]) == LOW && before[0] == HIGH)
-  { // first button pressed
-    send(0);
-  }
-  if (digitalRead(pinButton[1]) == LOW && before[1] == HIGH)
-  { // second button pressed
-    send(1);
-  }
-  if (digitalRead(pinButton[2]) == LOW && before[2] == HIGH)
-  { // third button pressed
-    send(2);
-  }
-  if (digitalRead(pinButton[3]) == LOW && before[3] == HIGH)
-  { // fourth button pressed
-    send(3);
-  }
-
-  invert(); // function invert
-
-  /*
-  for (index = 0; index < 4; index++) // read button pin
-  {
-    val = digitalRead(pinButton[index]); // read button value
-
-    if (val == LOW && before[index] == HIGH)
-    {
-      send(index);
-
-    } // end if
-
-      before[index] = val;
-
-  } // end for
-  */
-
-  delay(100); // delay
-
-} // end loop
-
-// ========== VOID SEND ========== //
-void send(int value) { // print pressed button
-  Serial.println(value);
-}
-
-// ========== VOID INVERT ========== //
-void invert() { // set before as pin state
-  for (index = 0; index < 4; index++)
-  {
-    before[index] = digitalRead(pinButton[index]);
-  }
-}


checkpoint for option of straight serial or ESP8266 ITEAD lib

--- uArm.ino
+++ uArm.ino
@@ -11,11 +11,16 @@

 #include <VarSpeedServo.h>

+#define USE_ESP8266_LIB
+#undef USE_ESP8266_LIB
+#ifdef USE_ESP8266_LIB
+#include "uartWIFI.h"
+#endif
+
 // MicroView
 int SCREEN_WIDTH = uView.getLCDWidth();
 int SCREEN_HEIGHT = uView.getLCDHeight();
 MicroViewWidget *widgetL, *widgetR, *widgetRot, *widgetHRot, *widgetH;
-

 // Servos
 const uint8_t servoPinL = 2;
@@ -108,9 +113,37 @@
 	servoH.detach();
 }

+
+// ESP8266
+#ifdef USE_ESP8266_LIB
+#define SSID       "root"
+#define PASSWORD   "conortimothy"
+
+WIFI wifi;
+extern int chlID;
+
+void setup_ESP8266(void) {
+	while (!wifi.begin());
+	while (!wifi.Initialize(STA, SSID, PASSWORD));
+	wifi.confMux(1);
+	wifi.confServer(1, 23);
+}
+
+#endif
+
+void sendMsg(String msg) {
+#ifdef USE_ESP8266_LIB
+	wifi.Send(chlID, msg);
+#else
+	Serial.print(msg);
+#endif
+}
+
 void setup() {
+	String msg;
+
 	// setup serial port
-	Serial.begin(9600);
+	Serial.begin(115200);

 	// setup MicroView
 	setupMicroView();
@@ -125,7 +158,12 @@
 	moveServoHRot(defaultServoPos, servoSpeed, false, false);
 	moveServoH(defaultServoPos, servoSpeed, true, true);

-	Serial.println("READY");
+#ifdef USE_ESP8266_LIB
+	// ESP8266
+	setup_ESP8266();
+#endif
+	msg = String(F("READY\n"));
+	sendMsg(msg);
 }

 /*
@@ -149,6 +187,7 @@
 	int pos;
 	int servoSpeedLocal = servoSpeed;
 	void (*moveServoFuncPtr)(uint8_t, uint8_t, bool, bool) = NULL;
+	String msg;

 	if (!speedControl)
 		servoSpeedLocal = 0;
@@ -192,21 +231,20 @@
 		} else {
 			servoMoveError = true;
 			if (*buf == endptr) {
-				Serial.print(F("ERROR: missing servo position for servo "));
-				Serial.println(servoShortName);
+				msg = String(F("ERROR: missing servo position for servo ")) + String(servoShortName) + String("\n");
 			} else {
-				Serial.print(F("ERROR: invalid servo position for servo "));
-				Serial.print(servoShortName);
-				Serial.print(F(": "));
-				Serial.println(pos, DEC);
-			}
+				msg = String(F("ERROR: invalid servo position for servo ")) + String(servoShortName) + String(": ") + String(pos, DEC) + String("\n");
+			}
+			sendMsg(msg);
+			return false;
 		}
 		*buf = endptr;
 		return true;
 	} else {
 		servoMoveError = true;
-		Serial.print(F("ERROR: invalid servo identifier: "));
-		Serial.println(servoShortName);
+		msg = String(F("ERROR: invalid servo identifier: ")) + String(servoShortName) + String("\n");
+		sendMsg(msg);
+		return false;
 	}
 	return false;
 }
@@ -224,7 +262,7 @@
 		case 'G': case 'g':
 			code = strtoul(&buf[1], &endptr, 10);
 			if (endptr == &buf[1]) {
-				Serial.println(F("ERROR: missing G command code"));
+				sendMsg(F("ERROR: missing G command code"));
 				return false;
 			}
 			if (code == 0) {
@@ -234,7 +272,8 @@
 				// speed control move
 				speedControl = true;
 			} else {
-				Serial.println(F("ERROR: invalid G command code"));
+				String msg = String(F("ERROR: invalid G command code: ")) + String(code, DEC) + String("\n");
+				sendMsg(msg);
 				return false;
 			}
 			// absorb spaces
@@ -250,12 +289,12 @@
 					} else if (code == 1) {
 						wait = true;
 					} else {
-						Serial.print(F("ERROR: invalid G command wait flag, bad value: "));
-						Serial.println(code, DEC);
+						String msg = String(F("ERROR: invalid G command wait flag, bad value: ")) + String(code, DEC) + String("\n");
+						sendMsg(msg);
 						return false;
 					}
 				} else {
-					Serial.println(F("ERROR: invalid G command wait flag (missing value)"));
+					sendMsg(F("ERROR: invalid G command wait flag (missing value)"));
 					return false;
 				}
 			}
@@ -270,69 +309,64 @@
 				servoMoves[i].moveServoFuncPtr(servoMoves[i].pos, servoMoves[i].servoSpeed,
 					(i == servoMoveCount - 1 ? false : wait), (i == servoMoveCount - 1 ? true : false));
 			}
-			if (i != 0)
-				Serial.println(F("OK"));
+			if (i != 0) {
+				sendMsg(F("OK"));
+			}
 			break;
 		case 'F': case 'f':
 			code = strtoul(&buf[1], &endptr, 10);
 			if (endptr == &buf[1]) {
-				Serial.println(F("ERROR: missing F speed parameter"));
+				sendMsg(F("ERROR: missing F speed parameter"));
 				return false;
 			}
 			if (code >= 0 && code <= 255) {
 				servoSpeed = code;
-				Serial.println(F("OK"));
+				sendMsg(F("OK"));
 				return true;
 			} else {
-				Serial.print(F("ERROR: invalid F speed parameter: "));
-				Serial.println(code, DEC);
+				String msg = String(F("ERROR: invalid F speed parameter: ")) + String(code, DEC) + String("\n");
+				sendMsg(msg);
 				return false;
 			}
 			break;
 		case 'M': case 'm':
 			code = strtoul(&buf[1], &endptr, 10);
 			if (endptr == &buf[1]) {
-				Serial.println(F("ERROR: missing M address parameter"));
+				sendMsg(F("ERROR: missing M address parameter"));
 				return false;
 			}
 			switch (code) {
 				case 100:
-					Serial.println(F("OK"));
+					sendMsg(F("OK"));
 					softwareReset();
 					break;
 				case 101:
-					Serial.println(freeRam(), DEC);
+					sendMsg(String(freeRam(), DEC) + String("\n"));
 					break;
-				case 102:
-					Serial.print(F("L"));
-					Serial.print(servoL.read(), DEC);
-					Serial.print(F(" R"));
-					Serial.print(servoR.read(), DEC);
-					Serial.print(F(" O"));
-					Serial.print(servoRot.read(), DEC);
-					Serial.print(F(" T"));
-					Serial.print(servoHRot.read(), DEC);
-					Serial.print(F(" H"));
-					Serial.println(servoH.read(), DEC);
-					break;
+				case 102: {
+					String msg = String(F("L")) + String(servoL.read(), DEC) +
+							String(F(" R")) + String(servoR.read(), DEC) +
+							String(F(" O")) + String(servoRot.read(), DEC) +
+							String(F(" T")) + String(servoHRot.read(), DEC) +
+							String(F(" H")) + String(servoH.read(), DEC) + String("\n");
+					sendMsg(msg);
+					break; }
 				case 112:
 					detachServos();
-					Serial.println(F("OK"));
+					sendMsg(F("OK"));
 					break;
 				case 113:
 					attachServos();
-					Serial.println(F("OK"));
+					sendMsg(F("OK"));
 					break;

 				default:
-					Serial.print(F("ERROR: invalid M address parameter: "));
-					Serial.println(code, DEC);
+					sendMsg(String(F("ERROR: invalid M address parameter: ")) + String(code, DEC) + String("\n"));
 					return false;
 			};
 			break;
 		default:
-			Serial.print(F("ERROR: invalid command: "));
-			Serial.println(buf[0]);
+			sendMsg(String(F("ERROR: invalid command: ")) + String(buf[0]) + String("\n"));
 			return false;
 	};
 }


Update pushbutton.ino

Update pushbutton.ino

--- pushbutton/pushbutton.ino
+++ pushbutton/pushbutton.ino
@@ -13,7 +13,7 @@

 }
 void loop(){
-  is_on = digitalRead(pinpin); // read from the button
+  is_on = digitalRead(pushpin); // read from the button

   if(is_on){
   digitalWrite(ledpin,HIGH); // on


Update ArduCAM_Shield_V2_Digital_Camera_2560.ino

--- ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Digital_Camera_2560/ArduCAM_Shield_V2_Digital_Camera_2560.ino
+++ ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Digital_Camera_2560/ArduCAM_Shield_V2_Digital_Camera_2560.ino
@@ -133,8 +133,16 @@
   Serial.println(F("ArduCAM Start!"));
   // set the SPI_CS as an output:
   pinMode(SPI_CS, OUTPUT);
+  digitalWrite(SPI_CS, HIGH);
   // initialize SPI:
   SPI.begin();
+
+  //Reset the CPLD
+  myCAM.write_reg(0x07, 0x80);
+  delay(100);
+  myCAM.write_reg(0x07, 0x00);
+  delay(100);
+
   while (1) {
     //Check if the ArduCAM SPI bus is OK
     myCAM.write_reg(ARDUCHIP_TEST1, 0x55);


updated project.ino

updated project.ino

--- project.ino
+++ project.ino
@@ -4,13 +4,17 @@
 #include <NewPing.h>

 //Max and Min value for the distance sensor
-float maxDistance = 400;
+float maxDistance = 200;
 float minDistance = 10;
+
+// # Cable management sensors #
+//   SUPPLY  |   S1    |   S2    |   S3
+// GND | +5V | E1 | T1 | E2 | T2 | E3 | T3

 //Define 3 distance sensors
 NewPing sonar1(11, 12, maxDistance); // Sensor 1: trigger pin, echo pin, maximum distance in cm
 NewPing sonar2(9, 10, maxDistance); // Sensor 2: trigger pin, echo pin, maximum distance in cm
-NewPing sonar3(7, 6, maxDistance); // Sensor 3: trigger pin, echo pin, maximum distance in cm
+NewPing sonar3(7, 8, maxDistance); // Sensor 3: trigger pin, echo pin, maximum distance in cm

 #define pingSpeed 100 // Ping frequency (in milliseconds), fastest we should ping is about 35ms per sensor
 unsigned long pingTimer1, pingTimer2, pingTimer3;
@@ -116,6 +120,17 @@
    Serial.println("PIN_SWITCH: ");
    Serial.println(digitalRead(PIN_SWITCH));

+   for(int i=0; i < 3; i++) {
+     if(distanceValues[i] < minDistance) {
+      if(distanceValues[i] == 0) {
+        distanceValues[i] = maxDistance;
+      }
+      else {
+        distanceValues[i] = minDistance;
+      }
+     }
+   }
+
    if(digitalRead(PIN_SWITCH)) {
       visualizeWithDirection();
     }
@@ -166,14 +181,6 @@
     //0 = 0,1 / 1 = 2,3 / 2 = 4,5
     //int distance = (distanceValues[i*2] + distanceValues[i*2+1]) / 2;
     int distance = distanceValues[i];
-    if(distance < minDistance) {
-      if(distance == 0) {
-        distance = maxDistance;
-      }
-      else {
-        distance = minDistance;
-      }
-    }
     //Serial.println(distance);
     int heightStrip = NUMBER_LEDS/NUMBER_STRIPS;

@@ -231,14 +238,6 @@
     //0 = 0,1 / 1 = 2,3 / 2 = 4,5
     //int distance = (distanceValues[i*2] + distanceValues[i*2+1]) / 2;
     int distance = distanceValues[i];
-    if(distance < minDistance) {
-      if(distance == 0) {
-        distance = maxDistance;
-      }
-      else {
-        distance = minDistance;
-      }
-    }
     int heightStrip = NUMBER_LEDS/NUMBER_STRIPS;

     //how many of the leds of one strip should be switched on


Cleanup

Cleanup

--- Arduino/McLighting/McLighting.ino
+++ Arduino/McLighting/McLighting.ino
@@ -86,9 +86,9 @@
     //DBG_OUTPUT_PORT.println(char(EEPROM.read(i + offset)));
   }

-  DBG_OUTPUT_PORT.print("Read EEPROM: [");
-  DBG_OUTPUT_PORT.print(res);
-  DBG_OUTPUT_PORT.println("]");
+  //DBG_OUTPUT_PORT.print("Read EEPROM: [");
+  //DBG_OUTPUT_PORT.print(res);
+  //DBG_OUTPUT_PORT.println("]");
   return res;
 }


simplify & fix Arduino audio modem code to match changes on Android side

--- Arduino/higgsmodem/higgsmodem.ino
+++ Arduino/higgsmodem/higgsmodem.ino
@@ -1,10 +1,9 @@
-#define MAX_ANDROID_MESSAGE 20
-#define MESSAGE_TIMEOUT 25
+#define MAX_ANDROID_MESSAGE 40
+#define SYNC_PEAKS 16
 // *** THESE VALUES WILL REQUIRE CALIBRATION ***
-#define PEAK_DETECT_THRESH 175
-#define FALLING_EDGE_TRIG 5
-#define STATE_RESET_THRESH 160
-#define SYNC_PEAKS 16
+#define PEAK_DETECT_THRESH 10
+#define CYCLE_RESET_THRESH 8
+#define MESSAGE_TIMEOUT 15

 int _syncPeaksCyclic[SYNC_PEAKS];
 int _syncHead;
@@ -13,61 +12,37 @@
 int _byte_pos;

 int _getNextAudioPeak(int timeout) {
-  // look for peaks in audio signal once sample exceeds PEAK_DETECT_THRESH (and saved as peak candidate)
-  // if current sample is greater than peak candidate - promote sample
-  // if peak candidate was set, and is greater than following FALLING_EDGE_TRIG samples, then we have detected a peak!
-  // reset state for next peak only after falling under STATE_RESET_THRESH
-  int sample, peak, falling_edge_length, no_sig_length;
-  enum PeakStates {
-    WaitingForPeak,
-    InPeak,
-    WaitingForReset,
-  } peak_detect_state=WaitingForPeak;
+  // look for peaks in audio signal once sample exceeds PEAK_DETECT_THRESH
+  // return peak after sample falls under CYCLE_RESET_THRESH
+  int sample, peak, no_sig_length;
+
   no_sig_length = 0;
-  while (1) {
+  sample = analogRead(A0);
+  while(sample <= PEAK_DETECT_THRESH) {
+    if ((timeout > 0) && (no_sig_length > timeout)) {
+      return 0;
+    }
+    ++no_sig_length;
     sample = analogRead(A0);
-    switch (peak_detect_state) {
-      case WaitingForPeak:
-      if (sample > PEAK_DETECT_THRESH) {
-        peak = sample;
-        falling_edge_length = 0;
-        no_sig_length = 0;
-        peak_detect_state = InPeak;
-      }
-      if (sample < STATE_RESET_THRESH) {
-        no_sig_length++;
-        if ((timeout > 0) && (no_sig_length > timeout)) {
-          return 0;
-        }
-      }
-      break;
-
-      case InPeak:
-      if (sample < peak) {
-        falling_edge_length++;
-        if (falling_edge_length > FALLING_EDGE_TRIG) {
-          peak_detect_state = WaitingForReset;
-        }
-      } else {
-        peak = sample;
-        falling_edge_length = 0;
-      }
-      break;
-
-      case WaitingForReset:
-      if (sample < STATE_RESET_THRESH) {
-        return peak;
-      }
+  }
+  peak = sample;
+
+  while (sample >= CYCLE_RESET_THRESH) {
+    if (sample > peak) {
+      peak = sample;
     }
+    sample = analogRead(A0);
   }
+
+  return peak;
 }

 int _isInSync() {
-  // look for a 0xA5 pattern in incoming audio bits
-  static int diffsign[SYNC_PEAKS-1] = {-1, +1, +1, -1, -1, +1, +1, -1, +1, -1, -1, +1, +1, -1, -1};
-  for (int i=0; i < sizeof(_syncPeaksCyclic) / sizeof(int); ++i) {
-    int
-    diff = _syncPeaksCyclic[(_syncHead + i + 1) % SYNC_PEAKS] - _syncPeaksCyclic[(_syncHead + i) % SYNC_PEAKS];
+  // look for a 0xA5 pattern in incoming audio peaks
+  static int diffsign[SYNC_PEAKS-1] = {
+    +1, -1, -1, +1, +1, -1, -1, +1, -1, +1, +1, -1, -1, +1, +1  };
+  for (int i=0; i < SYNC_PEAKS-1; ++i) {
+    int diff = _syncPeaksCyclic[(_syncHead + i + 1) % SYNC_PEAKS] - _syncPeaksCyclic[(_syncHead + i) % SYNC_PEAKS];
     if (diff * diffsign[i] < 0) {
       return 0;
     }
@@ -81,7 +56,7 @@
   // until there's no next peak for MESSAGE_TIMEOUT samples after last data peak
   int ref_sig_val, value_sig_val;
   char b=0;
-
+
   // bit-decode loop
   for (int bitpos=0; bitpos < 8; ++bitpos) {
     ref_sig_val = _getNextAudioPeak(MESSAGE_TIMEOUT);
@@ -95,7 +70,7 @@
     }
   }
   // return byte with swapped nibbles
-  return ((b & 0x0F) << 4) | ((b & 0xF0) >> 4);
+  return b;
 }

 int getAndroidMessage() {
@@ -103,7 +78,7 @@
   // so don't use those in your messages!
   _byte_pos = 0;
   memset(AndroidMessage, 0, sizeof(AndroidMessage));
-
+
   // lock on sync (0xa5)
   for (int i=0; i < sizeof(_syncPeaksCyclic) / sizeof(int); ++i) {
     _syncPeaksCyclic[i] = _getNextAudioPeak(-1);
@@ -113,12 +88,12 @@
     _syncPeaksCyclic[_syncHead] = _getNextAudioPeak(-1);
     _syncHead = (_syncHead + 1) % SYNC_PEAKS;
   }
-
+
   // byte-decode loop
   unsigned char b;
   while ((b = _getNextByte()) != 0) {
     // remove redundant sync bytes
-    if ((0xA5 == b) || (0x5A == b)) {
+    if (0xA5 == b) {
       continue;
     }
     AndroidMessage[_byte_pos++] = (char)b;
@@ -147,3 +122,4 @@
   }
   Serial.println(AndroidMessage);
 }
+


Remove Unnecessary Comments

Remove Unnecessary Comments

--- ArduinoOnBoard/ArduinoOnBoard.ino
+++ ArduinoOnBoard/ArduinoOnBoard.ino
@@ -28,6 +28,7 @@
 #include <Adafruit_Sensor.h>
 #include <Adafruit_LSM303_U.h>
 #include <Adafruit_Simple_AHRS.h>
+#include "DHT.h"

 MS5837 sensor;

@@ -41,26 +42,11 @@
 // Example testing sketch for various DHT humidity/temperature sensors
 // Written by ladyada, public domain

-#include "DHT.h"
+

 #define DHTPIN 2     // what digital pin we're connected to
+#define DHTTYPE DHT11   // DHT 11

-// Uncomment whatever type you're using!
-#define DHTTYPE DHT11   // DHT 11
-//#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
-//#define DHTTYPE DHT21   // DHT 21 (AM2301)
-
-// Connect pin 1 (on the left) of the sensor to +5V
-// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
-// to 3.3V instead of 5V!
-// Connect pin 2 of the sensor to whatever your DHTPIN is
-// Connect pin 4 (on the right) of the sensor to GROUND
-// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor
-
-// Initialize DHT sensor.
-// Note that older versions of this library took an optional third parameter to
-// tweak the timings for faster processors.  This parameter is no longer needed
-// as the current DHT reading algorithm adjusts itself to work on faster procs.
 DHT dht(DHTPIN, DHTTYPE);

 void setup()


Added nicer overview of available commands

--- ArduinoTestTool/ArduinoTestTool.ino
+++ ArduinoTestTool/ArduinoTestTool.ino
@@ -1,4 +1,10 @@
 #include <SPI.h>
+
+// Message types of Radio connector
+#define KEEPALIVE 1
+#define LISTACCESSPOINTS 2
+#define JOINACCESSPOINT 3
+#define QUITACCESSPOINT 4

 const int slaveSelectPin = 10;
 const int interruptPin = 2;
@@ -32,24 +38,53 @@
   if (Serial.available()) {
     String command = Serial.readStringUntil('\n');

-    if(command == "Hello") {
-      char message[] = "Master Alive";
-
-      digitalWrite(slaveSelectPin,LOW);
+    // Check for request command
+    if(command == "Alive") {
+      sendKeepAlive();
+    } else if(command == "ListAp") {
+      sendListAp();
+    } else {
+      Serial.println("Available commands:");
+      Serial.println("Alive  --- Request keep alive from slave");
+      Serial.println("ListAp --- Request accesspoints from slave");
+      Serial.println();
+    }
+  }
+}

-      Serial.println("Keep alive sent");
+/**
+ *  Send Keep Alive to slave
+ */
+void sendKeepAlive(void) {
+  char message[] = "Master Alive";

-      //SPI.transfer(0x01);
-      //SPI.transfer(sizeof(message));
-      //SPI.transfer(message, sizeof(message));
+  // Sending keep alive
+  Serial.println("---> Sending keep alive");

-      SPI.transfer(0x02);
-      SPI.transfer(0x00);
+  // Request keep alive
+  digitalWrite(slaveSelectPin,LOW);
+
+  SPI.transfer(KEEPALIVE);
+  SPI.transfer(sizeof(message));
+  SPI.transfer(message, sizeof(message));
+
+  digitalWrite(slaveSelectPin,HIGH);
+}

-      digitalWrite(slaveSelectPin,HIGH);
-
-    }
-  }
+/**
+ *  Send list accesspoints
+ */
+void sendListAp() {
+  // Keep alive sent to slave
+  Serial.println("---> Sending list accesspoints");
+
+  // Request accesspoints
+  digitalWrite(slaveSelectPin,LOW);
+
+  SPI.transfer(LISTACCESSPOINTS);
+  SPI.transfer(0x00);
+
+  digitalWrite(slaveSelectPin,HIGH);
 }

 void incomingMessage() {


defined all board LEDs

defined all board LEDs

--- utils/blink/blink.ino
+++ utils/blink/blink.ino
@@ -3,20 +3,41 @@
 // Pin 6  has the LED on Teensy++ 2.0
 // Pin 13 has the LED on Teensy 3.0

-#define LED 13
+#define LED0 13
+#define LED1 17
+#define LED2 16
+#define LED3 15
+#define LED4 14
+#define LED5 2
+
 #define PULSE 200

 void setup()
 {
     // initialize the digital pin as an output.
-    pinMode(LED, OUTPUT);
+    pinMode(LED0, OUTPUT);
+    pinMode(LED1, OUTPUT);
+    pinMode(LED2, OUTPUT);
+    pinMode(LED3, OUTPUT);
+    pinMode(LED4, OUTPUT);
+    pinMode(LED5, OUTPUT);
 }

 // the loop routine runs over and over again forever:
 void loop()
 {
-    digitalWrite(LED, HIGH);
+    digitalWrite(LED0, HIGH);
+    digitalWrite(LED1, HIGH);
+    digitalWrite(LED2, HIGH);
+    digitalWrite(LED3, HIGH);
+    digitalWrite(LED4, HIGH);
+    digitalWrite(LED5, HIGH);
     delay(PULSE);
-    digitalWrite(LED, LOW);
+    digitalWrite(LED0, LOW);
+    digitalWrite(LED1, LOW);
+    digitalWrite(LED2, LOW);
+    digitalWrite(LED3, LOW);
+    digitalWrite(LED4, LOW);
+    digitalWrite(LED5, LOW);
     delay(PULSE);
 }


Update ESP_DHT22_upload.ino

Update ESP_DHT22_upload.ino

Dependency on staging board manager added

--- ESP8266-code/ESP_DHT22_upload.ino
+++ ESP8266-code/ESP_DHT22_upload.ino
@@ -1,3 +1,11 @@
+/*
+ code for ESP8266
+As of 2016-01-12  this needs the staging version of the ESP board manager:
+  http://arduino.esp8266.com/staging/package_esp8266com_index.json
+(released version throws the _sqrt error)
+
+
+*/
 #include <ESP8266WiFi.h>
 #include "DHT.h"


json update

json update

--- _04-lcd-dust/_04-mqtt-lcd-dust-sensor-esp-12/_04-mqtt-lcd-dust-sensor-esp-12.ino
+++ _04-lcd-dust/_04-mqtt-lcd-dust-sensor-esp-12/_04-mqtt-lcd-dust-sensor-esp-12.ino
@@ -1,4 +1,4 @@
-// 80MHz / 4M / 1M / ESP-01 (flash chip is changed)
+// 80MHz / 4M / 1M / ESP-01 (flash chip is changed) / esp-lcd
 #include <TimeLib.h>
 #include <pgmspace.h>
 #include <ESP8266WiFi.h>
@@ -56,7 +56,7 @@
 //
 //RtcDS3231 Rtc;

-#define DEBUG_PRINT 1
+#define DEBUG_PRINT 0

 char* topic = "esp8266/arduino/s03";
 char* subtopic = "#";
@@ -230,8 +230,8 @@
     Serial.println(ESP.getFreeHeap());
   }

-  char json[] = "{\"VIrms\":595,\"revValue\":718.56,\"revMills\":8350,\"powerAvg\":656.78,\"Stddev\":66.70,\"calcIrmsmillis\":153,\"revCounts\":126,\"FreeHeap\":46336,\"RSSI\":-61,\"millis\":1076571}";
-  //{"Humidity":43.90,"Temperature":22.00,"DS18B20":22.00,"PIRSTATUS":0,"FreeHeap":43552,"acquireresult":0,"acquirestatus":0,"DHTnextSampleTime":2121587,"bDHTstarted":0,"RSSI":-48,"millis":2117963}
+  //char json[] = "{\"VIrms\":595,\"revValue\":718.56,\"revMills\":8350,\"powerAvg\":656.78,\"Stddev\":66.70,\"calcIrmsmillis\":153,\"revCounts\":126,\"FreeHeap\":46336,\"RSSI\":-61,\"millis\":1076571}";
+  char json[] = "{\"Humidity\":43.90,\"Temperature\":22.00,\"DS18B20\":22.00,\"PIRSTATUS\":0,\"FreeHeap\":43552,\"acquireresult\":0,\"acquirestatus\":0,\"DHTnextSampleTime\":2121587,\"bDHTstarted\":0,\"RSSI\":-48,\"millis\":2117963}";

   receivedpayload.toCharArray(json, 400);
   StaticJsonBuffer<400> jsonBuffer;


removing unique EUIs -> placeholder values

--- examples/ttn-otaa-feather-us915-dht22/ttn-otaa-feather-us915-dht22.ino
+++ examples/ttn-otaa-feather-us915-dht22/ttn-otaa-feather-us915-dht22.ino
@@ -34,17 +34,17 @@
 // first. When copying an EUI from ttnctl output, this means to reverse
 // the bytes. For TTN issued EUIs the last bytes should be 0xD5, 0xB3,
 // 0x70.
-static const u1_t PROGMEM APPEUI[8]= { 0xEF, 0x24, 0x01, 0xD0, 0x7E, 0xD5, 0xB3, 0x70 };
+static const u1_t PROGMEM APPEUI[8]= { YOUR_APPEUI_HERE };
 void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI, 8);}

 // This should also be in little endian format, see above.
-static const u1_t PROGMEM DEVEUI[8]= { 0xD6, 0xDD, 0x10, 0x00, 0x00, 0xB6, 0x76, 0x98 };
+static const u1_t PROGMEM DEVEUI[8] = { YOUR_DEVEUI_HERE };
 void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI, 8);}

 // This key should be in big endian format (or, since it is not really a
 // number but a block of memory, endianness does not really apply). In
 // practice, a key taken from the TTN console can be copied as-is.
-static const u1_t PROGMEM APPKEY[16] = { 0xBE, 0xDE, 0xCE, 0x25, 0x06, 0x38, 0xD1, 0x4D, 0x8E, 0x73, 0xE9, 0xE5, 0x61, 0x9F, 0xCC, 0xC3 };
+static const u1_t PROGMEM APPKEY[16] = { YOUR_APPKEY_HERE };
 void os_getDevKey (u1_t* buf) {  memcpy_P(buf, APPKEY, 16);}

 // payload to send to TTN gateway