Inverted / tasbot_eyes

Software, to control the eyes of the new TASBot, build by blastermak
BSD 2-Clause "Simplified" License
0 stars 3 forks source link

tasbot_eyes

Dependencies and credit

Install

  1. Clone, compile and install the rpi_ws281x lib (requires cmake)
  2. Download, compile and install GIFLIB (found here on SourceForge, requires make)
  3. Clone and compile this repo (requires cmake)
    :warning: ATTENTION: When compiling for real TASBot, make sure bool realTASBot ist set to true (it is by default)

If you experience an error, that a shared library can't be loaded, try to execute ldconfig to update your library chache (and maybe reboot).

How it works

The program looks within its current working directory, for a folder called gifs and subdirectories within it.

Path Explanation
./gifs/others Here go all the general animations. The program is choosing randomly animations from here
./gifs/blinks Here are all blinking animations, the program can choose from
./gifs/base.gif The animation, TASBots eye returns to between the animations and blinks
./gifs/startup.gif The animation, that gets played exactly once, when the program starts

Abstract program flow

  1. Startup
  2. Play startup animation
  3. Show base animation
  4. Sleep a random amount of time
  5. Do a blink cycle, meaning
    1. Determine how many times TASBot blinks (n)
    2. Play random blink animation
    3. Show base expression
    4. Sleep
    5. n = n-1
    6. If n>0, go to b.
  6. Check if animation stack is empty
    • if not:
      1. Pop top animation from stack
      2. Check if the animation has its own color. If not, choose a random one and overwrite all set pixels if wished
      3. Play animation
    • else:
      1. Generate a new stack and go to 6.
  7. Go to 3.

About blink patterns

It can be defined, how many times at most TASBot blinks between every random animation, but at least always once (if pattern is not making skipping them, e.g. 0-x-y). It can also be defined, how long are the periods are between the blinks.
Example: 3-4-6

  1. 3: Maximum amount of blinks between blinks
  2. 4: At least 4 seconds between each blink...
  3. 6: ...but at most 6 seconds.

The actual amount of seconds the program sleeps between the blinks is randomly generated in milliseconds. In this example, TASBot could wait 4581 ms, just as 5987 ms. He could blink at least once, but at most 3 times, before the next random animation

Usage

See the build-in -h option or arguments.c:28 to get an overview of all available arguments. There are some for changing the playback speed, setting the data pin, playing a specific animation and many more!

Create color palette

Color palettes are the random colors TASBot can choose from when playing a monochrome animation and colorful mode is activated. To create a color palette, you can either:

Inject animation

To inject any animation :warning: that is already stored on TASBot :warning: send a UDP datagram to 8080. An abstract payload could look like T;./path/to/animation.gif.

To make injecting animations easier, you can use the Animation Injectoar (aNinja) from the TASBot-Eyes-Toolkit if you want to.

WLED UDP realtime control

The centered "nose" LEDs can be controlled in real time with the -U argument. It's based on the WLED UDP realtime control protocol, see here. Right now, only the DRGB mode is supported, also known as mode 2. It covers an area of 48 LEDs in total in a 8x6 matrix.

Colorchord

ColorChord 2 by CNLohr supports WLED instances. In order to be able to use the realtime control with ColorChord, make sure to add something like this section to your ColorChord config file:

leds = 48
lightx = 8
lighty = 6

wled_realtime = 1
port = 19446  # Default port for UDP realtime
address = x.x.x.x  # TASBot IP
wled_timeout = 2 

There's also an example ColorChord config file (colorchord.conf) in the misc folder of this repository.

Known problems

Future ideas

Thanks to