// Graphic Serial LCD 128x64
// Arduino Pin 8 (RX) to LCD Pin TX (NOT USED, NOT NECESSARY)
// Arduino Pin 9 (TX) to LCD Pin RX
// Arduino Pin Vin to LCD Vin (Assuming you're powering Arduino externally with 9 VDC)
// Arduino Pin Gnd to LCD Pin Gnd
void setup() {
Serial1.begin(115200);
clearScreen();
// Set a dim display
setBackgroundBrightness(1);
// Note how by default it prints at upper left
print("hello");
// Note that 0,0 is at lower left side of display
setX(5);
setY(10);
print("world");
// Draw a big X
drawLine(0, 0, 127, 63, 1);
drawLine(127, 0, 0, 63, 1);
// Draw a centered circle
drawCircle(63, 31, 31, 1);
// Draw a box in the center
drawBox(31, 15, 95, 47, 1);
}
void loop()
{
}
void print(char *data){
Serial1.print(data);
}
void clearScreen(){
Serial1.write(byte(0x7C));
Serial1.write(byte(0x00));
}
void demo(){
Serial1.write(byte(0x7C));
Serial1.write(byte(0x04));
}
void toggleSplashScreen(){
Serial1.write(byte(0x7C));
Serial1.write(byte(0x13));
}
void setBackgroundBrightness(byte value){
Serial1.write(byte(0x7C));
Serial1.write(byte(0x02));
Serial1.write(byte(value));
}
void setBaudRate(long value){
// Get the internal reference for this baud rate
char *ref = " ";
if(value == 4800)
ref = "1";
else if(value == 9600)
ref = "2";
else if(value == 19200)
ref = "3";
else if(value == 38400)
ref = "4";
else if(value == 57600)
ref = "5";
else if(value == 115200)
ref = "6";
else
return;
// Since it often rolls back to 115200, try setting it via 115200 first
Serial1.begin(115200);
Serial1.write(byte(0x7C));
Serial1.write(byte(0x07));
Serial1.print(ref);
// Now change the serial port to the desired rate, and set it again.
Serial1.begin(value);
Serial1.write(byte(0x7C));
Serial1.write(byte(0x07));
Serial1.print(ref);
}
void setX(byte value){
Serial1.write(byte(0x7C));
Serial1.write(byte(0x18C));
Serial1.write(byte(value));
}
void setY(byte value){
Serial1.write(byte(0x7C));
Serial1.write(byte(0x19));
Serial1.write(byte(value));
}
void setPixel(byte state){
Serial1.write(byte(0x50));
Serial1.write(byte(0x40));
Serial1.write(byte(state));
}
void drawLine(byte startX, byte startY, byte endX, byte endY, byte state){
Serial1.write(byte(0x7C));
Serial1.write(byte(0x0C));
Serial1.write(byte(startX));
Serial1.write(byte(startY));
Serial1.write(byte(endX));
Serial1.write(byte(endY));
Serial1.write(byte(state));
}
void drawCircle(byte startX, byte startY, byte radius, byte state){
Serial1.write(byte(0x7C));
Serial1.write(byte(0x03));
Serial1.write(byte(startX));
Serial1.write(byte(startY));
Serial1.write(byte(radius));
Serial1.write(byte(state));
}
void drawBox(byte topLeftX, byte topLeftY, byte bottomRightX, byte bottomRightY, byte state){
Serial1.write(byte(0x7C));
Serial1.write(byte(0x0F));
Serial1.write(byte(topLeftX));
Serial1.write(byte(topLeftY));
Serial1.write(byte(bottomRightX));
Serial1.write(byte(bottomRightY));
Serial1.write(byte(state));
}
void eraseBox(byte topLeftX, byte topLeftY, byte bottomRightX, byte bottomRightY, byte state){
Serial1.write(byte(0x7C));
Serial1.write(byte(0x05));
Serial1.write(byte(topLeftX));
Serial1.write(byte(topLeftY));
Serial1.write(byte(bottomRightX));
Serial1.write(byte(bottomRightY));
Serial1.write(byte(state));
}
bogdan,
Raspundese poate cumpara de la dumneavoastra si shieldul respectiv ,fara ecran?
A fost util acest review?