// ======================================================================================================================================================// ====================================================================================================================================================== // ---------------built-in base functions to control the serial RGB LCD display ------------------- // ---------------find the full set of commands at https://learn.adafruit.com/usb-plus-serial-backpack/command-reference // ====================================================================================================================================================== // ====================================================================================================================================================== //------ set the baud rate for LCD screen ---------------------------------------------------------- void LCDbaudRate() { // set the baud rate for the LCD display (be sure to match your "Serial.();" statement Serial.write(0xFE); // This first command (0xFE) gets the display driver's attention for the upcoming commands Serial.write(0x39); // This tells the LCD what the command actually is so it can interpret the next set(s) of values Serial.write(0x67); //9600 /* case 0x53: setBaud(1200); break; case 0x29: setBaud(2400); break; case 0xCf: setBaud(4800); break; case 0x67: setBaud(9600); break; case 0x33: setBaud(19200); break; case 0x22: setBaud(28800); break; case 0x19: setBaud(38400); break; case 0x10: setBaud(57600); break; case 0x08: setBaud(115200); break; */ } //------ set the size of the LCD screen -------------------------------------------------------------------------------- void LCDsetSize() { // set the size of the display if it isn't 16x2 (you only have to do this once) Serial.write(0xFE); // This gets the display driver's attention for the upcoming commands Serial.write(0xD1); // This tells the LCD what the command is so it can interpret the next set(s) of values Serial.write(16); // 16 columns Serial.write(2); // 2 rows delay(10); } //------ set contrast for LCD screen ------------------------------------------------------------------------------------ void LCDcontrast(int LCDcontrast) { Serial.write(0xFE); Serial.write(0x50); Serial.write(LCDcontrast); delay(10); } //------ set brightness of LCD backlight ------------------------------------------------------------ void LCDbrightness(int LCDbrightness) { Serial.write(0xFE); Serial.write(0x99); Serial.write(LCDbrightness); // This board/LCD/NeoPixel combo doesn't have enough amps to use full brightness, so 25 is good delay(10); } //------ turn ON backlight of LCD screen --------------------------------------------------------------- void LCDbacklightON() { // turn off backlight Serial.write(0xFE); Serial.write(0x42); } //------ turn OFF backlight of LCD screen ---------------------------------------------------------------- void LCDbacklightOFF() { // turn off backlight Serial.write(0xFE); Serial.write(0x46); } //------ set the LCD's background color via passed RGB values ---------------------------------------------- void LCDbacklightColor(int LCDred, int LCDgreen, int LCDblue) { Serial.write(0xFE); // Set the LCD's background color Serial.write(0xD0); Serial.write(LCDred); Serial.write(LCDgreen); Serial.write(LCDblue); } //------ turn OFF the cursors for LCD screen ------------------------------------------------------------- void LCDcursorsOFF() { Serial.write(0xFE); Serial.write(0x4B); Serial.write(0xFE); Serial.write(0x54); } //------ turn ON the LCD's autoscroll feature -------------------------------------------------------------- void LCDautoscrollON() { Serial.write(0xFE); Serial.write(0x51); delay(10); } //------ turn OFF the LCD's autoscroll feature -------------------------------------------------------------- void LCDautoscrollOFF() { Serial.write(0xFE); Serial.write(0x52); delay(10); } //------ create a custom character for the LCD screen (LOGO) ------------------------------------------------- void LCDcreateCustomChar() { Serial.write(0xFE); Serial.write(0x4E); Serial.write((uint8_t)0); // location #0 Serial.write((uint8_t)0x00); // 8 bytes of character data Serial.write(0x0A); Serial.write(0x15); Serial.write(0x11); Serial.write(0x11); Serial.write(0x0A); Serial.write(0x04); Serial.write((uint8_t)0x00); delay(10); } //------ clear the LCD screen of any and all content -------------------------------------------------------- void LCDclear() { Serial.write(0xFE); Serial.write(0x58); delay(10); } //------ move the LCD's insertion point to home (column one, row one) ---------------------------------------- void LCDgoHome() { Serial.write(0xFE); Serial.write(0x48); delay(10); } //------ move the LCD's insertion point to position (col,row) based on passed values -------------------------- void LCDgotoPOSITION(int LCDgotoCOL, int LCDgotoROW) { Serial.write(0xFE);//Move cursor to 'home' position on LINE 2 Serial.write(0x47); Serial.write(LCDgotoCOL); Serial.write(LCDgotoROW); delay(1); } //------ set the LCD's start-up splash screen ------------------------------------------------------------------ void LCDshowSplash() { // show the splash screen Serial.print("We "); Serial.write((uint8_t)0); // to print the custom character, 'write' the location Serial.println(" Arduino!"); Serial.print(" - Adafruit"); delay(1000); } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // There are a few more commands available, mostly cursor related, //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++