feat(sterni/blipqn): interact with a flipdot display from BQN

The idea of this “library” is to do the least. The most natural way to
represent the image to render on a flipdot image is a two dimensional
array of booleans. This something BQN is very well equipped for, i.e. it
has primitives that are designed to deal with this type of data
structure. The only thing we have to do is to take care of sending such
arrays to the flipdot display via the μCCC's un(der)documented UDP
protocol.

Compact implements the conversion from a boolean array to a bitmap that
only uses 1 bit per pixel. All socket code is written in C and invoked
via •FFI. Currently, every time a bitmap is sent to a display, the
target host has to be resolved again. This should be fixed in the
future.

Change-Id: Idea7c81baac919da93c88a69f98cbbbd026fa328
Reviewed-on: https://cl.tvl.fyi/c/depot/+/13010
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
sterni 2025-01-12 22:18:14 +01:00
parent b51720f844
commit 1027e21eee
6 changed files with 148 additions and 0 deletions

View file

@ -0,0 +1,20 @@
MakeFlipdot
# - host (char*) argument:
# - Assume char is i8 (safe even if it's actually u8 if
# ASCII). We can't let •FFI check this for us since CBQN doesn't support
# specifying c7. We do this in MakeFlipdot
# - Needs to be zero-terminated, we also do this in MakeFlipdot.
# - bitmap_len (size_t) argument: assume size_t is at least u32.
ffi_send_to_flipdot "libflipdot.so" •FFI "i8""send_to_flipdot""*i8:c8""u16""*u8""u32"
Compact +´( × 2)˘(8)
MakeFlipdot {
hostport 𝕊 wh:
"Total pixel count must be divisible by 8" ! 0=8|w×h
"Hostname must be ASCII" ! ´(@+127)host
shape hw
empty shape0
Send {"sendto(2) error"!FFI_send_to_flipdot (host@)port() Compact 𝕩}
}