/christmas

Fall 2023

Primary LanguageGoGNU General Public License v3.0GPL-3.0

acm-christmas

Needs Nix. To enter, run nix-shell.

Shopping List

  • Christmas Tree
    • Price: $49.99
    • Size: 6ft (~1.8m)
  • Raspberry Pi
    • Stolen Borrowed from ACM
  • LED Strips (12V)
    • Actual LED bulbs rather than strips, so better for 2D use.
    • 0.3W per bulb, 50 bulbs per strip, 15W per strip
      • For 5V, 3A per strip
      • For 12V, 1.25A per strip
    • Price:
      • $18.50 (50x, 13ft, 4m)
      • $37.00 (100x, 26ft, 8m)
      • $55.50 (150x, 39ft, 12m)
  • LED Power Supply (12V)
    • Price: $11.99
    • 12V 5A, so can power 4 strips or 200 bulbs

Hardware

Raspberry Pi

The Raspberry Pi will run the main daemon, which is in charge of:

  • Accepting Protobuf commands and handling them,
  • Running interpolation algorithms to convert images into LED data (if required), and
  • Controlling the LEDs.

The Raspberry Pi should run a very minimal Linux distribution, such as Alpine Linux or, even better, some kind of embedded Linux distribution that supports real-time scheduling.

Ideally, the Go daemon should also be optimized:

  • No allocations should be performed during the main loop, and
  • It should run with real-time scheduling.

We could leverage Go's pprof to profile the daemon and see where it's spending most of its time. Some real-world benchmarking will be required.

The LEDs are driven using the Raspberry Pi's DMA capabilities and a PWM pin. This allows the Pi to achieve the hardware-level timing required to drive the WS2811 LEDs.

Tools

You must run make before running any of the tools.

live-capture

Starts an FFmpeg daemon that keeps an up-to-date BMP image that is the current frame of the given webcam.

Before running live-capture, you must first edit camerarc to specify the webcam you want to use. You can find the name of your webcam by running v4l2-ctl --list-devices.

Then, to start capturing, run:

live-capture start

To start capturing with a black-and-white threshold filter:

live-capture start --filter-args "$(ffutil threshold 640x480 0.5)"

To view a snapshot of the current frame:

live-capture view

To take a snapshot of the current frame onto a PNG file:

live-capture snapshot /tmp/snapshot.png

Note: If the snapshot is also a BMP file, no conversion is performed, so the snapshot will be very fast.

christmasd

The actual daemon that controls the LEDs. It exposes an HTTP server that can be invoked to set the color of a given LED as well as perform various other higher-level tasks.

See proto/christmasd.proto for the full API.

christmas-gio

A variant of christmasd that uses GIO to render the LEDs to a window instead of actually controlling the LEDs. This daemon exposes a local HTTP server that can be used to control the LEDs. It follows the same Proto API as the above.

TODO: implement