Class library for a serial lcd implemented on a DISCO-F469NI Development board running specific firmware for this purpose.

Dependencies:   BufferedSerial

Committer:
grantphillips
Date:
Sun Feb 18 19:56:53 2018 +0000
Revision:
3:33ee80658224
Parent:
2:b4877019c16a
Child:
4:df0201a66e39
v1.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
grantphillips 0:3f62b3c0ec9a 1 /* DISCOF469SerialLCD Library v1.0
grantphillips 0:3f62b3c0ec9a 2 * Copyright (c) 2018 Grant Phillips
grantphillips 0:3f62b3c0ec9a 3 * grant.phillips@mandela.ac.za
grantphillips 0:3f62b3c0ec9a 4 *
grantphillips 0:3f62b3c0ec9a 5 *
grantphillips 0:3f62b3c0ec9a 6 * Permission is hereby granted, free of charge, to any person obtaining a copy
grantphillips 0:3f62b3c0ec9a 7 * of this software and associated documentation files (the "Software"), to deal
grantphillips 0:3f62b3c0ec9a 8 * in the Software without restriction, including without limitation the rights
grantphillips 0:3f62b3c0ec9a 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
grantphillips 0:3f62b3c0ec9a 10 * copies of the Software, and to permit persons to whom the Software is
grantphillips 0:3f62b3c0ec9a 11 * furnished to do so, subject to the following conditions:
grantphillips 0:3f62b3c0ec9a 12 *
grantphillips 0:3f62b3c0ec9a 13 * The above copyright notice and this permission notice shall be included in
grantphillips 0:3f62b3c0ec9a 14 * all copies or substantial portions of the Software.
grantphillips 0:3f62b3c0ec9a 15 *
grantphillips 0:3f62b3c0ec9a 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
grantphillips 0:3f62b3c0ec9a 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
grantphillips 0:3f62b3c0ec9a 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
grantphillips 0:3f62b3c0ec9a 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
grantphillips 0:3f62b3c0ec9a 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
grantphillips 0:3f62b3c0ec9a 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
grantphillips 0:3f62b3c0ec9a 22 * THE SOFTWARE.
grantphillips 0:3f62b3c0ec9a 23 */
grantphillips 0:3f62b3c0ec9a 24
grantphillips 0:3f62b3c0ec9a 25 #ifndef DISCOF469SerialLCD_H
grantphillips 0:3f62b3c0ec9a 26 #define DISCOF469SerialLCD_H
grantphillips 0:3f62b3c0ec9a 27
grantphillips 0:3f62b3c0ec9a 28 #include "mbed.h"
grantphillips 0:3f62b3c0ec9a 29 #include "BufferedSerial.h"
grantphillips 0:3f62b3c0ec9a 30
grantphillips 0:3f62b3c0ec9a 31 #define LCD_WHITE 0xffffffff
grantphillips 0:3f62b3c0ec9a 32 #define LCD_SILVER 0xffC0C0C0
grantphillips 0:3f62b3c0ec9a 33 #define LCD_GRAY 0xff808080
grantphillips 0:3f62b3c0ec9a 34 #define LCD_BLACK 0xff000000
grantphillips 0:3f62b3c0ec9a 35 #define LCD_RED 0xffff0000
grantphillips 0:3f62b3c0ec9a 36 #define LCD_MAROON 0xff800000
grantphillips 0:3f62b3c0ec9a 37 #define LCD_YELLOW 0xffffff00
grantphillips 0:3f62b3c0ec9a 38 #define LCD_OLIVE 0xff808000
grantphillips 0:3f62b3c0ec9a 39 #define LCD_LIME 0xff00ff00
grantphillips 0:3f62b3c0ec9a 40 #define LCD_GREEN 0xff008000
grantphillips 0:3f62b3c0ec9a 41 #define LCD_AQUA 0xff00ffff
grantphillips 0:3f62b3c0ec9a 42 #define LCD_TEAL 0xff008080
grantphillips 0:3f62b3c0ec9a 43 #define LCD_BLUE 0xff0000ff
grantphillips 0:3f62b3c0ec9a 44 #define LCD_NAVY 0xff000080
grantphillips 0:3f62b3c0ec9a 45 #define LCD_FUCHSIA 0xffff00ff
grantphillips 0:3f62b3c0ec9a 46 #define LCD_PURPLE 0xff800080
grantphillips 0:3f62b3c0ec9a 47
grantphillips 0:3f62b3c0ec9a 48 /** Class library for a serial lcd implemented on a DISCO-F469NI Development board running
grantphillips 0:3f62b3c0ec9a 49 * specific firmware for this purpose.
grantphillips 0:3f62b3c0ec9a 50 *
grantphillips 0:3f62b3c0ec9a 51 * Example:
grantphillips 0:3f62b3c0ec9a 52 * @code
grantphillips 0:3f62b3c0ec9a 53 * #include "mbed.h"
grantphillips 0:3f62b3c0ec9a 54 * #include "DISCOF469SerialLCD.h"
grantphillips 0:3f62b3c0ec9a 55 *
grantphillips 0:3f62b3c0ec9a 56 * DISCOF469SerialLCD lcd(PA_0, PA_1); //tx, rx
grantphillips 0:3f62b3c0ec9a 57 *
grantphillips 0:3f62b3c0ec9a 58 * void DisplayPattern(void);
grantphillips 0:3f62b3c0ec9a 59 *
grantphillips 0:3f62b3c0ec9a 60 * int main() {
grantphillips 0:3f62b3c0ec9a 61 * char buf[40];
grantphillips 0:3f62b3c0ec9a 62 * int numtouches;
grantphillips 0:3f62b3c0ec9a 63 * bool cleared = false;
grantphillips 0:3f62b3c0ec9a 64 * uint16_t x1, y1, x2, y2;
grantphillips 0:3f62b3c0ec9a 65 *
grantphillips 0:3f62b3c0ec9a 66 * DisplayPattern();
grantphillips 0:3f62b3c0ec9a 67 * lcd.LED1(1);
grantphillips 0:3f62b3c0ec9a 68 * wait(1.0);
grantphillips 0:3f62b3c0ec9a 69 * lcd.LED2(1);
grantphillips 0:3f62b3c0ec9a 70 * wait(1.0);
grantphillips 0:3f62b3c0ec9a 71 * lcd.LED3(1);
grantphillips 0:3f62b3c0ec9a 72 * wait(1.0);
grantphillips 0:3f62b3c0ec9a 73 * lcd.LED4(1);
grantphillips 0:3f62b3c0ec9a 74 * wait(1.0);
grantphillips 0:3f62b3c0ec9a 75 * lcd.Clear(LCD_WHITE);
grantphillips 0:3f62b3c0ec9a 76 * lcd.LED1(0);
grantphillips 0:3f62b3c0ec9a 77 * lcd.LED2(0);
grantphillips 0:3f62b3c0ec9a 78 * lcd.LED3(0);
grantphillips 0:3f62b3c0ec9a 79 * lcd.LED4(0);
grantphillips 0:3f62b3c0ec9a 80 *
grantphillips 0:3f62b3c0ec9a 81 * while(1)
grantphillips 0:3f62b3c0ec9a 82 * {
grantphillips 0:3f62b3c0ec9a 83 * numtouches = lcd.Touches(); //read if the screen is touched
grantphillips 0:3f62b3c0ec9a 84 * if(numtouches > 0) //has the screen been touched?
grantphillips 0:3f62b3c0ec9a 85 * {
grantphillips 0:3f62b3c0ec9a 86 * cleared = false; //reset clear flag
grantphillips 0:3f62b3c0ec9a 87 * if(numtouches == 1) //if one finger is on the screen
grantphillips 0:3f62b3c0ec9a 88 * {
grantphillips 0:3f62b3c0ec9a 89 * lcd.GetTouch1(&x1, &y1);
grantphillips 0:3f62b3c0ec9a 90 * sprintf(buf, "Touch 1: x=%3u y=%3u", x1, y1);
grantphillips 0:3f62b3c0ec9a 91 * lcd.DrawStringAtLine(0,4,LCD_BLUE, LCD_WHITE, 0, buf);
grantphillips 0:3f62b3c0ec9a 92 * lcd.FillCircle(x1, y1, 50, LCD_RED);
grantphillips 0:3f62b3c0ec9a 93 * }
grantphillips 0:3f62b3c0ec9a 94 * else if(numtouches == 2) //if two fingers are on the screen
grantphillips 0:3f62b3c0ec9a 95 * {
grantphillips 0:3f62b3c0ec9a 96 * lcd.GetTouch1(&x1, &y1);
grantphillips 0:3f62b3c0ec9a 97 * lcd.GetTouch2(&x2, &y2);
grantphillips 0:3f62b3c0ec9a 98 * sprintf(buf, "Touch 1: x=%3u y=%3u", x1, y1);
grantphillips 0:3f62b3c0ec9a 99 * lcd.DrawStringAtLine(0,4,LCD_BLUE, LCD_WHITE, 0, buf);
grantphillips 0:3f62b3c0ec9a 100 * sprintf(buf, "Touch 2: x=%3u y=%3u", x2, y2);
grantphillips 0:3f62b3c0ec9a 101 * lcd.DrawStringAtLine(1,4,LCD_BLUE, LCD_WHITE, 0, buf);
grantphillips 0:3f62b3c0ec9a 102 * lcd.FillCircle(x1, y1, 50, LCD_RED);
grantphillips 0:3f62b3c0ec9a 103 * lcd.FillCircle(x2, y2, 50, LCD_BLUE);
grantphillips 0:3f62b3c0ec9a 104 * }
grantphillips 0:3f62b3c0ec9a 105 * }
grantphillips 0:3f62b3c0ec9a 106 * else
grantphillips 0:3f62b3c0ec9a 107 * {
grantphillips 0:3f62b3c0ec9a 108 * if(!cleared) //if the screen hasn't been cleared
grantphillips 0:3f62b3c0ec9a 109 * {
grantphillips 0:3f62b3c0ec9a 110 * lcd.Clear(LCD_WHITE); //clear the screen after fingers left screen
grantphillips 0:3f62b3c0ec9a 111 * cleared = true;
grantphillips 0:3f62b3c0ec9a 112 * }
grantphillips 0:3f62b3c0ec9a 113 * }
grantphillips 0:3f62b3c0ec9a 114 * }
grantphillips 0:3f62b3c0ec9a 115 * }
grantphillips 0:3f62b3c0ec9a 116 *
grantphillips 0:3f62b3c0ec9a 117 * void DisplayPattern(void)
grantphillips 0:3f62b3c0ec9a 118 * {
grantphillips 0:3f62b3c0ec9a 119 * lcd.FillRectangle(0, 0, 50, 479,LCD_WHITE);
grantphillips 0:3f62b3c0ec9a 120 * lcd.FillRectangle(50, 0, 50, 479,LCD_SILVER);
grantphillips 0:3f62b3c0ec9a 121 * lcd.FillRectangle(100, 0, 50, 479,LCD_GRAY);
grantphillips 0:3f62b3c0ec9a 122 * lcd.FillRectangle(150, 0, 50, 479,LCD_BLACK);
grantphillips 0:3f62b3c0ec9a 123 * lcd.FillRectangle(200, 0, 50, 479,LCD_RED);
grantphillips 0:3f62b3c0ec9a 124 * lcd.FillRectangle(250, 0, 50, 479,LCD_MAROON);
grantphillips 0:3f62b3c0ec9a 125 * lcd.FillRectangle(300, 0, 50, 479,LCD_YELLOW);
grantphillips 0:3f62b3c0ec9a 126 * lcd.FillRectangle(350, 0, 50, 479,LCD_OLIVE);
grantphillips 0:3f62b3c0ec9a 127 * lcd.FillRectangle(400, 0, 50, 479,LCD_LIME);
grantphillips 0:3f62b3c0ec9a 128 * lcd.FillRectangle(450, 0, 50, 479,LCD_GREEN);
grantphillips 0:3f62b3c0ec9a 129 * lcd.FillRectangle(500, 0, 50, 479,LCD_AQUA);
grantphillips 0:3f62b3c0ec9a 130 * lcd.FillRectangle(550, 0, 50, 479,LCD_TEAL);
grantphillips 0:3f62b3c0ec9a 131 * lcd.FillRectangle(600, 0, 50, 479,LCD_BLUE);
grantphillips 0:3f62b3c0ec9a 132 * lcd.FillRectangle(650, 0, 50, 479,LCD_NAVY);
grantphillips 0:3f62b3c0ec9a 133 * lcd.FillRectangle(700, 0, 50, 479,LCD_FUCHSIA);
grantphillips 0:3f62b3c0ec9a 134 * lcd.FillRectangle(750, 0, 50, 479,LCD_PURPLE);
grantphillips 0:3f62b3c0ec9a 135 * lcd.DrawStringAtXY(0, 0, 1, LCD_WHITE, LCD_BLACK, "White");
grantphillips 0:3f62b3c0ec9a 136 * lcd.DrawStringAtXY(50, 0, 1, LCD_WHITE, LCD_BLACK, "Silver");
grantphillips 0:3f62b3c0ec9a 137 * lcd.DrawStringAtXY(100, 0, 1, LCD_WHITE, LCD_BLACK, "Gray");
grantphillips 0:3f62b3c0ec9a 138 * lcd.DrawStringAtXY(150, 0, 1, LCD_WHITE, LCD_BLACK, "Black");
grantphillips 0:3f62b3c0ec9a 139 * lcd.DrawStringAtXY(200, 0, 1, LCD_WHITE, LCD_BLACK, "Red");
grantphillips 0:3f62b3c0ec9a 140 * lcd.DrawStringAtXY(250, 0, 1, LCD_WHITE, LCD_BLACK, "Maroon");
grantphillips 0:3f62b3c0ec9a 141 * lcd.DrawStringAtXY(300, 0, 1, LCD_WHITE, LCD_BLACK, "Yellow");
grantphillips 0:3f62b3c0ec9a 142 * lcd.DrawStringAtXY(350, 0, 1, LCD_WHITE, LCD_BLACK, "Olive");
grantphillips 0:3f62b3c0ec9a 143 * lcd.DrawStringAtXY(400, 0, 1, LCD_WHITE, LCD_BLACK, "Lime");
grantphillips 0:3f62b3c0ec9a 144 * lcd.DrawStringAtXY(450, 0, 1, LCD_WHITE, LCD_BLACK, "Green");
grantphillips 0:3f62b3c0ec9a 145 * lcd.DrawStringAtXY(500, 0, 1, LCD_WHITE, LCD_BLACK, "Aqua");
grantphillips 0:3f62b3c0ec9a 146 * lcd.DrawStringAtXY(550, 0, 1, LCD_WHITE, LCD_BLACK, "Teal");
grantphillips 0:3f62b3c0ec9a 147 * lcd.DrawStringAtXY(600, 0, 1, LCD_WHITE, LCD_BLACK, "Blue");
grantphillips 0:3f62b3c0ec9a 148 * lcd.DrawStringAtXY(650, 0, 1, LCD_WHITE, LCD_BLACK, "Navy");
grantphillips 0:3f62b3c0ec9a 149 * lcd.DrawStringAtXY(700, 0, 1, LCD_WHITE, LCD_BLACK, "Fuchsia");
grantphillips 0:3f62b3c0ec9a 150 * lcd.DrawStringAtXY(750, 0, 1, LCD_WHITE, LCD_BLACK, "Purple");
grantphillips 0:3f62b3c0ec9a 151 * }
grantphillips 0:3f62b3c0ec9a 152 * @endcode
grantphillips 0:3f62b3c0ec9a 153 */
grantphillips 0:3f62b3c0ec9a 154
grantphillips 0:3f62b3c0ec9a 155 class DISCOF469SerialLCD {
grantphillips 0:3f62b3c0ec9a 156 public:
grantphillips 0:3f62b3c0ec9a 157 /** Create a DISCOF469SerialLCD object for a graphics LCD connected to the specified pins.
grantphillips 0:3f62b3c0ec9a 158 * @param Tx USART TX pin used to connect to Nextion LCD's RX pin
grantphillips 0:3f62b3c0ec9a 159 * @param Rx USART RX pin used to connect to Nextion LCD's TX pin
grantphillips 0:3f62b3c0ec9a 160 */
grantphillips 0:3f62b3c0ec9a 161 DISCOF469SerialLCD(PinName Tx, PinName Rx);
grantphillips 0:3f62b3c0ec9a 162
grantphillips 0:3f62b3c0ec9a 163 /**
grantphillips 0:3f62b3c0ec9a 164 * @brief Clears the LCD by filling it with the specified color pixels.
grantphillips 2:b4877019c16a 165 * @param Color Color to fill the screen with - represented in ARGB8888 color space format.
grantphillips 0:3f62b3c0ec9a 166 */
grantphillips 0:3f62b3c0ec9a 167 void Clear(uint32_t Color);
grantphillips 0:3f62b3c0ec9a 168
grantphillips 0:3f62b3c0ec9a 169 /**
grantphillips 0:3f62b3c0ec9a 170 * @brief Draws a pixel on the LCD.
grantphillips 2:b4877019c16a 171 * @param Xpos X position
grantphillips 2:b4877019c16a 172 * @param Ypos Y position
grantphillips 2:b4877019c16a 173 * @param Color Pixel color in ARGB mode (8-8-8-8)
grantphillips 0:3f62b3c0ec9a 174 */
grantphillips 0:3f62b3c0ec9a 175 void DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t Color);
grantphillips 0:3f62b3c0ec9a 176
grantphillips 0:3f62b3c0ec9a 177 /**
grantphillips 0:3f62b3c0ec9a 178 * @brief Reads the color of an LCD pixel.
grantphillips 2:b4877019c16a 179 * @param Xpos X position
grantphillips 2:b4877019c16a 180 * @param Ypos Y position
grantphillips 3:33ee80658224 181 * @retval uint32_t Pixel color in ARGB mode (8-8-8-8)
grantphillips 0:3f62b3c0ec9a 182 */
grantphillips 0:3f62b3c0ec9a 183 uint32_t ReadPixel(uint16_t Xpos, uint16_t Ypos);
grantphillips 0:3f62b3c0ec9a 184
grantphillips 0:3f62b3c0ec9a 185 /**
grantphillips 0:3f62b3c0ec9a 186 * @brief Draws a line on the LCD.
grantphillips 2:b4877019c16a 187 * @param x1 Point 1 X position
grantphillips 2:b4877019c16a 188 * @param y1 Point 1 Y position
grantphillips 2:b4877019c16a 189 * @param x2 Point 2 X position
grantphillips 2:b4877019c16a 190 * @param y2 Point 2 Y position
grantphillips 2:b4877019c16a 191 * @param Color Line color in ARGB mode (8-8-8-8)
grantphillips 0:3f62b3c0ec9a 192 */
grantphillips 0:3f62b3c0ec9a 193 void DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint32_t Color);
grantphillips 0:3f62b3c0ec9a 194
grantphillips 0:3f62b3c0ec9a 195 /**
grantphillips 0:3f62b3c0ec9a 196 * @brief Draws a rectangle on the LCD.
grantphillips 2:b4877019c16a 197 * @param Xpos X position
grantphillips 2:b4877019c16a 198 * @param Ypos Y position
grantphillips 2:b4877019c16a 199 * @param Width Rectangle width
grantphillips 2:b4877019c16a 200 * @param Height Rectangle height
grantphillips 2:b4877019c16a 201 * @param Color Rectangle color in ARGB mode (8-8-8-8)
grantphillips 0:3f62b3c0ec9a 202 */
grantphillips 0:3f62b3c0ec9a 203 void DrawRectangle(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height, uint32_t Color);
grantphillips 0:3f62b3c0ec9a 204
grantphillips 0:3f62b3c0ec9a 205 /**
grantphillips 0:3f62b3c0ec9a 206 * @brief Draws a filled rectangle on the LCD.
grantphillips 2:b4877019c16a 207 * @param Xpos X position
grantphillips 2:b4877019c16a 208 * @param Ypos Y position
grantphillips 2:b4877019c16a 209 * @param Width Rectangle width
grantphillips 2:b4877019c16a 210 * @param Height Rectangle height
grantphillips 2:b4877019c16a 211 * @param Color Rectangle color in ARGB mode (8-8-8-8)
grantphillips 0:3f62b3c0ec9a 212 */
grantphillips 0:3f62b3c0ec9a 213 void FillRectangle(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height, uint32_t Color);
grantphillips 0:3f62b3c0ec9a 214
grantphillips 0:3f62b3c0ec9a 215 /**
grantphillips 0:3f62b3c0ec9a 216 * @brief Draws a circle on the LCD.
grantphillips 2:b4877019c16a 217 * @param Xpos X position
grantphillips 2:b4877019c16a 218 * @param Ypos Y position
grantphillips 2:b4877019c16a 219 * @param Radius Circle radius
grantphillips 2:b4877019c16a 220 * @param Color Circle color in ARGB mode (8-8-8-8)
grantphillips 0:3f62b3c0ec9a 221 */
grantphillips 0:3f62b3c0ec9a 222 void DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius, uint32_t Color);
grantphillips 0:3f62b3c0ec9a 223
grantphillips 0:3f62b3c0ec9a 224 /**
grantphillips 0:3f62b3c0ec9a 225 * @brief Draws a filled circle on the LCD.
grantphillips 2:b4877019c16a 226 * @param Xpos X position
grantphillips 2:b4877019c16a 227 * @param Ypos Y position
grantphillips 2:b4877019c16a 228 * @param Radius Circle radius
grantphillips 2:b4877019c16a 229 * @param Color Circle color in ARGB mode (8-8-8-8)
grantphillips 0:3f62b3c0ec9a 230 */
grantphillips 0:3f62b3c0ec9a 231 void FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius, uint32_t Color);
grantphillips 0:3f62b3c0ec9a 232
grantphillips 0:3f62b3c0ec9a 233 /**
grantphillips 0:3f62b3c0ec9a 234 * @brief Draws an ellipse on the LCD.
grantphillips 2:b4877019c16a 235 * @param Xpos X position
grantphillips 2:b4877019c16a 236 * @param Ypos Y position
grantphillips 2:b4877019c16a 237 * @param XRadius Ellipse X radius
grantphillips 2:b4877019c16a 238 * @param YRadius Ellipse Y radius
grantphillips 2:b4877019c16a 239 * @param Color Ellipse color in ARGB mode (8-8-8-8)
grantphillips 0:3f62b3c0ec9a 240 */
grantphillips 0:3f62b3c0ec9a 241 void DrawEllipse(uint16_t Xpos, uint16_t Ypos, uint16_t XRadius, uint16_t YRadius, uint32_t Color);
grantphillips 0:3f62b3c0ec9a 242
grantphillips 0:3f62b3c0ec9a 243 /**
grantphillips 0:3f62b3c0ec9a 244 * @brief Draws a filled ellipse on the LCD.
grantphillips 2:b4877019c16a 245 * @param Xpos X position
grantphillips 2:b4877019c16a 246 * @param Ypos Y position
grantphillips 2:b4877019c16a 247 * @param XRadius Ellipse X radius
grantphillips 2:b4877019c16a 248 * @param YRadius Ellipse Y radius
grantphillips 2:b4877019c16a 249 * @param Color Ellipse color in ARGB mode (8-8-8-8)
grantphillips 0:3f62b3c0ec9a 250 */
grantphillips 0:3f62b3c0ec9a 251 void FillEllipse(uint16_t Xpos, uint16_t Ypos, uint16_t XRadius, uint16_t YRadius, uint32_t Color);
grantphillips 0:3f62b3c0ec9a 252
grantphillips 0:3f62b3c0ec9a 253 /**
grantphillips 0:3f62b3c0ec9a 254 * @brief Displays a string on the LCD at Xpos,Ypos.
grantphillips 2:b4877019c16a 255 * @param Xpos X position (in pixel)
grantphillips 2:b4877019c16a 256 * @param Ypos Y position (in pixel)
grantphillips 2:b4877019c16a 257 * @param FontSize The size of the text (0 - 4)
grantphillips 2:b4877019c16a 258 * @param TextColor The text foreground color
grantphillips 2:b4877019c16a 259 * @param BackColor The text background color
grantphillips 2:b4877019c16a 260 * @param Text String to display on LCD
grantphillips 0:3f62b3c0ec9a 261 */
grantphillips 0:3f62b3c0ec9a 262 void DrawStringAtXY(uint16_t Xpos, uint16_t Ypos, uint8_t FontSize, uint32_t TextColor, uint32_t BackColor, char *Text);
grantphillips 0:3f62b3c0ec9a 263
grantphillips 0:3f62b3c0ec9a 264 /**
grantphillips 0:3f62b3c0ec9a 265 * @brief Displays a string on the LCD at a certain line based on the font size.
grantphillips 2:b4877019c16a 266 * @param Line Line where to display the string
grantphillips 2:b4877019c16a 267 * @param FontSize The size of the text (0 - 4)
grantphillips 2:b4877019c16a 268 * @param TextColor The text foreground color
grantphillips 2:b4877019c16a 269 * @param BackColor The text background color
grantphillips 2:b4877019c16a 270 * @param Mode Display mode (0=LEFT mode; 1=CENTER mode; 2=RIGHT mode)
grantphillips 2:b4877019c16a 271 * @param Text String to display on LCD
grantphillips 0:3f62b3c0ec9a 272 */
grantphillips 0:3f62b3c0ec9a 273 void DrawStringAtLine(uint16_t Line, uint8_t FontSize, uint32_t TextColor, uint32_t BackColor, uint8_t Mode, char *Text);
grantphillips 0:3f62b3c0ec9a 274
grantphillips 0:3f62b3c0ec9a 275 /** Determines if the touchscreen is being touched or not.
grantphillips 0:3f62b3c0ec9a 276 *
grantphillips 3:33ee80658224 277 * @retval uint8_t Number of simulantanous touches on screen. 0 = not touched.
grantphillips 0:3f62b3c0ec9a 278 */
grantphillips 0:3f62b3c0ec9a 279 uint8_t Touches(void);
grantphillips 0:3f62b3c0ec9a 280
grantphillips 0:3f62b3c0ec9a 281 /**
grantphillips 0:3f62b3c0ec9a 282 * @brief Gets the x and y coordinates of the first touch on the touchscreen.
grantphillips 2:b4877019c16a 283 * @param x Pointer to the x coordinate
grantphillips 2:b4877019c16a 284 * @param y Pointer to the y coordinate
grantphillips 0:3f62b3c0ec9a 285 */
grantphillips 0:3f62b3c0ec9a 286 void GetTouch1(uint16_t *x, uint16_t *y);
grantphillips 0:3f62b3c0ec9a 287
grantphillips 0:3f62b3c0ec9a 288 /**
grantphillips 0:3f62b3c0ec9a 289 * @brief Gets the x and y coordinates of the second touch on the touchscreen.
grantphillips 2:b4877019c16a 290 * @param x Pointer to the x coordinate
grantphillips 2:b4877019c16a 291 * @param y Pointer to the y coordinate
grantphillips 0:3f62b3c0ec9a 292 */
grantphillips 0:3f62b3c0ec9a 293 void GetTouch2(uint16_t *x, uint16_t *y);
grantphillips 0:3f62b3c0ec9a 294
grantphillips 0:3f62b3c0ec9a 295 /**
grantphillips 0:3f62b3c0ec9a 296 * @brief Writes to the LCD's LED1.
grantphillips 2:b4877019c16a 297 * @param OnOff 1 = On; 0 = Off
grantphillips 0:3f62b3c0ec9a 298 */
grantphillips 0:3f62b3c0ec9a 299 void LED1(uint8_t OnOff);
grantphillips 0:3f62b3c0ec9a 300
grantphillips 0:3f62b3c0ec9a 301 /**
grantphillips 0:3f62b3c0ec9a 302 * @brief Writes to the LCD's LED1.
grantphillips 2:b4877019c16a 303 * @param OnOff 1 = On; 0 = Off
grantphillips 0:3f62b3c0ec9a 304 */
grantphillips 0:3f62b3c0ec9a 305 void LED2(uint8_t OnOff);
grantphillips 0:3f62b3c0ec9a 306
grantphillips 0:3f62b3c0ec9a 307 /**
grantphillips 0:3f62b3c0ec9a 308 * @brief Writes to the LCD's LED1.
grantphillips 2:b4877019c16a 309 * @param OnOff 1 = On; 0 = Off
grantphillips 0:3f62b3c0ec9a 310 */
grantphillips 0:3f62b3c0ec9a 311 void LED3(uint8_t OnOff);
grantphillips 0:3f62b3c0ec9a 312
grantphillips 0:3f62b3c0ec9a 313 /**
grantphillips 0:3f62b3c0ec9a 314 * @brief Writes to the LCD's LED1.
grantphillips 2:b4877019c16a 315 * @param OnOff 1 = On; 0 = Off
grantphillips 0:3f62b3c0ec9a 316 */
grantphillips 0:3f62b3c0ec9a 317 void LED4(uint8_t OnOff);
grantphillips 0:3f62b3c0ec9a 318
grantphillips 0:3f62b3c0ec9a 319
grantphillips 0:3f62b3c0ec9a 320
grantphillips 0:3f62b3c0ec9a 321 private:
grantphillips 0:3f62b3c0ec9a 322
grantphillips 0:3f62b3c0ec9a 323
grantphillips 0:3f62b3c0ec9a 324 BufferedSerial lcd; //Serial object for connecting to LCD
grantphillips 0:3f62b3c0ec9a 325 //Serial pc;
grantphillips 0:3f62b3c0ec9a 326 uint8_t mTouches;
grantphillips 0:3f62b3c0ec9a 327 uint16_t mTouch1X, mTouch1Y,mTouch2X, mTouch2Y;
grantphillips 0:3f62b3c0ec9a 328 uint32_t mReadPixelColor;
grantphillips 0:3f62b3c0ec9a 329 int mcnt;
grantphillips 0:3f62b3c0ec9a 330
grantphillips 0:3f62b3c0ec9a 331 char mRxMsg[40];
grantphillips 0:3f62b3c0ec9a 332 int mRxIdx;
grantphillips 0:3f62b3c0ec9a 333 char cmd[5];
grantphillips 0:3f62b3c0ec9a 334 uint32_t data32_0;
grantphillips 0:3f62b3c0ec9a 335 uint16_t data16_0, data16_1;
grantphillips 0:3f62b3c0ec9a 336 uint8_t data8_0;
grantphillips 0:3f62b3c0ec9a 337 void ServiceSerialRX(void); //Rx Interrupt
grantphillips 0:3f62b3c0ec9a 338 };
grantphillips 0:3f62b3c0ec9a 339
grantphillips 0:3f62b3c0ec9a 340 #endif