Project:USB Disco Dance Floor/v1/firmware

From London Hackspace Wiki

< Project:USB Disco Dance Floor‎ | v1

Revision as of 19:05, 4 April 2011 by Dmi (talk | contribs) (Info about neighbours query call)

USB Disco Dance Floor v1 Firmware
Created 2011-03-31
Members DMI
Project Status Prototyping


Introduction

The firmware will be responsible for listening for serial commands, and then acting upon them. This will primarily involve changing the display.

Data types

Colour spec

The board reports the number of colours it supports at reset time. The colour(s) in a one-colour board will be referred to as R, in a three-colour board as RGB, and in a four-colour board as RGBU. This is because of the suggested LED choices of Red, Green, Blue, and Ultraviolet. The board also reports the number of bits (n) that it can use for setting the brightness of each colour LED.

A colour spec consists of n bits of R, followed by n bits of G, B, and U (as appropriate). If the total number of bits is not a multiple of 8, it will be right-padded with zeroes.

Examples:

  • 4 bpc (bits per channel) and 4 colours would lead to a bit pattern of: RRRRGGGG BBBBUUUU.
  • 4 bpc and 3 colours would have a bit pattern of: RRRRGGGG BBBB0000
  • 12bps and 3 colours would have a bit pattern of: RRRRRRRR RRRRGGGG GGGGGGGG BBBBBBBB BBBB0000
  • 3bps and 3 colours would have a bit pattern of: RRRGGGBB B0000000

Co-ordinate

A co-ordinate consists of four two-bit values packed into a single byte, with the bit pattern: xxyywwhh. Co-ordinates of (0,0) are at the top-left of the module, and increase downwards and rightwards. Note that the ww and hh bits may be ignored.

Scroll spec

A scroll spec consists of two two-bit values and two one-bit values packed into a single byte, with the bit pattern: xxyy0w0h. The number of pixels to scroll along the X and Y axes is specified by xx and yy, and the direction is negative along the X/Y axis if w or h are set, respectively.

Commands

Commands start with a one-byte identifier, followed by zero or more data bytes. The number of data bytes is command-specific. The device should not output any data unless specified below.

Command Action Min version
Status/Diagnostic Commands
00 Reset 1.0
Resets the board to an initial state, with all pixels off. The board sends four bytes representing its hardware and firmware versions (2 bytes each), followed by 2 bytes for hardware details. This command also resets the board ID to 0xFFFF (i.e. unset).

The high nybble of the first hardware info byte is the number of different colours supported (0x1, 0x3, or 0x4) and the low nybble is whether sensors are supported (0x1 for yes). The high nybble of the second byete specifies the number of bits needed to specify LED brightness. If this is different for different colours, the firmware will handle scaling. 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).

01 Identify 1.0
Informs the board of its two-byte board ID for this session. Note that board IDs 0x0000 and 0xFFFF are reserved. The board will respond with 0x00 (success).
02 Ping 1.0
Checks connectivity with the board. The board will respond with 0x00 (success) followed by its two-byte board ID.
03 Query neighbours 1.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 1.0
???
0F Display animated test pattern 1.0
???
Simple Display Commands
10 Clear floor 1.0
???
11 Write floor 1.0
???
18 Clear row 1.0
???
19 Write row 1.0
???
Complex Display Commands
50 Set pixel 1.1
???
51 Draw line 1.1
???
52 Draw hollow rectangle 1.1
???
53 Draw filled rectangle 1.1
???
54 Scroll floor 1.1
???
55 Scroll rectangle 1.1
???
5E Draw single-colour pattern 1.1
???
5F Draw pattern rect 1.1
???