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