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:
parent
b51720f844
commit
1027e21eee
6 changed files with 148 additions and 0 deletions
29
users/sterni/blipqn/examples.bqn
Executable file
29
users/sterni/blipqn/examples.bqn
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env BQN
|
||||
|
||||
⟨MakeFlipdot⟩ ⇐ •Import "../lib/"⊸∾⍟("bin" (⊣≡(-∘≠⊸↑)) •path) "blipqn.bqn"
|
||||
|
||||
examples ← ⍉>⟨
|
||||
"random"‿{𝕩.Send 𝕩.shape •rand.Range 2},
|
||||
"235"‿{𝕩.Send 1˙⌾(4‿22⊸⊑) 𝕩.empty},
|
||||
⟩
|
||||
|
||||
usage ← "Usage: "∾•name∾" HOST PORT WIDTH HEIGHT EXAMPLE"∾"
|
||||
|
||||
where EXAMPLE is one of
|
||||
|
||||
"∾∾{(7↑"")∾"- "∾𝕩∾@+10}¨⊏examples
|
||||
|
||||
# TODO(sterni): this is an atrocious interface
|
||||
opts ← {
|
||||
(•Exit 1˙∘•Out)⍟(5⊸≠≠•args) usage
|
||||
host‿port‿width‿height‿example ← •args
|
||||
|
||||
example ⇐
|
||||
addr ⇐ host⋈•ParseFloat port
|
||||
dim ⇐ •ParseFloat¨ width‿height
|
||||
}
|
||||
|
||||
action ← examples (⊏⊸(⊑∘⊐) ⊑ ⊏˜⟜1)⟜< opts.example
|
||||
|
||||
flip ← opts.addr MakeFlipdot opts.dim
|
||||
Action flip
|
||||
Loading…
Add table
Add a link
Reference in a new issue