173 lines
3.2 KiB
Plaintext
173 lines
3.2 KiB
Plaintext
/*#include <LiquidCrystal.h>
|
|
|
|
LiquidCrystal lcd(9, 8, 7, 6, 5, 4, 3, 2);
|
|
|
|
int row = 0;
|
|
int line = 0;
|
|
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
// set up the LCD's number of columns and rows:
|
|
lcd.begin(40, 4);
|
|
lcd.clear();
|
|
lcd.home();
|
|
}
|
|
|
|
#define LCDSERIALIZER_LCDI 0xFE
|
|
|
|
byte serial_getch() {
|
|
int incoming;
|
|
while (Serial.available() == 0) {
|
|
}
|
|
// read the incoming byte:
|
|
incoming = Serial.read();
|
|
//Serial.write(incoming);
|
|
|
|
return (incoming & 0xff);
|
|
}
|
|
|
|
void loop() {
|
|
byte rxbyte;
|
|
|
|
rxbyte = serial_getch(); // Fetch byte
|
|
|
|
if (rxbyte == 0x11) // If LCD instruction
|
|
{
|
|
Serial.write("[CMD]");
|
|
|
|
rxbyte = serial_getch(); // Fetch byte
|
|
|
|
if (rxbyte == 0x0C)
|
|
{
|
|
lcd.clear();
|
|
lcd.home();
|
|
Serial.println("[ff]");
|
|
line = 0;
|
|
row = 0;
|
|
lcd.setCursor(line, row);
|
|
}
|
|
else if (rxbyte == 0x01)
|
|
{
|
|
Serial.println("[clr]");
|
|
lcd.clear();
|
|
}
|
|
else if (rxbyte == 0x0D)
|
|
{
|
|
Serial.println("[cr]");
|
|
lcd.setCursor(0, row);
|
|
}
|
|
else if (rxbyte == 0x0A)
|
|
{
|
|
Serial.println("[nl]");
|
|
row = row < 3 ? row + 1 : 0;
|
|
line = 0;
|
|
lcd.setCursor(line, row);
|
|
}
|
|
else if (rxbyte == 0xc0) {
|
|
lcd.clear();
|
|
lcd.home();
|
|
Serial.println("[ff]");
|
|
row = 0;
|
|
line = 0;
|
|
lcd.setCursor(line, row);
|
|
}
|
|
else if (rxbyte == 0x12) {
|
|
Serial.println("[\n]");
|
|
row = row < 3 ? row + 1 : 0;
|
|
line = 0;
|
|
lcd.setCursor(line, row);
|
|
}
|
|
else if (rxbyte == 0x04) {
|
|
Serial.println("[ ]");
|
|
line++;
|
|
if (line > 39)
|
|
{
|
|
row = row < 3 ? row + 1 : 0;
|
|
line = 0;
|
|
}
|
|
lcd.setCursor(line, row);
|
|
}
|
|
else if (rxbyte == 0x02) {
|
|
Serial.write("[hm]");
|
|
lcd.clear();
|
|
lcd.home();
|
|
Serial.println("[ff]");
|
|
line = 0;
|
|
row = 0;
|
|
lcd.setCursor(line, row);
|
|
}
|
|
else if (rxbyte == 0x80) {
|
|
lcd.clear();
|
|
lcd.home();
|
|
Serial.println("[80 clr]");
|
|
line = 0;
|
|
row = 0;
|
|
lcd.setCursor(line, row);
|
|
}
|
|
else
|
|
{
|
|
Serial.print("[?]");
|
|
String thisString = String(rxbyte, HEX);
|
|
Serial.println(thisString);
|
|
}
|
|
}
|
|
/*else if (rxbyte == 0x12) {
|
|
Serial.println("[]");
|
|
}
|
|
else if (rxbyte == 0x15) {
|
|
Serial.println("[]");
|
|
}*/
|
|
/*else if (rxbyte == 0x20) {
|
|
Serial.println("[]");
|
|
}*/
|
|
|
|
|
|
/*else if (rxbyte == 0x15) {
|
|
Serial.println("[]");
|
|
}
|
|
else if (rxbyte == 0x00) {
|
|
Serial.println("[]");
|
|
}
|
|
else if (rxbyte == 0x1b) {
|
|
Serial.println("[]");
|
|
}
|
|
else if (rxbyte == 0x1f) {
|
|
Serial.println("[]");
|
|
}
|
|
else if (rxbyte == 0x0e) {
|
|
Serial.println("[<]");
|
|
line--;
|
|
if (line < 0)
|
|
{
|
|
row = row > 0 ? row - 1 : 3;
|
|
line = 0;
|
|
}
|
|
}
|
|
else if (rxbyte == 0x01) {
|
|
Serial.print("[pos]");
|
|
serial_getch();
|
|
serial_getch();
|
|
serial_getch();
|
|
serial_getch();
|
|
}
|
|
|
|
else if (rxbyte == 0x0a) {
|
|
row = row < 3 ? row + 1 : 0;
|
|
lcd.setCursor(line, row);
|
|
}
|
|
|
|
else {
|
|
String thisString = String(rxbyte, HEX);
|
|
Serial.println(thisString);
|
|
lcd.write(rxbyte); //Otherwise just dump it as text
|
|
line++;
|
|
if (line > 39)
|
|
{
|
|
row = row < 3 ? row + 1 : 0;
|
|
line = 0;
|
|
}
|
|
lcd.setCursor(line, row);
|
|
}
|
|
}
|
|
*/
|