Processing + BRG LED display signs
in
Share your Work
•
3 years ago
hey guys. Just wanted to post up some code I wrote to talk to BRGPrecision LED signs (
http://www.brgprecision.com/products/message_displays/singlelinemd.php ).
It was a bit of a pain since the reference material wasn't accurate, so maybe this will help someone in the future.
The code is pretty rough, but i tried to comment it so you could have a reasonable idea. if you want to change the font or color etc, it's a good idea to reference the manual (
http://www.brgprecision.com/pdffiles/Protocol12.pdf ) as that has the descriptions of each font.
- Serial myPort; // Create object from Serial class
- void clearMessages()
- {
- println("* wrote CLEAR *");
- byte n = 0x00;
- myPort.write(n); // null
- myPort.write(n);
- myPort.write(n);
- myPort.write(n);
- myPort.write(n);
- myPort.write(0x01); //start of head
- myPort.write(0xFF); // sender address
- myPort.write(n); //reciever address - broadcast
- myPort.write(0x02); //start of text
- myPort.write('W'); //special function command
- myPort.write('L'); //delete all data
- myPort.write(0x03); //end of text
- myPort.write("00A8"); //efficacy code
- myPort.write(0x04); //end of transmition
- }
- int writeAndLog(char val)
- {
- myPort.write(val);
- return val;
- }
- void writeMessage(String message, int _slot)
- {
- char slot = getSlot(_slot);
- println("* wrote message *");
- byte n = 0x00;
- int efficacy = 0;
- myPort.write(n); // null
- myPort.write(n);
- myPort.write(n);
- myPort.write(n);
- myPort.write(n);
- myPort.write(0x01); //start of head
- myPort.write('F'); // sender address
- myPort.write('F'); // sender address
- myPort.write('0'); //reciever address - broadcast
- myPort.write('0'); //reciever address - broadcast
- myPort.write(0x02); //start of text
- efficacy += 0x02;
- efficacy += writeAndLog('A'); //special function command
- efficacy += writeAndLog(slot); // file name, 0-9 A-Z
- efficacy += writeAndLog('I'); //roll left
- efficacy += writeAndLog('5'); //slower
- efficacy += writeAndLog('2'); //2 second hold
- efficacy += writeAndLog('7'); // ??
- efficacy += writeAndLog('F'); // ??
- efficacy += writeAndLog('0'); // ??
- efficacy += writeAndLog('0'); // ??
- efficacy += writeAndLog('0'); // ??
- efficacy += writeAndLog('0'); // ??
- efficacy += writeAndLog('2'); // ??
- efficacy += writeAndLog('3'); // ??
- efficacy += writeAndLog('0'); // ??
- efficacy += writeAndLog('0'); // ??
- myPort.write(0xFF); // ??
- myPort.write(0xFF); // ??
- efficacy+=0xFF;
- efficacy+=0xFF;
- efficacy += writeAndLog('1');
- efficacy += writeAndLog('1');
- myPort.write(0xFE); //font value addtl char
- efficacy+=0xFE;
- efficacy += writeAndLog('E'); //font value : SS7
- myPort.write(0xFD); // color value addtl char
- efficacy+=0xFD;
- efficacy += writeAndLog('I'); // color value : ORANGE
- //text
- for(int i=0;i<message.length();i++) // efficacy
- {efficacy += writeAndLog(message.charAt(i));}
- myPort.write(0x03); //end of text
- efficacy += 0x03;
- String efString = hex(efficacy, 4);
- for(int i=0;i<efString.length();i++) // efficacy
- {myPort.write(efString.charAt(i));}
- myPort.write(0x04);
- }
- char getSlot(int slot)
- {
- char c = 'Q';
- switch(slot)
- {
- case 0:
- c = '0';
- break;
- case 1:
- c = '1';
- break;
- case 2:
- c = '2';
- break;
- case 3:
- c = '3';
- break;
- case 4:
- c = '4';
- break;
- case 5:
- c = '5';
- break;
- case 6:
- c = '6';
- break;
- case 7:
- c = '7';
- break;
- case 8:
- c = '8';
- break;
- case 9:
- c = '9';
- break;
- case 10:
- c = 'A';
- break;
- case 11:
- c = 'B';
- break;
- case 12:
- c = 'C';
- break;
- case 13:
- c = 'D';
- break;
- case 14:
- c = 'E';
- break;
- case 15:
- c = 'F';
- break;
- case 16:
- c = 'G';
- break;
- case 17:
- c = 'H';
- break;
- case 18:
- c = 'I';
- break;
- case 19:
- c = 'J';
- break;
- case 20:
- c = 'K';
- break;
- case 21:
- c = 'L';
- break;
- case 22:
- c = 'M';
- break;
- case 23:
- c = 'N';
- break;
- case 24:
- c = 'O';
- break;
- case 25:
- c = 'P';
- break;
- case 26:
- c = 'Q';
- break;
- case 27:
- c = 'R';
- break;
- case 28:
- c = 'S';
- break;
- case 29:
- c = 'T';
- break;
- case 30:
- c = 'U';
- break;
- case 31:
- c = 'V';
- break;
- case 32:
- c = 'W';
- break;
- case 33:
- c = 'X';
- break;
- case 34:
- c = 'Y';
- break;
- case 35:
- c = 'Z';
- break;
- default:
- slot=35;
- c = getSlot();
- break;
- }
- return c;
- }
and if you want to send multiple messages, you'll want this code in draw to check for when its okay to send a new message (after 0x01 is received).
- int val;
- if ( myPort.available() > 0) { // If data is available,
- val = myPort.read(); // read it and store it in val
- if((byte)val == 0x04)
- {
- println("* command recieved *");
- }
- else if((byte)val == 0x01)
- {
- println("* sign ready for next command *");
- }