LCD demo

From Public Wiki
Revision as of 20:23, 2 November 2020 by Falgsc-al (talk | contribs) (This page is a modified demo that came with the new LCD board.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

/***********************************************************************************

  • This program is a demo of displaying string
  • This demo was made for LCD modules with 8bit or 16bit data port.
  • This program requires the the LCDKIWI library.
  • File : display_string.ino
  • Hardware Environment: Arduino UNO&Mega2560
  • Build Environment : Arduino
  • Set the pins to the correct ones for your development shield or breakout board.
  • This demo use the BREAKOUT BOARD only and use these 8bit data lines to the LCD,
  • pin usage as follow:
  • LCD_CS LCD_CD LCD_WR LCD_RD LCD_RST SD_SS SD_DI SD_DO SD_SCK
  • Arduino Uno A3 A2 A1 A0 A4 10 11 12 13
  • Arduino Mega2560 A3 A2 A1 A0 A4 10 11 12 13
  • LCD_D0 LCD_D1 LCD_D2 LCD_D3 LCD_D4 LCD_D5 LCD_D6 LCD_D7
  • Arduino Uno 8 9 2 3 4 5 6 7
  • Arduino Mega2560 8 9 2 3 4 5 6 7
  • Remember to set the pins to suit your display module!
  • @attention
  • THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  • WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  • TIME. AS A RESULT, QD electronic SHALL NOT BE HELD LIABLE FOR ANY
  • DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  • FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  • CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
                                                                                                                                                                    • /
  1. include <LCDWIKI_GUI.h> //Core graphics library
  2. include <LCDWIKI_KBV.h> //Hardware-specific library

//if the IC model is known or the modules is unreadable,you can use this constructed function LCDWIKI_KBV mylcd(ILI9486,A3,A2,A1,A0,A4); //model,cs,cd,wr,rd,reset //if the IC model is not known and the modules is readable,you can use this constructed function //LCDWIKI_KBV mylcd(320,480,A3,A2,A1,A0,A4);//width,height,cs,cd,wr,rd,reset

//define some colour values

  1. define BLACK 0x0000
  2. define BLUE 0x001F
  3. define RED 0xF800
  4. define GREEN 0x07E0
  5. define CYAN 0x07FF
  6. define MAGENTA 0xF81F
  7. define YELLOW 0xFFE0
  8. define WHITE 0xFFFF

void setup() {

 Serial.begin(9600);
 mylcd.Init_LCD();
 Serial.println(mylcd.Read_ID(), HEX);
 mylcd.Fill_Screen(BLACK);

}

void loop() {

 mylcd.Set_Text_Mode(0);
 //display 1 times string
 mylcd.Fill_Screen(0x0000);
 mylcd.Set_Text_colour(RED);
 mylcd.Set_Text_Back_colour(BLACK);
 mylcd.Set_Text_Size(3);
 mylcd.Print_String("Battery Monitor", 0, 0);
 //mylcd.Print_Number_Float(01234.56789, 2, 0, 8, '.', 0, ' ');  
 //mylcd.Print_Number_Int(0xDEADBEF, 0, 16, 0, ' ',16);
 //mylcd.Print_String("DEADBEF", 0, 16);
 //display 2 times string
 mylcd.Set_Text_colour(GREEN);
 mylcd.Set_Text_Size(2);
 mylcd.Print_String("Made by Caleb\nand Tim", 0, 40);
 //mylcd.Print_Number_Float(01234.56789, 2, 0, 56, '.', 0, ' ');  
 //mylcd.Print_Number_Int(0xDEADBEF, 0, 72, 0, ' ',16);
 //mylcd.Print_String("DEADBEEF", 0, 72);
 //display 3 times string
 mylcd.Set_Text_colour(BLUE);
 mylcd.Set_Text_Size(2);
 mylcd.Print_String("Battery 1", 0, 100);
 //mylcd.Print_Number_Float(01234.56789, 2, 0, 128, '.', 0, ' ');  
 //mylcd.Print_Number_Int(0xDEADBEF, 0, 152, 0, ' ',16);
// mylcd.Print_String("DEADBEEF", 0, 152);
 //display 4 times string
 mylcd.Set_Text_colour(WHITE);
 mylcd.Set_Text_Size(2);
 mylcd.Print_String("Battery 2", 0, 140);
 //display 5 times string
 mylcd.Set_Text_colour(YELLOW);
 mylcd.Set_Text_Size(2);
 mylcd.Print_String("Battery 3", 0, 180);
 //display 6 times string
 mylcd.Set_Text_colour(RED);
 mylcd.Set_Text_Size(2);
 mylcd.Print_String("Battery 4", 0, 220);
 delay(3000);