Expand description
sigroot_applet_interface - A Rust interface structure for Framework LED Matrix
Interface library contains an AppletInterface struct for communicating with the LED matrix board program
new() requires the localhost’s port that is currently used by the LED matrix board program, the applet number being interfaced with (0 is the top row status bar, 1-3 are the applets, 4-256 are invalid), and the separator type (if not variable, attempts to use set_bar() will error)
set_grid(), set_point(), and set_bar() modify the struct’s internal grid and separator while write_grid() and write_bar() send both to the LED matrix board program respectively
Raw communication is in the following format:
Communication is over TCP
Commands are sent with JSON encoded ‘Command’ strucutres in the format:
{
"opcode": "<Command Name>",
"app_num": <Applet Number (0-2)>,
"parameters": [x<,y<,...z> (where each value is a u8)]
}
Commands:
CreateApplet - Creates a new applet assigned to the requesting TCP stream
Parameters: 1 u8 from 0-3
0 - Applet separator is empty (all LED's off)
1 - Applet separator is solid (all LED's on)
2 - Applet separator is dotted (alternating LED's on & off)
3 - Applet seprator is variable (default off)
UpdateGrid - Rewrites the current 9x10 applet grid with new values
Parameters:
90 u8 representing grid brightnesses - rows then columns (1st 10 is row1, 2nd 10 is row2, etc.)
UpdateBar - Rewrites the current 9x1 applet separator
Parameters:
9 u8 representing separator brightnesses
Note: Error 32 returned if bar is not variable
sig_rp2040_board will respond with a single u8 error code (not JSON):
0: Command successfully processed
10: Failed to read data from stream
20: Failed to parse stream data as UTF-8
21: Failed to parse stream data as JSON
30: Command uses invalid applet number (greater than 2)
31: Command attempts to modify applet stream did not create
32: Attempt to update applet 0 grid
33: Error in commanding applet
34: Attempt to create new applet when applet already exists
40: Invalid separator value when creating applet
255: Unknown error