Make use of your Hue lights and set up a lightshow!
This project stems from me learning Rust and trying to find a practical application that would guide my learning.
A while back I created a Rust wrapper for the Hue lights called lighthouse. I then got sidetracked into writing other tools and fun stuff based on that API:
- trigger lights from by playing my drums: see here.
- change light color in your room based on what type of code you write: see here
As part of that I decided that I wanted to somehow store mappings of light behaviour to the midi input sequences. I wrote a really poor parser for a format and just left it. But having learned Haskell previously I always wanted to try parser combinators.
This project is essentially me learning parser combinators by writing a scripting language that my lights can interpret and that I can later map to my drums.
cargo install --git https://github.com/finnkauski/lightshow
lshow ../path/to/file.lshow
The following are example syntax for the language.
Generally - check out example.lshow
for a sample script.
- change color to the given hex color -
color <hex_color>
- blink lights -
blink <n_times> <pause_between> <hex_color>
- wait for n seconds
wait <n_seconds>
You can assign an action to a variable as follows:
variable_action: act = color ff0000;
This defines a sequence of individual actions
or commands to your lights.
variable_sequence: seq = {
color ff0000;
wait 1;
color 00ff00;
wait 1;
color 0000ff;
};
And finally the way to trigger the saved actions or sequences is by using the trigger
statement.
trigger variable_sequence;