Project:USB Disco Dance Floor/v1/firmware: Difference between revisions

From London Hackspace Wiki

Added full doc in comment at the end until I have time to transfer it to wikitext
(Added skeleton for other commands, and note about ping response)
(Added full doc in comment at the end until I have time to transfer it to wikitext)
Line 152: Line 152:
|colspan="2"|???
|colspan="2"|???
|}
|}
<!--
Code | Action
=====+========================================================================
                          STATUS/DIAGNOSTIC COMMANDS
-----+------------------------------------------------------------------------
00  | Reset                                                            v1.0
    | Resets the board to an initial state, with all pixels off. The board
    | sends four bytes representing its hardware and firmware version (2
    | each), followed by 2 bytes for hardware details. The high nybble of
    | the first hardware info byte is the number of different colours
    | supported (0x1, 0x3 or 0x4) and the low nibble is whether sensors are
    | supported (0x1 for yes). The high nybble of the second byte specifies
    | the number of bits needed to specify LED brightness (if different for
    | different colours, the firmware will scale as necessary) and the low
    | nybble does the same for sensor resolution. Note that, for the time
    | being, resolutions should be a power of 2 (0x1, 0x2, 0x4, 0x8). This
    | comand also resets the stored board ID to 0xFFFF (unset).
-----+------------------------------------------------------------------------
01  | Identify                                                          v1.0
    | Informs the board of its board ID for this session (two bytes). Note
    | that board IDs 0x0000 and 0xFFFF are reserved. The board responds with
    | 0x00 (success).
-----+------------------------------------------------------------------------
02  | Ping                                                              v1.0
    | Checks connectivity. The board will respond with 0x00 (success).
-----+------------------------------------------------------------------------
03  | Neighbours                                                        v1.2?
    | Asks the board to search for its immediate neighbours. The board will
    | respond with 8 bytes representing the two-byte IDs of its neighbours,
    | starting with its "top" connection and proceeding clockwise. If no
    | neighbour is found in a given position, 0x0000 is returned. If a
    | neighbour is found but it has not been given an identifier for this
    | session, it will return 0xFFFF.
    | This should allow the controller software to automatically detect the
    | layout of the floor.
-----+------------------------------------------------------------------------
0E  | Display static test pattern                                      v1.0
    | A static test pattern will be displayed, as selected by the one-byte
    | argument. A list of patterns is given below:
    |  00 - All white
    |  01 - All red
    |  02 - All green
    |  03 - All yellow
    |  04 - All blue
    |  05 - All magenta
    |  06 - All cyan
    |  07 - All 50% white
    |  08 - Checkerboard: (0,0)=red; (0,1)=cyan
    |  09 - Checkerboard: (0,0)=cyan; (0,1)=red
    |  0A - Checkerboard: (0,0)=green; (0,1)=magenta
    |  0B - Checkerboard: (0,0)=magenta; (0,1)=green
    |  0C - Checkerboard: (0,0)=blue; (0,1)=yellow
    |  0D - Checkerboard: (0,0)=yellow; (0,1)=blue
    |  0E - Checkerboard: (0,0)=white; (0,1)=black
    |  0F - Checkerboard: (0,0)=black; (0,1)=white
    |  10 - RGB fade, (0,0) = red; (3,0) = green; (0,3) = blue; (3,3) = ?
-----+------------------------------------------------------------------------
0F  | Display animated test pattern                                    v1.0
    | An animated test pattern will be displayed, as selected by the one-byte
    | argument. A list of patterns is given below:
    |  00 - clockwise spiral chase (white), starting at (0,0)
    |  01 - clockwise spiral (white), starting at (0,0); then black spiral
    |      once complete
==============================================================================
                          SIMPLE DISPLAY COMMANDS
-----+------------------------------------------------------------------------
10  | Clear floor                                                      v1.0
-----+------------------------------------------------------------------------
11  | Write floor                                                      v1.0
-----+------------------------------------------------------------------------
18  | Clear row                                                        v1.0
-----+------------------------------------------------------------------------
19  | Write row                                                        v1.0
==============================================================================
                          COMPLEX DISPLAY COMMANDS
-----+------------------------------------------------------------------------
50  | Set pixel                                                        v1.1
    | Should only be used very rarely, as it's highly data-inefficient.
    | Sends a one-byte co-ordinate followed by a color specification. The low
    | nybble of the co-ordinate is ignored.
-----+------------------------------------------------------------------------
51  | Draw line                                                        v1.1
    | Sends a one-byte co-ordinate followed by a color specification. A
    | 1-pixel line is drawn from absolute co-ordinates (x,y) to absolute
    | co-ordinates (w,h) using ???'s algorithm.
-----+------------------------------------------------------------------------
52  | Draw hollow rectangle                                            v1.1
    | Sends a one-byte co-ordinate followed by a color specification. A
    | hollow rectangle will be drawn of width w and height h, with top-left
    | at (x, y).
-----+------------------------------------------------------------------------
53  | Draw filled rectangle                                            v1.1
    | Sends a one-byte co-ordinate followed by a color specification. A
    | filled rectangle will be drawn of width w and height h, with top-left
    | at (x, y).
-----+------------------------------------------------------------------------
54  | Scroll floor                                                      v1.1
    | Sends a one-byte co-ordinate. Scrolls the entire image by (x, y)
    | pixels. If w or h is non-zero then the scroll direction is reversed.
-----+------------------------------------------------------------------------
55  | Scroll rectangle                                                  v1.1
    | Sends two co-ordinate bytes. The first defines the rectangle to scroll,
    | the second is a scroll spec (as above).
-----+------------------------------------------------------------------------
5E  | Draw single-colour pattern                                        v1.1
    | Sends two bytes followed by a colour spec. The first two bytes define
    | the pattern to be drawn on the module as a whole, with set bits
    | indicating that the given pixel should be set to the given colour.
-----+------------------------------------------------------------------------
5F  | Draw pattern rect                                                v1.1
    | Sends a co-ordinate byte to define the rectangle, followed by a list of
    | colour specs to be used when filling that rectangle. The specs are
    | given in order of increasing X then increasing Y (e.g. (0,0), (1,0),
    | (0,1), (1,0))
Co-ordinates
------------
Co-ordinates are specified as four two-bit values packed into a single byte:
xxyywwhh
Scroll spec
-----------
A scroll spec is specified as two two-bit values plus two one-bit values
packed into a single byte: xxyy0w0h. The scroll amount in the X and Y axes is
set by xx and yy, and if w/h are one the direction is reversed.
Colour specification
--------------------
The board will report how many colours it supports at reset time. One colour
will be referred to here as "R", three as "RGB" and four as "RGBU". The board
also sends the number of bits that it can use for setting each colour
brightness (n). Combining these parameters gives us a colour specification.
The colour spec consists of n bits of R, followed by n bits of G, B and U (as
appropriate). If the number of bits is not a multiple of 8, it will be
right-padded with zeroes.
-->