Adapted from Peter Dresche's original for Waveshare 2.8inch TFT Touch Shield Board and Mbed 6. RGB order reversed by changing reg 16 commands, spi write code adjusted as there is no reset pin but there is data command pin. Wait commands changed for new thread_sleep style, Stream class explicitly included. Library to control a QVGA TFT connected to SPI. You can use printf to print text The lib can handle different fonts, draw lines, circles, rect and bmp

Committer:
John Durrell
Date:
Tue Mar 30 20:38:26 2021 +0100
Revision:
27:8360ab3c19d6
Parent:
25:f593b4adb905
Sorting

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dreschpe 8:65a4de035c3c 1 /* mbed library for 240*320 pixel display TFT based on HX8347D LCD Controller
dreschpe 8:65a4de035c3c 2 * Copyright (c) 2011 Peter Drescher - DC2PD
jhd25 19:40a5d0425259 3 * Edited for Wavehare - JHD
dreschpe 8:65a4de035c3c 4 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
dreschpe 8:65a4de035c3c 5 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
dreschpe 8:65a4de035c3c 6 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
dreschpe 8:65a4de035c3c 7 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
dreschpe 8:65a4de035c3c 8 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
dreschpe 8:65a4de035c3c 9 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
dreschpe 8:65a4de035c3c 10 * THE SOFTWARE.
dreschpe 8:65a4de035c3c 11 */
dreschpe 8:65a4de035c3c 12
dreschpe 8:65a4de035c3c 13 /* change the char position handling
dreschpe 8:65a4de035c3c 14 * use pixel (x,y) instadt of colum row */
dreschpe 8:65a4de035c3c 15
dreschpe 8:65a4de035c3c 16
dreschpe 8:65a4de035c3c 17 #ifndef MBED_SPI_TFT_H
dreschpe 8:65a4de035c3c 18 #define MBED_SPI_TFT_H
dreschpe 8:65a4de035c3c 19
jhd25 20:275bf616ceb7 20 #define NO_DMA
dreschpe 8:65a4de035c3c 21
dreschpe 8:65a4de035c3c 22 #include "mbed.h"
dreschpe 8:65a4de035c3c 23 #include "GraphicsDisplay.h"
jhd25 25:f593b4adb905 24 #include "DirectSPI.h"
jhd25 25:f593b4adb905 25
dreschpe 8:65a4de035c3c 26
dreschpe 8:65a4de035c3c 27 #define RGB(r,g,b) (((r&0xF8)<<8)|((g&0xFC)<<3)|((b&0xF8)>>3)) //5 red | 6 green | 5 blue
dreschpe 8:65a4de035c3c 28
dreschpe 8:65a4de035c3c 29 #define SPI_START (0x70) /* Start byte for SPI transfer */
dreschpe 8:65a4de035c3c 30 #define SPI_RD (0x01) /* WR bit 1 within start */
dreschpe 8:65a4de035c3c 31 #define SPI_WR (0x00) /* WR bit 0 within start */
dreschpe 8:65a4de035c3c 32 #define SPI_DATA (0x02) /* RS bit 1 within start byte */
dreschpe 8:65a4de035c3c 33 #define SPI_INDEX (0x00) /* RS bit 0 within start byte */
dreschpe 8:65a4de035c3c 34
dreschpe 8:65a4de035c3c 35
jhd25 20:275bf616ceb7 36 /* some RGB color definitions
jhd25 20:275bf616ceb7 37 // Orginally RGB
jhd25 21:d7ae9d59eb03 38 // Waveshare board is BGR */
dreschpe 8:65a4de035c3c 39 #define Black 0x0000 /* 0, 0, 0 */
dreschpe 8:65a4de035c3c 40 #define Navy 0x000F /* 0, 0, 128 */
dreschpe 8:65a4de035c3c 41 #define DarkGreen 0x03E0 /* 0, 128, 0 */
dreschpe 8:65a4de035c3c 42 #define DarkCyan 0x03EF /* 0, 128, 128 */
dreschpe 8:65a4de035c3c 43 #define Maroon 0x7800 /* 128, 0, 0 */
dreschpe 8:65a4de035c3c 44 #define Purple 0x780F /* 128, 0, 128 */
dreschpe 8:65a4de035c3c 45 #define Olive 0x7BE0 /* 128, 128, 0 */
dreschpe 8:65a4de035c3c 46 #define LightGrey 0xC618 /* 192, 192, 192 */
dreschpe 8:65a4de035c3c 47 #define DarkGrey 0x7BEF /* 128, 128, 128 */
dreschpe 8:65a4de035c3c 48 #define Blue 0x001F /* 0, 0, 255 */
dreschpe 8:65a4de035c3c 49 #define Green 0x07E0 /* 0, 255, 0 */
dreschpe 8:65a4de035c3c 50 #define Cyan 0x07FF /* 0, 255, 255 */
dreschpe 8:65a4de035c3c 51 #define Red 0xF800 /* 255, 0, 0 */
dreschpe 8:65a4de035c3c 52 #define Magenta 0xF81F /* 255, 0, 255 */
dreschpe 8:65a4de035c3c 53 #define Yellow 0xFFE0 /* 255, 255, 0 */
dreschpe 8:65a4de035c3c 54 #define White 0xFFFF /* 255, 255, 255 */
dreschpe 8:65a4de035c3c 55 #define Orange 0xFD20 /* 255, 165, 0 */
dreschpe 8:65a4de035c3c 56 #define GreenYellow 0xAFE5 /* 173, 255, 47 */
dreschpe 8:65a4de035c3c 57
dreschpe 8:65a4de035c3c 58
dreschpe 8:65a4de035c3c 59 // some defines for the DMA use
dreschpe 8:65a4de035c3c 60 #define DMA_CHANNEL_ENABLE 1
dreschpe 8:65a4de035c3c 61 #define DMA_TRANSFER_TYPE_M2P (1UL << 11)
dreschpe 8:65a4de035c3c 62 #define DMA_CHANNEL_TCIE (1UL << 31)
dreschpe 8:65a4de035c3c 63 #define DMA_CHANNEL_SRC_INC (1UL << 26)
dreschpe 8:65a4de035c3c 64 #define DMA_MASK_IE (1UL << 14)
dreschpe 8:65a4de035c3c 65 #define DMA_MASK_ITC (1UL << 15)
dreschpe 8:65a4de035c3c 66 #define DMA_SSP1_TX (1UL << 2)
dreschpe 8:65a4de035c3c 67 #define DMA_SSP0_TX (0)
dreschpe 8:65a4de035c3c 68 #define DMA_DEST_SSP1_TX (2UL << 6)
dreschpe 8:65a4de035c3c 69 #define DMA_DEST_SSP0_TX (0UL << 6)
dreschpe 8:65a4de035c3c 70
dreschpe 8:65a4de035c3c 71
dreschpe 8:65a4de035c3c 72 /** Display control class, based on GraphicsDisplay and TextDisplay
dreschpe 8:65a4de035c3c 73 *
dreschpe 8:65a4de035c3c 74 * Example:
dreschpe 8:65a4de035c3c 75 * @code
dreschpe 8:65a4de035c3c 76 * #include "stdio.h"
dreschpe 8:65a4de035c3c 77 * #include "mbed.h"
dreschpe 8:65a4de035c3c 78 * #include "SPI_TFT.h"
dreschpe 8:65a4de035c3c 79 * #include "string"
dreschpe 8:65a4de035c3c 80 * #include "Arial12x12.h"
dreschpe 8:65a4de035c3c 81 * #include "Arial24x23.h"
dreschpe 8:65a4de035c3c 82 *
dreschpe 8:65a4de035c3c 83 *
dreschpe 8:65a4de035c3c 84 *
dreschpe 8:65a4de035c3c 85 * // the TFT is connected to SPI pin 5-7
dreschpe 8:65a4de035c3c 86 * SPI_TFT TFT(p5, p6, p7, p8, p15,"TFT"); // mosi, miso, sclk, cs, reset
dreschpe 8:65a4de035c3c 87 *
dreschpe 8:65a4de035c3c 88 * int main() {
dreschpe 8:65a4de035c3c 89 * TFT.claim(stdout); // send stdout to the TFT display
dreschpe 8:65a4de035c3c 90 * //TFT.claim(stderr); // send stderr to the TFT display
dreschpe 8:65a4de035c3c 91 *
dreschpe 8:65a4de035c3c 92 * TFT.background(Black); // set background to black
dreschpe 8:65a4de035c3c 93 * TFT.foreground(White); // set chars to white
dreschpe 8:65a4de035c3c 94 * TFT.cls(); // clear the screen
dreschpe 8:65a4de035c3c 95 * TFT.set_font((unsigned char*) Arial12x12); // select the font
dreschpe 8:65a4de035c3c 96 *
dreschpe 8:65a4de035c3c 97 * TFT.set_orientation(0);
dreschpe 8:65a4de035c3c 98 * TFT.locate(0,0);
dreschpe 8:65a4de035c3c 99 * printf(" Hello Mbed 0");
dreschpe 8:65a4de035c3c 100 * TFT.set_font((unsigned char*) Arial24x23); // select font 2
dreschpe 8:65a4de035c3c 101 * TFT.locate(48,115);
dreschpe 8:65a4de035c3c 102 * TFT.printf("Bigger Font");
dreschpe 8:65a4de035c3c 103 * }
dreschpe 8:65a4de035c3c 104 * @endcode
dreschpe 8:65a4de035c3c 105 */
dreschpe 8:65a4de035c3c 106 class SPI_TFT : public GraphicsDisplay {
dreschpe 8:65a4de035c3c 107 public:
dreschpe 8:65a4de035c3c 108
dreschpe 8:65a4de035c3c 109 /** Create a SPI_TFT object connected to SPI and two pins
dreschpe 8:65a4de035c3c 110 *
dreschpe 8:65a4de035c3c 111 * @param mosi,miso,sclk SPI
dreschpe 8:65a4de035c3c 112 * @param cs pin connected to CS of display
dreschpe 8:65a4de035c3c 113 * @param reset pin connected to RESET of display
dreschpe 8:65a4de035c3c 114 *
dreschpe 8:65a4de035c3c 115 */
dreschpe 8:65a4de035c3c 116 SPI_TFT(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset,const char* name ="TFT");
dreschpe 8:65a4de035c3c 117
dreschpe 8:65a4de035c3c 118 /** Get the width of the screen in pixel
dreschpe 8:65a4de035c3c 119 *
dreschpe 8:65a4de035c3c 120 * @param
dreschpe 8:65a4de035c3c 121 * @returns width of screen in pixel
dreschpe 8:65a4de035c3c 122 *
dreschpe 8:65a4de035c3c 123 */
dreschpe 8:65a4de035c3c 124 virtual int width();
dreschpe 8:65a4de035c3c 125
dreschpe 8:65a4de035c3c 126 /** Get the height of the screen in pixel
dreschpe 8:65a4de035c3c 127 *
dreschpe 8:65a4de035c3c 128 * @returns height of screen in pixel
dreschpe 8:65a4de035c3c 129 *
dreschpe 8:65a4de035c3c 130 */
dreschpe 8:65a4de035c3c 131 virtual int height();
dreschpe 8:65a4de035c3c 132
dreschpe 8:65a4de035c3c 133 /** Draw a pixel at x,y with color
dreschpe 8:65a4de035c3c 134 *
dreschpe 8:65a4de035c3c 135 * @param x horizontal position
dreschpe 8:65a4de035c3c 136 * @param y vertical position
dreschpe 8:65a4de035c3c 137 * @param color 16 bit pixel color
dreschpe 8:65a4de035c3c 138 */
dreschpe 8:65a4de035c3c 139 virtual void pixel(int x, int y,int colour);
dreschpe 8:65a4de035c3c 140
dreschpe 8:65a4de035c3c 141 /** draw a circle
dreschpe 8:65a4de035c3c 142 *
dreschpe 8:65a4de035c3c 143 * @param x0,y0 center
dreschpe 8:65a4de035c3c 144 * @param r radius
dreschpe 8:65a4de035c3c 145 * @param color 16 bit color *
dreschpe 8:65a4de035c3c 146 *
dreschpe 8:65a4de035c3c 147 */
dreschpe 8:65a4de035c3c 148 void circle(int x, int y, int r, int colour);
dreschpe 8:65a4de035c3c 149
dreschpe 8:65a4de035c3c 150 /** draw a filled circle
dreschpe 8:65a4de035c3c 151 *
dreschpe 8:65a4de035c3c 152 * @param x0,y0 center
dreschpe 8:65a4de035c3c 153 * @param r radius
dreschpe 8:65a4de035c3c 154 * @param color 16 bit color *
dreschpe 8:65a4de035c3c 155 *
dreschpe 8:65a4de035c3c 156 * use circle with different radius,
dreschpe 8:65a4de035c3c 157 * can miss some pixel
dreschpe 8:65a4de035c3c 158 */
dreschpe 8:65a4de035c3c 159 void fillcircle(int x, int y, int r, int colour);
dreschpe 8:65a4de035c3c 160
dreschpe 8:65a4de035c3c 161
dreschpe 8:65a4de035c3c 162
dreschpe 8:65a4de035c3c 163 /** draw a 1 pixel line
dreschpe 8:65a4de035c3c 164 *
dreschpe 8:65a4de035c3c 165 * @param x0,y0 start point
dreschpe 8:65a4de035c3c 166 * @param x1,y1 stop point
dreschpe 8:65a4de035c3c 167 * @param color 16 bit color
dreschpe 8:65a4de035c3c 168 *
dreschpe 8:65a4de035c3c 169 */
dreschpe 8:65a4de035c3c 170 void line(int x0, int y0, int x1, int y1, int colour);
dreschpe 8:65a4de035c3c 171
dreschpe 8:65a4de035c3c 172 /** draw a rect
dreschpe 8:65a4de035c3c 173 *
dreschpe 8:65a4de035c3c 174 * @param x0,y0 top left corner
dreschpe 8:65a4de035c3c 175 * @param x1,y1 down right corner
dreschpe 8:65a4de035c3c 176 * @param color 16 bit color
dreschpe 8:65a4de035c3c 177 * *
dreschpe 8:65a4de035c3c 178 */
dreschpe 8:65a4de035c3c 179 void rect(int x0, int y0, int x1, int y1, int colour);
dreschpe 8:65a4de035c3c 180
dreschpe 8:65a4de035c3c 181 /** draw a filled rect
dreschpe 8:65a4de035c3c 182 *
dreschpe 8:65a4de035c3c 183 * @param x0,y0 top left corner
dreschpe 8:65a4de035c3c 184 * @param x1,y1 down right corner
dreschpe 8:65a4de035c3c 185 * @param color 16 bit color
dreschpe 8:65a4de035c3c 186 *
dreschpe 8:65a4de035c3c 187 */
dreschpe 8:65a4de035c3c 188 void fillrect(int x0, int y0, int x1, int y1, int colour);
dreschpe 8:65a4de035c3c 189
dreschpe 8:65a4de035c3c 190 /** setup cursor position
dreschpe 8:65a4de035c3c 191 *
dreschpe 8:65a4de035c3c 192 * @param x x-position (top left)
dreschpe 8:65a4de035c3c 193 * @param y y-position
dreschpe 8:65a4de035c3c 194 */
dreschpe 8:65a4de035c3c 195 virtual void locate(int x, int y);
dreschpe 8:65a4de035c3c 196
dreschpe 8:65a4de035c3c 197 /** Fill the screen with _backgroun color
dreschpe 8:65a4de035c3c 198 *
dreschpe 8:65a4de035c3c 199 */
dreschpe 8:65a4de035c3c 200 virtual void cls (void);
dreschpe 8:65a4de035c3c 201
dreschpe 8:65a4de035c3c 202 /** calculate the max number of char in a line
dreschpe 8:65a4de035c3c 203 *
dreschpe 8:65a4de035c3c 204 * @returns max columns
dreschpe 8:65a4de035c3c 205 * depends on actual font size
dreschpe 8:65a4de035c3c 206 *
dreschpe 8:65a4de035c3c 207 */
dreschpe 8:65a4de035c3c 208 virtual int columns(void);
dreschpe 8:65a4de035c3c 209
dreschpe 8:65a4de035c3c 210 /** calculate the max number of columns
dreschpe 8:65a4de035c3c 211 *
dreschpe 8:65a4de035c3c 212 * @returns max column
dreschpe 8:65a4de035c3c 213 * depends on actual font size
dreschpe 8:65a4de035c3c 214 *
dreschpe 8:65a4de035c3c 215 */
dreschpe 8:65a4de035c3c 216 virtual int rows(void);
dreschpe 8:65a4de035c3c 217
dreschpe 8:65a4de035c3c 218 /** put a char on the screen
dreschpe 8:65a4de035c3c 219 *
dreschpe 8:65a4de035c3c 220 * @param value char to print
dreschpe 8:65a4de035c3c 221 * @returns printed char
dreschpe 8:65a4de035c3c 222 *
dreschpe 8:65a4de035c3c 223 */
dreschpe 8:65a4de035c3c 224 virtual int _putc(int value);
dreschpe 8:65a4de035c3c 225
dreschpe 8:65a4de035c3c 226 /** draw a character on given position out of the active font to the TFT
dreschpe 8:65a4de035c3c 227 *
dreschpe 8:65a4de035c3c 228 * @param x x-position of char (top left)
dreschpe 8:65a4de035c3c 229 * @param y y-position
dreschpe 8:65a4de035c3c 230 * @param c char to print
dreschpe 8:65a4de035c3c 231 *
dreschpe 8:65a4de035c3c 232 */
dreschpe 8:65a4de035c3c 233 virtual void character(int x, int y, int c);
dreschpe 8:65a4de035c3c 234
dreschpe 8:65a4de035c3c 235 /** paint a bitmap on the TFT
dreschpe 8:65a4de035c3c 236 *
dreschpe 8:65a4de035c3c 237 * @param x,y : upper left corner
dreschpe 8:65a4de035c3c 238 * @param w width of bitmap
dreschpe 8:65a4de035c3c 239 * @param h high of bitmap
dreschpe 8:65a4de035c3c 240 * @param *bitmap pointer to the bitmap data
dreschpe 8:65a4de035c3c 241 *
dreschpe 8:65a4de035c3c 242 * bitmap format: 16 bit R5 G6 B5
dreschpe 8:65a4de035c3c 243 *
dreschpe 8:65a4de035c3c 244 * use Gimp to create / load , save as BMP, option 16 bit R5 G6 B5
dreschpe 8:65a4de035c3c 245 * use winhex to load this file and mark data stating at offset 0x46 to end
dreschpe 8:65a4de035c3c 246 * use edit -> copy block -> C Source to export C array
dreschpe 8:65a4de035c3c 247 * paste this array into your program
dreschpe 8:65a4de035c3c 248 *
dreschpe 8:65a4de035c3c 249 * define the array as static const unsigned char to put it into flash memory
dreschpe 8:65a4de035c3c 250 * cast the pointer to (unsigned char *) :
dreschpe 8:65a4de035c3c 251 * tft.Bitmap(10,40,309,50,(unsigned char *)scala);
dreschpe 8:65a4de035c3c 252 */
dreschpe 8:65a4de035c3c 253 void Bitmap(unsigned int x, unsigned int y, unsigned int w, unsigned int h,unsigned char *bitmap);
dreschpe 8:65a4de035c3c 254
dreschpe 8:65a4de035c3c 255
dreschpe 8:65a4de035c3c 256 /** paint a 16 bit BMP from local filesytem on the TFT (slow)
dreschpe 8:65a4de035c3c 257 *
dreschpe 8:65a4de035c3c 258 * @param x,y : upper left corner
dreschpe 8:65a4de035c3c 259 * @param *Name_BMP name of the BMP file
dreschpe 8:65a4de035c3c 260 * @returns 1 if bmp file was found and painted
dreschpe 8:65a4de035c3c 261 * @returns -1 if bmp file was found not found
dreschpe 8:65a4de035c3c 262 * @returns -2 if bmp file is not 16bit
dreschpe 8:65a4de035c3c 263 * @returns -3 if bmp file is to big for screen
dreschpe 8:65a4de035c3c 264 * @returns -4 if buffer malloc go wrong
dreschpe 8:65a4de035c3c 265 *
dreschpe 8:65a4de035c3c 266 * bitmap format: 16 bit R5 G6 B5
dreschpe 8:65a4de035c3c 267 *
dreschpe 8:65a4de035c3c 268 * use Gimp to create / load , save as BMP, option 16 bit R5 G6 B5
dreschpe 8:65a4de035c3c 269 * copy to internal file system
dreschpe 8:65a4de035c3c 270 *
dreschpe 8:65a4de035c3c 271 */
dreschpe 8:65a4de035c3c 272
dreschpe 8:65a4de035c3c 273 int BMP_16(unsigned int x, unsigned int y, const char *Name_BMP);
dreschpe 8:65a4de035c3c 274
dreschpe 8:65a4de035c3c 275
dreschpe 8:65a4de035c3c 276
dreschpe 8:65a4de035c3c 277 /** select the font to use
dreschpe 8:65a4de035c3c 278 *
dreschpe 8:65a4de035c3c 279 * @param f pointer to font array
dreschpe 8:65a4de035c3c 280 *
dreschpe 8:65a4de035c3c 281 * font array can created with GLCD Font Creator from http://www.mikroe.com
dreschpe 8:65a4de035c3c 282 * you have to add 4 parameter at the beginning of the font array to use:
dreschpe 8:65a4de035c3c 283 * - the number of byte / char
dreschpe 8:65a4de035c3c 284 * - the vertial size in pixel
dreschpe 8:65a4de035c3c 285 * - the horizontal size in pixel
dreschpe 8:65a4de035c3c 286 * - the number of byte per vertical line
dreschpe 8:65a4de035c3c 287 * you also have to change the array to char[]
dreschpe 8:65a4de035c3c 288 *
dreschpe 8:65a4de035c3c 289 */
dreschpe 8:65a4de035c3c 290 void set_font(unsigned char* f);
dreschpe 8:65a4de035c3c 291
dreschpe 8:65a4de035c3c 292 /** Set the orientation of the screen
dreschpe 8:65a4de035c3c 293 * x,y: 0,0 is always top left
dreschpe 8:65a4de035c3c 294 *
dreschpe 8:65a4de035c3c 295 * @param o direction to use the screen (0-3) 90&#65533; Steps
dreschpe 8:65a4de035c3c 296 *
dreschpe 8:65a4de035c3c 297 */
dreschpe 8:65a4de035c3c 298 void set_orientation(unsigned int o);
jhd25 25:f593b4adb905 299 #ifdef __DIRECTSPI_H_
jhd25 25:f593b4adb905 300 DirectSPI _spi;
jhd25 25:f593b4adb905 301 #else
dreschpe 8:65a4de035c3c 302 SPI _spi;
jhd25 25:f593b4adb905 303 #endif
dreschpe 8:65a4de035c3c 304 DigitalOut _cs;
dreschpe 8:65a4de035c3c 305 DigitalOut _reset;
dreschpe 8:65a4de035c3c 306 unsigned char* font;
dreschpe 8:65a4de035c3c 307
dreschpe 8:65a4de035c3c 308
dreschpe 8:65a4de035c3c 309
dreschpe 8:65a4de035c3c 310
dreschpe 8:65a4de035c3c 311 protected:
dreschpe 8:65a4de035c3c 312
dreschpe 8:65a4de035c3c 313 /** Set draw window region to whole screen
dreschpe 8:65a4de035c3c 314 *
dreschpe 8:65a4de035c3c 315 */
dreschpe 8:65a4de035c3c 316 void WindowMax (void);
dreschpe 8:65a4de035c3c 317
dreschpe 8:65a4de035c3c 318
dreschpe 8:65a4de035c3c 319 /** draw a horizontal line
dreschpe 8:65a4de035c3c 320 *
dreschpe 8:65a4de035c3c 321 * @param x0 horizontal start
dreschpe 8:65a4de035c3c 322 * @param x1 horizontal stop
dreschpe 8:65a4de035c3c 323 * @param y vertical position
dreschpe 8:65a4de035c3c 324 * @param color 16 bit color
dreschpe 8:65a4de035c3c 325 *
dreschpe 8:65a4de035c3c 326 */
dreschpe 8:65a4de035c3c 327 void hline(int x0, int x1, int y, int colour);
dreschpe 8:65a4de035c3c 328
dreschpe 8:65a4de035c3c 329 /** draw a vertical line
dreschpe 8:65a4de035c3c 330 *
dreschpe 8:65a4de035c3c 331 * @param x horizontal position
dreschpe 8:65a4de035c3c 332 * @param y0 vertical start
dreschpe 8:65a4de035c3c 333 * @param y1 vertical stop
dreschpe 8:65a4de035c3c 334 * @param color 16 bit color
dreschpe 8:65a4de035c3c 335 */
dreschpe 8:65a4de035c3c 336 void vline(int y0, int y1, int x, int colour);
dreschpe 8:65a4de035c3c 337
dreschpe 8:65a4de035c3c 338 /** Set draw window region
dreschpe 8:65a4de035c3c 339 *
dreschpe 8:65a4de035c3c 340 * @param x horizontal position
dreschpe 8:65a4de035c3c 341 * @param y vertical position
dreschpe 8:65a4de035c3c 342 * @param w window width in pixel
dreschpe 8:65a4de035c3c 343 * @param h window height in pixels
dreschpe 8:65a4de035c3c 344 */
dreschpe 11:9bb71766cafc 345 virtual void window (unsigned int x,unsigned int y, unsigned int w, unsigned int h);
dreschpe 8:65a4de035c3c 346
dreschpe 8:65a4de035c3c 347
dreschpe 8:65a4de035c3c 348
dreschpe 8:65a4de035c3c 349 /** Init the HX8347D controller
dreschpe 8:65a4de035c3c 350 *
dreschpe 8:65a4de035c3c 351 */
dreschpe 8:65a4de035c3c 352 void tft_reset();
dreschpe 8:65a4de035c3c 353
dreschpe 8:65a4de035c3c 354 /** Write data to the LCD controller
dreschpe 8:65a4de035c3c 355 *
dreschpe 8:65a4de035c3c 356 * @param dat data written to LCD controller
dreschpe 8:65a4de035c3c 357 *
dreschpe 8:65a4de035c3c 358 */
dreschpe 8:65a4de035c3c 359 //void wr_dat(unsigned int value);
dreschpe 8:65a4de035c3c 360 void wr_dat(unsigned char value);
dreschpe 8:65a4de035c3c 361
dreschpe 8:65a4de035c3c 362 /** Write a command the LCD controller
dreschpe 8:65a4de035c3c 363 *
dreschpe 8:65a4de035c3c 364 * @param cmd: command to be written
dreschpe 8:65a4de035c3c 365 *
dreschpe 8:65a4de035c3c 366 */
dreschpe 8:65a4de035c3c 367 void wr_cmd(unsigned char value);
dreschpe 8:65a4de035c3c 368
dreschpe 8:65a4de035c3c 369 /** Start data sequence to the LCD controller
dreschpe 8:65a4de035c3c 370 *
dreschpe 8:65a4de035c3c 371 */
dreschpe 8:65a4de035c3c 372 //void wr_dat_start();
dreschpe 8:65a4de035c3c 373
dreschpe 8:65a4de035c3c 374 /** Stop of data writing to the LCD controller
dreschpe 8:65a4de035c3c 375 *
dreschpe 8:65a4de035c3c 376 */
dreschpe 8:65a4de035c3c 377 //void wr_dat_stop();
dreschpe 8:65a4de035c3c 378
dreschpe 8:65a4de035c3c 379 /** write data to the LCD controller
dreschpe 8:65a4de035c3c 380 *
dreschpe 8:65a4de035c3c 381 * @param data to be written
dreschpe 8:65a4de035c3c 382 * *
dreschpe 8:65a4de035c3c 383 */
dreschpe 8:65a4de035c3c 384 void wr_dat_only(unsigned short dat);
dreschpe 8:65a4de035c3c 385
dreschpe 8:65a4de035c3c 386 /** Read data from the LCD controller
dreschpe 8:65a4de035c3c 387 *
dreschpe 8:65a4de035c3c 388 * @returns data from LCD controller
dreschpe 8:65a4de035c3c 389 *
dreschpe 8:65a4de035c3c 390 */
dreschpe 8:65a4de035c3c 391 unsigned short rd_dat(void);
dreschpe 8:65a4de035c3c 392
dreschpe 8:65a4de035c3c 393 /** Write a value to the to a LCD register
dreschpe 8:65a4de035c3c 394 *
dreschpe 8:65a4de035c3c 395 * @param reg register to be written
dreschpe 8:65a4de035c3c 396 * @param val data to be written
dreschpe 8:65a4de035c3c 397 */
dreschpe 8:65a4de035c3c 398 void wr_reg (unsigned char reg, unsigned char val);
dreschpe 8:65a4de035c3c 399
dreschpe 8:65a4de035c3c 400 /** Read a LCD register
dreschpe 8:65a4de035c3c 401 *
dreschpe 8:65a4de035c3c 402 * @param reg register to be read
dreschpe 8:65a4de035c3c 403 * @returns value of the register
dreschpe 8:65a4de035c3c 404 */
dreschpe 8:65a4de035c3c 405 unsigned short rd_reg (unsigned char reg);
dreschpe 8:65a4de035c3c 406
dreschpe 8:65a4de035c3c 407 unsigned char spi_port;
dreschpe 8:65a4de035c3c 408 unsigned int orientation;
dreschpe 8:65a4de035c3c 409 unsigned int char_x;
dreschpe 8:65a4de035c3c 410 unsigned int char_y;
dreschpe 8:65a4de035c3c 411
dreschpe 8:65a4de035c3c 412
dreschpe 8:65a4de035c3c 413 };
dreschpe 8:65a4de035c3c 414
dreschpe 8:65a4de035c3c 415 #endif