Created
June 18, 2013 16:38
-
-
Save mrichardson23/5807016 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Commands for Alpha Sign Communication Protocol | |
byte NUL = 0x00; | |
byte START_HEADER = 0x01; | |
byte START_TEXT = 0x02; | |
byte END_TRANSMISSION = 0x04; | |
byte ESC = 0x1B; | |
byte FILL = 0x30; | |
byte ROTATE = 0x61; | |
byte SLOW = 0x15; | |
byte FAST = 0x19; | |
byte TIME = 0x13; | |
byte CALL_STRING = 0x10; | |
byte CALL_SIZE = 0x1A; | |
byte SIZE_LARGE = 0x33; | |
byte SIZE_SMALL = 0x31; | |
#include <Console.h> | |
String message; | |
int current_char; | |
void setup() { | |
Serial1.begin(9600); | |
writeText("This serial message is never displayed."); | |
Bridge.begin(); | |
writeText("bridge started."); | |
Console.begin(); | |
writeText("console started."); | |
delay(5000); | |
writeText("waiting for console connection."); | |
while (!Console) { | |
; // wait for Console port to connect. | |
} | |
writeText("enter your message."); | |
Console.println("Enter your message: "); | |
} | |
void loop() { | |
current_char = Console.read(); | |
if (current_char == '\n') { | |
writeText(message); | |
Console.println("Written to sign."); | |
message = ""; | |
Console.println("Enter your message: "); | |
} else if (current_char != -1) { //if the buffer is empty Cosole.read returns -1 | |
message = message + (char)current_char; | |
} | |
} | |
void writeText(String text) { | |
Serial1.write(NUL); // Start frame sync chars | |
Serial1.write(NUL); | |
Serial1.write(NUL); | |
Serial1.write(NUL); | |
Serial1.write(NUL); // end frame sync chars | |
Serial1.write(START_HEADER); // start of header | |
Serial1.write("Z00"); // all sign types, all addresses | |
Serial1.write(START_TEXT); //start of text | |
Serial1.write("AA"); // write command, text file A | |
Serial1.write(ESC); | |
Serial1.write(FILL); | |
Serial1.write(ROTATE); | |
Serial1.print(text); | |
Serial1.write(END_TRANSMISSION); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Commands for Alpha Sign Communication Protocol | |
byte NUL = 0x00; | |
byte START_HEADER = 0x01; | |
byte START_TEXT = 0x02; | |
byte END_TRANSMISSION = 0x04; | |
byte ESC = 0x1B; | |
byte FILL = 0x30; | |
byte ROTATE = 0x61; | |
byte SLOW = 0x15; | |
byte FAST = 0x19; | |
byte TIME = 0x13; | |
byte CALL_STRING = 0x10; | |
byte CALL_SIZE = 0x1A; | |
byte SIZE_LARGE = 0x33; | |
byte SIZE_SMALL = 0x31; | |
#include <Console.h> | |
String message; | |
int current_char; | |
void setup() { | |
Serial1.begin(9600); | |
writeText("Serial writing works in this simple sketch."); | |
} | |
void loop() { | |
} | |
void writeText(String text) { | |
Serial1.write(NUL); // Start frame sync chars | |
Serial1.write(NUL); | |
Serial1.write(NUL); | |
Serial1.write(NUL); | |
Serial1.write(NUL); // end frame sync chars | |
Serial1.write(START_HEADER); // start of header | |
Serial1.write("Z00"); // all sign types, all addresses | |
Serial1.write(START_TEXT); //start of text | |
Serial1.write("AA"); // write command, text file A | |
Serial1.write(ESC); | |
Serial1.write(FILL); | |
Serial1.write(ROTATE); | |
Serial1.print(text); | |
Serial1.write(END_TRANSMISSION); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment