Boblightd supports 4 types of devices: momo, sound, popen and LTBL.
Momo
A momo device uses a serial port, the protocol is very basic, first an optional prefix is sent, then one byte per channel. The
original momo device has a baudrate of 9600, uses no prefix and has 9 channels which are sent in this order:
red left - red top - red right - green left - green top - green right - blue left - blue top - blue right
This means that whenever an extra byte is sent or a byte is lost, the controller loses synchronization and has no way of getting back in sync.
My controller uses a prefix of 0xFF and has 12 channels, because it's connected to usb, a baudrate setting has no meaning.
Sound
A sound device uses a soundcard to generate a pwm signal, because it uses alsa, it currently only works on linux. If you want to make some hardware for it, check out
PWM drive led strips with a soundcard
Popen
A popen device is not really a device, boblightd uses
popen to open an executable and writes one float per channel in ASCII to it's stdin. The value of the float is between 0.0 and 1.0, you can use this to easily implement a custom protocol.
For example, if you have a popen device with 3 channels, boblightd will write lines like this:
0.498039 0.498039 0.435540
This can easily be read with scanf:
int main()
{
float input[3];
while(1)
{
scanf("%f %f %f", input, input + 1, input + 2);
/*write to output device here*/
}
}
LTBL
LTBL stands for Let There Be Light, which is a protocol designed for lighting applications, currently it's only supported on the serial port.
The LTBL protocol uses a two byte prefix of 0x55 0xAA, then one byte which sets the startchannel if it's from 0 to 126, or a command if it's 127 or above.
The next byte sets the number of channels sent, or the number of bytes in case of a command.
Then the data is sent, for channel data it uses two bytes per channel so you can use up to 16 bit pwm. It sends the most significant byte first
Commands:
0x81: Request current values. Boblightd sends the startchannel and number of channels, the LTBL device sends back the startchannel and number of channels, then two bytes per channel representing the current values.
0x82: Write current values to eeprom. Boblightd sends the startchannel and number of channels, the LTBL device wil then write those devices to it's eeprom. To protect the eeprom, the device will wait 250 ms before accepting a new command.
0x83: Open light. This opens the control over rs232, the LTBL device will no longer respond to any other input, such as buttons or a remote control.
0x84: Close light. This closes the control over rs232, the LTBL device can be controlled again with other inputs.
When boblightd starts, it has no idea which state the LTBL controller is in, so it sends 0x00 255 times to be sure the device is in the state that it's waiting for the 0x55 0xAA prefix.
In boblight 1.2 this is changed to sending 0x55 255 times, followed by 0xFF 3 times, to allow LTBL devices to measure the baudrate, I currently have this working with a dsPIC33FJ12MC201 and it's awesome!
Next, if boblightd wants to do anything with the LTBL device, it has to send an "open light" command first to allow rs232 input, if there are no clients connected to boblightd, it sends the "close light" command if the LTBL controller was opened.
Example:
Boblightd starts:
Boblightd sends 0x55 255 times, then 0xFF 3 times. The LTBL device is now in the state that it's waiting for the 0x55 0xAA prefix.
Boblightd opens the controller, it sends: 0x55 0xAA (prefix) 0x83 (open command) 0x00 (nr of bytes).
Boblightd wants to know the current values: it sends: 0x55 0xAA (prefix) 0x81 (request values) 0x02 (nr of bytes) 0x00 (startchannel) 0x03 (nr of channels, in this case 3)
The LTBL controller responds like this: 0x55 0xAA (prefix) 0x00 (startchannel) 0x03 (nr of channels) 0xFF (channel 1 msb) 0xFF (channel 1 lsb) etc.
Boblightd sets the channels at a certain value, it sends: 0x55 0xAA (prefix) 0x00 (startchannel) 0x03 (nr of channels) 0xFF (channel 1 msb) 0xFF (channel 1 lsb) etc.
If there are no clients, boblightd closes the controller again, it sends: 0x55 0xAA (prefix) 0x84 (close command) 0x00 (nr of bytes).
posted on Monday, October 27, 2008 9:14 PM