Version: Dave Woodfield 25/10/17
Data transfer to/from the Magic Chessboard (MB) will be at 38400 baud, odd parity, 7 bit, 1 stop. All data is printable ASCII. All data strings are terminated in a block-parity check character. Commands will only be actioned and acknowledged by the MB if the format and X-Y parity check is correct. The odd X parity will be performed by the USB serial driver. The Y parity is generated by taking the binary XOR of all of the transmitted ASCII characters including the command character and all of the data characters upto the check-byte. This value is then transmitted as a further 2 hex characters.
This command retrieves the piece status of the complete board.
S Command character
<Chk> Block parity check byte - 2 hex digits
Reply:-
s Lower-case acknowledge character
<Pcode><Pcode>..........<Pcode> 64 * Piece codes. Data order is A8...H8,A7...H7 etc.
<Chk> Block parity check byte - 2 hex digits
<Pcodes>
are K,Q,R,N,B,P for white pieces and k,q,r,n,b,p for black. An empty square returns '.'
.
The LED command sets the flash pattern of all 81 LEDs on the board.
L Command character
XX Slot time – 2 hex digits
<Lcode><Lcode>..........<Lcode> 81 * LED codes, LED 1 to LED 81
<Chk> Block parity check byte - 2 hex digits
Reply:-
l Lower-case acknowledge character
<Chk> Block parity check byte - 2 hex digits
<Lcode>
parameters consist of 2 upper-case hex characters representing an LED pattern byte. The LEDs follow the bit pattern from b7 to b0, changing every LED time slot, e.g. = C4 will give an ON, ON, OFF, OFF, OFF, ON, OFF, OFF flash pattern repeating every 8 time slots. The slot time is set in units of 4.096mS.
LED 1 is in the A8 corner, LED 9 is in the A1 corner
LED 73 is in the H8 corner, LED 81 is in the H1 corner
X Command character
<Chk> Block parity check byte - 2 hex digits
Reply:-
x Lower-case acknowledge character
<Chk> Block parity check byte - 2 hex digits
This command will cause a hardware reset of the MB. There will be a start-up delay of 3 seconds and the MB will then start scanning again. Note that status and LED arrays will be cleared.
T Command character
<Chk> Block parity check byte - 2 hex digits
There will be no reply as a hardware reset is performed immediately upon correct receipt of this command.
V Command character
<Chk> Block parity check byte - 2 hex digits
Reply:-
v Lower-case acknowledge character
XX Firmware version number high – 2 hex digits
XX Firmware version number low – 2 hex digits
<Chk> Block parity check byte - 2 hex digits
This command is used to write the E2 memory in the MB where operating parameters are stored. All values are transferred as upper-case hex characters. E2 locations above 0x10 may be used for other non-volatile data if required by the host.
W Command character
XX Address – 2 hex digits
XX Data byte – 2 hex digits
<Chk> Block parity check byte - 2 hex digits
Reply:-
w Lower-case acknowledge character
XX Address – 2 hex digits
XX Data byte – 2 hex digits
<Chk> Block parity check byte - 2 hex digits
This command is used to read the E2 memory in the MB where operating parameters are stored. All values are transferred as upper-case hex characters.
R Command character
XX Address – 2 hex digits
<Chk> Block parity check byte - 2 hex digits
Reply:-
r Lower-case acknowledge character
XX Address – 2 hex digits
XX Data byte – 2 hex digits
<Chk> Block parity check byte - 2 hex digits
The block parity should normally be enabled, but can be disabled to enable easier testing with a terminal emulator.
b0 = Block parity disable
0 Enabled (default)
1 Disabled
b7-b1 Unused
This is the time in units of 2.048mS to do a complete scan of the board. It defaults to 20 giving a scan time of 40.96mS, or 24.4 scans per second. This is a safe value which will work reliably in all conditions with all playing pieces, however if all of the pieces in a set give their nominal or faster response this value can be reduced by trial and error to a theoretical minimum of 15, giving a scan rate in excess of 32 scans per second.
The scan time can be increased if desired to reduce the number of status messages that may be sent as a piece is swept across the board, but this can increase the delay before a position change may be seen. For speed chess the scan time should be short to get an almost immediate response and any move debounce done in the host software.
The minimum allowed value is 15, anything less than this will set 20. The maximum value is 255 which will give 1.9 scans per second.
If enabled automatic reports may by inserted between any command and it's acknowledgement. It is therefore important that all acknowledge messages have their type checked to match then up with the command that instigated them. The format is the same as a reply to the board status command.
b2-b0 = Automatic status reports
000 Send status on every scan (default)
001 Disabled. Use 'S' command
010 Send status with time set at address 03
011 Send status on any change
100 Send status on any change with 2 scan debounce
101 Send status on any change with 3 scan debounce
110 Send status on any change with 4 scan debounce
111 Send status on any change with 5 scan debounce
b7-b3 Unused
This is the time between automatic status reports if enabled, in units of 4.096mS.
0 = Dim, >14 = Full brightness