[SOFT] AtmoDuinoSync - a way to lip-sync your AtmoDuino (1 Viewer)

kenwonders

MP Donator
  • Premium Supporter
  • January 19, 2007
    791
    741
    Home Country
    England England
    This Arduino code can allow you to add a delay (in milliseconds) to the output so that your AtmoDuino updates at the same time as your TV. This is not the same as the loop delay as is in the AtmoLight plugin, this will drive the LEDs at the same rate as received, but delayed by the amount of time you specify, just like with audio.

    To install:
    • Ensure you are already able to compile the existing AtmoDuino source. Note your addLED setting.
    • Install the FastLED library (from here: http://fastled.io/)
    • Install the QueueArray library (from here: http://playground.arduino.cc/Code/QueueArray)
    • Unzip file from this thread and place in dir (or open it and let the Arduino software do this for you)
    • Change the 3 settings near the top to suit
      • NUM_LEDS - How many LEDs in your set
      • SERIAL_TIMEOUT - How long after no data is received before blanking out LED set
      • STREAM_DELAY - How long to delay the LED stream after receiving it.
    • Change the addLeds call to suit
    • Compile, upload and test with AtmoWin/AmbiBox
    The LED data is buffered in a QueueArray. If you are using a Mega then you will be able to add nearly a second delay to 50 leds. To calculate how long, you can use these calculations:
    1 stream = 3 x (number of leds = 50 for me) + 4 = 154 bytes - how many bytes per led set, 4 bytes for unsigned long to hold frame time
    60 fps = 16.67ms per frame
    - worst case scenario for data rate from tv/film, change to 10ms for worst case colourcycle usage

    Using Uno = 2k = 2048
    2048 / 154 = number of whole frames = 13
    13 - 3 (safety margin, other data in sram) = 10
    10 * 16.67ms = 166.7ms maximum delay

    Mega/Teensy = 8k = 8192
    8192 / 154 = number of whole frames = 53
    53 - 3 (safety margin, other data in sram) = 50
    50 * 16.67ms = 833.5ms maximum delay

    All suggestions for improvements would be great. I have some comments:

    - This code was put onto a kit known as 'AdaLight' which although has a really lovely Arduino driver (a state machine), it is not well supported in software. If you have an AdaLight, this will work out the box for you as an AtmoDuino.

    - If you buy a set of LEDs to chain with existing set and they do not work, ignore logic and try the data/clock in reverse (even if the arrows suggest otherwise!).

    - Lastly a huge thank you to the other posters on this forum both English and German (translated!) for all their posts, I would not have a working setup without all that useful information.

    Last file update: 2.1 - changed to FastLED
     

    Attachments

    • AtmoDuinoSync2.zip
      2.2 KB
    Last edited:

    kenwonders

    MP Donator
  • Premium Supporter
  • January 19, 2007
    791
    741
    Home Country
    England England
    Updated with new version to ignore channel information sent. This will make it work with both AtmoWin and Ambibox.
     

    kenwonders

    MP Donator
  • Premium Supporter
  • January 19, 2007
    791
    741
    Home Country
    England England
    i have added your last version ( 2.1) to ambilight 4 mediaportal repo. ;)

    Cool! It's great to think it will be of use to others. Seeing a mod already up there is addicting, I need to write more for free :)

    How much ram does the Teensy have? I am thinking of calculating the limits so I can keep systems stable.
     

    azzuro

    Test Group
  • Team MediaPortal
  • May 10, 2007
    9,984
    5,663
    France - IDF
    Home Country
    France France
    it's an Atmel32u4 same as arduino leonardo, i have set it to 5ms ( because don't need it), but my first version was 0 ms = none delay, and Atmowin bug.
    my sketch is in Atmoduinosync2_2_1_teensy ( but not sure i have uploaded the last one )

    edit : Teensy2 have
    RAM Memory2560
    so, 2.5 kb, can you share the formul for know what is the max of delay we can ?
     
    Last edited:

    Users who are viewing this thread

    Top Bottom