2012-11-21, 14:02
For Adalight users to calculate the prefix:
Regarding the checksum, here's the relevant bit from the Processing sketch:
buffer[0] = 'A'; // Magic word
buffer[1] = 'd';
buffer[2] = 'a';
buffer[3] = byte((coord.length - 1) >> 8); // LED count high byte
buffer[4] = byte((coord.length - 1) & 0xff); // LED count low byte
buffer[5] = byte(buffer[3] ^ buffer[4] ^ 0x55); // Checksum
Calculation with examples:
Prefix for 25 LEDS: 41 64 61 00 18 4D
Prefix for 50 LEDS: 41 64 61 00 31 64
Prefix for 100 LEDS: 41 64 61 00 63 36
Prefix for 48 LEDS: 41 64 61 00 2F 7A
00 = led number 0
25 LED = 25-1=24 in hex is = 18
50 LED = 50-1=49 in hex is = 31
100 LED = 100-1=99 in hex is = 63
48 LED = 48-1=47 in hex is = 2F
(Microsoft Scientific calc in hex mode)
25 LED = 55 * Xor 18 = 4D
50 LED = 55 * Xor 31 = 64
100 LED = 55 * Xor 63 = 36
48 LED = 55 * Xor 2F = 7A
Regarding the checksum, here's the relevant bit from the Processing sketch:
buffer[0] = 'A'; // Magic word
buffer[1] = 'd';
buffer[2] = 'a';
buffer[3] = byte((coord.length - 1) >> 8); // LED count high byte
buffer[4] = byte((coord.length - 1) & 0xff); // LED count low byte
buffer[5] = byte(buffer[3] ^ buffer[4] ^ 0x55); // Checksum
Calculation with examples:
Prefix for 25 LEDS: 41 64 61 00 18 4D
Prefix for 50 LEDS: 41 64 61 00 31 64
Prefix for 100 LEDS: 41 64 61 00 63 36
Prefix for 48 LEDS: 41 64 61 00 2F 7A
00 = led number 0
25 LED = 25-1=24 in hex is = 18
50 LED = 50-1=49 in hex is = 31
100 LED = 100-1=99 in hex is = 63
48 LED = 48-1=47 in hex is = 2F
(Microsoft Scientific calc in hex mode)
25 LED = 55 * Xor 18 = 4D
50 LED = 55 * Xor 31 = 64
100 LED = 55 * Xor 63 = 36
48 LED = 55 * Xor 2F = 7A