[SOFT] AtmoDuinoSync - a way to lip-sync your AtmoDuino

Discussion in 'Ambient Lighting System' started by kenwonders, January 26, 2014.

  1. kenwonders
    • Premium Supporter

    kenwonders MP Donator

    Joined:
    January 19, 2007
    Messages:
    788
    Likes Received:
    416
    Gender:
    Male
    Ratings:
    +766 / 0
    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
     

    Attached Files:

    Last edited: February 11, 2014
    • Thank You! Thank You! x 4
    • Great Idea! Great Idea! x 1
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. azzuro
    • Team MediaPortal

    azzuro Test Group

    Joined:
    May 10, 2007
    Messages:
    8,397
    Likes Received:
    2,479
    Occupation:
    technician HVAC
    Location:
    France - IDF
    Ratings:
    +4,136 / 13
    Home Country:
    France France
    Show System Specs
    i have deleted your post, on @Lightning303 thread.
    i'm interested by your work. but more as help for coding on Arduino side ... ;)
     
  4. azzuro
    • Team MediaPortal

    azzuro Test Group

    Joined:
    May 10, 2007
    Messages:
    8,397
    Likes Received:
    2,479
    Occupation:
    technician HVAC
    Location:
    France - IDF
    Ratings:
    +4,136 / 13
    Home Country:
    France France
    Show System Specs
    i think you can update your librarie with FastLED ( the new name ) available here : https://github.com/FastLED/FastLED

    the librarie 2.1 ( next release) working great for me
     
  5. kenwonders
    • Premium Supporter

    kenwonders MP Donator

    Joined:
    January 19, 2007
    Messages:
    788
    Likes Received:
    416
    Gender:
    Male
    Ratings:
    +766 / 0
    Home Country:
    England England
    Updated with new version to ignore channel information sent. This will make it work with both AtmoWin and Ambibox.
     
  6. azzuro
    • Team MediaPortal

    azzuro Test Group

    Joined:
    May 10, 2007
    Messages:
    8,397
    Likes Received:
    2,479
    Occupation:
    technician HVAC
    Location:
    France - IDF
    Ratings:
    +4,136 / 13
    Home Country:
    France France
    Show System Specs
    Hey,
    why don't update your librarie, you use the old one, now.
    the new is FastLed, no more FastSPI_LED
     
  7. kenwonders
    • Premium Supporter

    kenwonders MP Donator

    Joined:
    January 19, 2007
    Messages:
    788
    Likes Received:
    416
    Gender:
    Male
    Ratings:
    +766 / 0
    Home Country:
    England England
    Because I am an old fool who forgot :) Will update it later on.
     
  8. kenwonders
    • Premium Supporter

    kenwonders MP Donator

    Joined:
    January 19, 2007
    Messages:
    788
    Likes Received:
    416
    Gender:
    Male
    Ratings:
    +766 / 0
    Home Country:
    England England
    Updated to FastLED library
     
    • Like Like x 1
  9. azzuro
    • Team MediaPortal

    azzuro Test Group

    Joined:
    May 10, 2007
    Messages:
    8,397
    Likes Received:
    2,479
    Occupation:
    technician HVAC
    Location:
    France - IDF
    Ratings:
    +4,136 / 13
    Home Country:
    France France
    Show System Specs
  10. kenwonders
    • Premium Supporter

    kenwonders MP Donator

    Joined:
    January 19, 2007
    Messages:
    788
    Likes Received:
    416
    Gender:
    Male
    Ratings:
    +766 / 0
    Home Country:
    England England
    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.
     
  11. azzuro
    • Team MediaPortal

    azzuro Test Group

    Joined:
    May 10, 2007
    Messages:
    8,397
    Likes Received:
    2,479
    Occupation:
    technician HVAC
    Location:
    France - IDF
    Ratings:
    +4,136 / 13
    Home Country:
    France France
    Show System Specs
    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: February 11, 2014
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!