diff --git a/Arduino driver 40x4/not sure if still useful/hd44780_40X4-LCDPROC.rar b/Arduino driver 40x4/not sure if still useful/hd44780_40X4-LCDPROC.rar new file mode 100644 index 0000000..14b2ac8 Binary files /dev/null and b/Arduino driver 40x4/not sure if still useful/hd44780_40X4-LCDPROC.rar differ diff --git a/Arduino driver 40x4/not sure if still useful/hd44780_40X4-LCDPROC.txt b/Arduino driver 40x4/not sure if still useful/hd44780_40X4-LCDPROC.txt new file mode 100644 index 0000000..0e92fbb --- /dev/null +++ b/Arduino driver 40x4/not sure if still useful/hd44780_40X4-LCDPROC.txt @@ -0,0 +1,193 @@ +#include + +LiquidCrystal lcd(9, 8, 7, 6, 5, 4, 3, 2); + +int row = 0; +int line = 0; +bool controller = false; +int temp = 0; +int ignore = 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 = serial_getch(); // Fetch byte + + if (rxbyte == LCDSERIALIZER_LCDI) // If LCD instruction + { + //Serial.write("[CMD]"); + + rxbyte = serial_getch(); // Fetch byte + + if (rxbyte == 0x01) + { + Serial.println("Clear screen"); + } + else if (rxbyte == 0x0c) + { + Serial.println("Restore the display (with cursor hidden)"); + } + else if (rxbyte == 0x08) + { + Serial.println("Blank the display (without clearing)"); + } + else if (rxbyte == 0x0c) + { + Serial.println("Make cursor invisible"); + } + else if (rxbyte == 0x0f) + { + Serial.println("Turn on visible blinking-block cursor"); + } + else if (rxbyte == 0x0e) + { + Serial.println("Turn on visible underline cursor"); + } + else if (rxbyte == 0x10) + { + Serial.println("Move cursor one character left"); + } + else if (rxbyte == 0x14) + { + Serial.println("Move cursor one character right"); + } + else if (rxbyte == 0x15) + { + Serial.println("(15)Move cursor one character right"); + } + else if (rxbyte == 0x02) + { + Serial.println("Home (move cursor to top/left character position)"); + } + else if (rxbyte == 0x18) + { + Serial.println("Scroll display one character left (all lines)"); + } + else if (rxbyte == 0x1e) + { + Serial.println("Scroll display one character right (all lines)"); + } + else if (rxbyte == 0x20) + { + Serial.println("Function set (4-bit interface, 1 line, 5*7 Pixels)"); + } + else if (rxbyte == 0x28) + { + Serial.println("Function set (4-bit interface, 2 lines, 5*7 Pixels)"); + } + else if (rxbyte == 0x30) + { + Serial.println("Function set (8-bit interface, 1 line, 5*7 Pixels)"); + } + else if (rxbyte == 0x38) + { + Serial.println("Function set (8-bit interface, 2 lines, 5*7 Pixels)"); + } + else if (rxbyte & 0x80) + { + byte address = rxbyte & 0x7f; + + row = address <= 0x27 ? 0 : 1; + line = address <= 0x27 ? address : address - 64; + + Serial.print("Address received " + String(row) + "," + String(line) + " \t"); + + if (controller) + row = row + 2; + + if (row == 1 && line == 0) + controller = true; + else if (row == 3) + controller = false; + + lcd.setCursor(line, row); + + Serial.println("Set Cursor to " + String(row) + "," + String(line)); + + return; + } + else if (rxbyte & 0x40) + { + //Serial.println("Set pointer in character-generator RAM (CG RAM address)"); + Serial.println(); + + // uhh? + //ignore = 8; + + lcd.setController(0); + lcd.command(rxbyte); + lcd.setController(1); + lcd.command(rxbyte); + + // get custom char + for (int i = 0; i < 8; i++) + { + rxbyte = serial_getch(); // Fetch byte + lcd.setController(0); + lcd.write(rxbyte); + lcd.setController(1); + lcd.write(rxbyte); + } + + return; + } + else + { + // print byte. + String thisString = String(rxbyte, HEX); + Serial.println("UNKNOWN " + thisString); + } + + //if (rxbyte != 0x80 && !(rxbyte & 0x40)) + lcd.command(rxbyte); + } + else + { + // print byte. + //String thisString = String(rxbyte, HEX); + //Serial.println(thisString); + //Serial.println("position " + String(row) + " " + String(line)); + + + //if (ignore == 0) + //{ + lcd.write(rxbyte); + line++; + //} + /*else + { + lcd.setController(0); + lcd.write(rxbyte); + lcd.setController(1); + lcd.write(rxbyte); + ignore--; + }*/ + + /*if (line > 39) + { + row = row < 3 ? row + 1 : 0; + line = 0; + Serial.println("row increased by line count"); + } + lcd.setCursor(line, row);*/ + } +} diff --git a/Arduino driver 40x4/not sure if still useful/temp.txt b/Arduino driver 40x4/not sure if still useful/temp.txt new file mode 100644 index 0000000..d6dcd95 --- /dev/null +++ b/Arduino driver 40x4/not sure if still useful/temp.txt @@ -0,0 +1,172 @@ +/*#include + +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); + } +} +*/