Difference between revisions of "LCD demo"
Jump to navigation
Jump to search
(This page is a modified demo that came with the new LCD board.) |
m |
||
Line 1: | Line 1: | ||
+ | <syntaxhighlight lang="C++" line='line'> | ||
/*********************************************************************************** | /*********************************************************************************** | ||
*This program is a demo of displaying string | *This program is a demo of displaying string | ||
Line 102: | Line 103: | ||
delay(3000); | delay(3000); | ||
+ | </syntaxhighlight> |
Revision as of 20:26, 2 November 2020
1 /***********************************************************************************
2 *This program is a demo of displaying string
3 *This demo was made for LCD modules with 8bit or 16bit data port.
4 *This program requires the the LCDKIWI library.
5
6 * File : display_string.ino
7 * Hardware Environment: Arduino UNO&Mega2560
8 * Build Environment : Arduino
9
10 *Set the pins to the correct ones for your development shield or breakout board.
11 *This demo use the BREAKOUT BOARD only and use these 8bit data lines to the LCD,
12 *pin usage as follow:
13 * LCD_CS LCD_CD LCD_WR LCD_RD LCD_RST SD_SS SD_DI SD_DO SD_SCK
14 * Arduino Uno A3 A2 A1 A0 A4 10 11 12 13
15 *Arduino Mega2560 A3 A2 A1 A0 A4 10 11 12 13
16
17 * LCD_D0 LCD_D1 LCD_D2 LCD_D3 LCD_D4 LCD_D5 LCD_D6 LCD_D7
18 * Arduino Uno 8 9 2 3 4 5 6 7
19 *Arduino Mega2560 8 9 2 3 4 5 6 7
20
21 *Remember to set the pins to suit your display module!
22 *
23 * @attention
24 *
25 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
26 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
27 * TIME. AS A RESULT, QD electronic SHALL NOT BE HELD LIABLE FOR ANY
28 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
29 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
30 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
31 **********************************************************************************/
32
33 #include <LCDWIKI_GUI.h> //Core graphics library
34 #include <LCDWIKI_KBV.h> //Hardware-specific library
35
36 //if the IC model is known or the modules is unreadable,you can use this constructed function
37 LCDWIKI_KBV mylcd(ILI9486,A3,A2,A1,A0,A4); //model,cs,cd,wr,rd,reset
38 //if the IC model is not known and the modules is readable,you can use this constructed function
39 //LCDWIKI_KBV mylcd(320,480,A3,A2,A1,A0,A4);//width,height,cs,cd,wr,rd,reset
40
41 //define some colour values
42 #define BLACK 0x0000
43 #define BLUE 0x001F
44 #define RED 0xF800
45 #define GREEN 0x07E0
46 #define CYAN 0x07FF
47 #define MAGENTA 0xF81F
48 #define YELLOW 0xFFE0
49 #define WHITE 0xFFFF
50
51 void setup()
52 {
53 Serial.begin(9600);
54 mylcd.Init_LCD();
55 Serial.println(mylcd.Read_ID(), HEX);
56 mylcd.Fill_Screen(BLACK);
57 }
58
59 void loop()
60 {
61 mylcd.Set_Text_Mode(0);
62 //display 1 times string
63 mylcd.Fill_Screen(0x0000);
64 mylcd.Set_Text_colour(RED);
65 mylcd.Set_Text_Back_colour(BLACK);
66 mylcd.Set_Text_Size(3);
67 mylcd.Print_String("Battery Monitor", 0, 0);
68 //mylcd.Print_Number_Float(01234.56789, 2, 0, 8, '.', 0, ' ');
69 //mylcd.Print_Number_Int(0xDEADBEF, 0, 16, 0, ' ',16);
70 //mylcd.Print_String("DEADBEF", 0, 16);
71
72 //display 2 times string
73 mylcd.Set_Text_colour(GREEN);
74 mylcd.Set_Text_Size(2);
75 mylcd.Print_String("Made by Caleb\nand Tim", 0, 40);
76 //mylcd.Print_Number_Float(01234.56789, 2, 0, 56, '.', 0, ' ');
77 //mylcd.Print_Number_Int(0xDEADBEF, 0, 72, 0, ' ',16);
78 //mylcd.Print_String("DEADBEEF", 0, 72);
79
80 //display 3 times string
81 mylcd.Set_Text_colour(BLUE);
82 mylcd.Set_Text_Size(2);
83 mylcd.Print_String("Battery 1", 0, 100);
84 //mylcd.Print_Number_Float(01234.56789, 2, 0, 128, '.', 0, ' ');
85 //mylcd.Print_Number_Int(0xDEADBEF, 0, 152, 0, ' ',16);
86 // mylcd.Print_String("DEADBEEF", 0, 152);
87
88 //display 4 times string
89 mylcd.Set_Text_colour(WHITE);
90 mylcd.Set_Text_Size(2);
91 mylcd.Print_String("Battery 2", 0, 140);
92
93 //display 5 times string
94 mylcd.Set_Text_colour(YELLOW);
95 mylcd.Set_Text_Size(2);
96 mylcd.Print_String("Battery 3", 0, 180);
97
98 //display 6 times string
99 mylcd.Set_Text_colour(RED);
100 mylcd.Set_Text_Size(2);
101 mylcd.Print_String("Battery 4", 0, 220);
102
103 delay(3000);