Hardware-wise, this is a simple project, with only three components:
- USB-C PD trigger
- ESP32 dev kit
- WS2812 "seed" light string, 10m long with 100 lights
The USB-C PD trigger is currently being powered by an old Nintendo Switch power supply, and provides 5V to the rest of the system (the dev kit board has an internal 5V->3.3V converter).
Outside of power, there is only a single connection to be made, from D13 on the ESP32 to the data line on the WS2812 LEDs. D13 was chosen for its proximity to the 5V and GND pins on the ESP32.
The components have been placed into a two piece 3D printed enclosure, the ESP32 dev kit screwed down, and the power supply module is held in place by the enclosure itself.
The software is written in a combination of C++ for the microcontroller, and HTML/JavaScript for the web site it hosts.
The VM that is runs the light programs on the ESP32 is implemented as a set of "case" statements in a big "switch" block. There are a total of 61 opcodes for the VM to execute. Variables are all global and strongly-typed, with different opcodes for different data types. Procedures can be called and returned from, but all information passing is via the global variables - there are no parameters or return values.
These decisions were made to keep the code as simple as possible, while also enforcing type safety from implementation in Blockly to the execution. It should not be possible to define a program that mixes variable type through the UI,though I'm sure an inventive enough user would find a way.
Blockly was chosen as the language implementation for its ease of use, the target audience for writing light setting programs is my children (as well as myself). It allows for users to simply drag and drop code blocks onto a canvas, snapping them together to form the program. The nice thing about Blockly vs a text-based language is that Blockly restricts what the user can enter, so restricts the possible invalid program entries.
The user can access the interface via a web server built into the ESP32, no apps or internet connection is necessary.