From 35822a08c95f5fb3022c316d27ba0c0cef91745a Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Fri, 16 Nov 2012 18:37:24 +0100 Subject: [PATCH] Add synchronization byte \xAC at the beginning of RGB burst --- arduino/controlled/controlled.ino | 5 +++++ host/ledbar.c | 6 +++++- host_python/send_to_serial.py | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/arduino/controlled/controlled.ino b/arduino/controlled/controlled.ino index a5eef65..2d8e56b 100644 --- a/arduino/controlled/controlled.ino +++ b/arduino/controlled/controlled.ino @@ -23,6 +23,11 @@ void setup() void loop() { int led, i; + /* Wait for synchronization. */ + do { + while (!Serial.available()); + } while (Serial.read() != 0xAC); + /* Set LEDs. */ for (led = 0; led < cpinsets; led++) { for (i = 0; i < CH; i++) { while (!Serial.available()); diff --git a/host/ledbar.c b/host/ledbar.c index 7168054..18fe5da 100644 --- a/host/ledbar.c +++ b/host/ledbar.c @@ -298,6 +298,9 @@ void drawScreen(SDL_Surface* screen, int t, FILE* fp) if(SDL_MUSTLOCK(screen) && SDL_LockSurface(screen) < 0) return; + if (fp) + fwrite("\xAC", 1, 1, fp); + for (i=0; i 0: read = sys.stdin.read(to_read)