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
GraphicsDisplay.h@27:8360ab3c19d6, 2021-03-30 (annotated)
- Committer:
- John Durrell
- Date:
- Tue Mar 30 20:38:26 2021 +0100
- Revision:
- 27:8360ab3c19d6
- Parent:
- 11:9bb71766cafc
Sorting
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dreschpe | 0:de9d1462a835 | 1 | /* mbed GraphicsDisplay Display Library Base Class |
dreschpe | 0:de9d1462a835 | 2 | * Copyright (c) 2007-2009 sford |
dreschpe | 0:de9d1462a835 | 3 | * Released under the MIT License: http://mbed.org/license/mit |
dreschpe | 0:de9d1462a835 | 4 | * |
dreschpe | 0:de9d1462a835 | 5 | * A library for providing a common base class for Graphics displays |
dreschpe | 0:de9d1462a835 | 6 | * To port a new display, derive from this class and implement |
dreschpe | 0:de9d1462a835 | 7 | * the constructor (setup the display), pixel (put a pixel |
dreschpe | 0:de9d1462a835 | 8 | * at a location), width and height functions. Everything else |
dreschpe | 0:de9d1462a835 | 9 | * (locate, printf, putc, cls, window, putp, fill, blit, blitbit) |
dreschpe | 0:de9d1462a835 | 10 | * will come for free. You can also provide a specialised implementation |
dreschpe | 0:de9d1462a835 | 11 | * of window and putp to speed up the results |
dreschpe | 0:de9d1462a835 | 12 | */ |
dreschpe | 0:de9d1462a835 | 13 | |
dreschpe | 0:de9d1462a835 | 14 | #ifndef MBED_GRAPHICSDISPLAY_H |
dreschpe | 0:de9d1462a835 | 15 | #define MBED_GRAPHICSDISPLAY_H |
dreschpe | 0:de9d1462a835 | 16 | |
dreschpe | 0:de9d1462a835 | 17 | #include "TextDisplay.h" |
dreschpe | 0:de9d1462a835 | 18 | |
dreschpe | 0:de9d1462a835 | 19 | class GraphicsDisplay : public TextDisplay { |
dreschpe | 0:de9d1462a835 | 20 | |
dreschpe | 0:de9d1462a835 | 21 | public: |
dreschpe | 0:de9d1462a835 | 22 | |
dreschpe | 0:de9d1462a835 | 23 | GraphicsDisplay(const char* name); |
dreschpe | 0:de9d1462a835 | 24 | |
dreschpe | 0:de9d1462a835 | 25 | virtual void pixel(int x, int y, int colour) = 0; |
dreschpe | 0:de9d1462a835 | 26 | virtual int width() = 0; |
dreschpe | 0:de9d1462a835 | 27 | virtual int height() = 0; |
dreschpe | 0:de9d1462a835 | 28 | |
dreschpe | 11:9bb71766cafc | 29 | virtual void window(unsigned int x,unsigned int y,unsigned int w,unsigned int h); |
dreschpe | 0:de9d1462a835 | 30 | virtual void putp(int colour); |
dreschpe | 0:de9d1462a835 | 31 | |
dreschpe | 0:de9d1462a835 | 32 | virtual void cls(); |
dreschpe | 0:de9d1462a835 | 33 | virtual void fill(int x, int y, int w, int h, int colour); |
dreschpe | 0:de9d1462a835 | 34 | virtual void blit(int x, int y, int w, int h, const int *colour); |
dreschpe | 0:de9d1462a835 | 35 | virtual void blitbit(int x, int y, int w, int h, const char* colour); |
dreschpe | 0:de9d1462a835 | 36 | |
dreschpe | 0:de9d1462a835 | 37 | virtual void character(int column, int row, int value); |
dreschpe | 0:de9d1462a835 | 38 | virtual int columns(); |
dreschpe | 0:de9d1462a835 | 39 | virtual int rows(); |
dreschpe | 0:de9d1462a835 | 40 | |
dreschpe | 0:de9d1462a835 | 41 | protected: |
dreschpe | 0:de9d1462a835 | 42 | |
dreschpe | 0:de9d1462a835 | 43 | // pixel location |
dreschpe | 0:de9d1462a835 | 44 | short _x; |
dreschpe | 0:de9d1462a835 | 45 | short _y; |
dreschpe | 0:de9d1462a835 | 46 | |
dreschpe | 0:de9d1462a835 | 47 | // window location |
dreschpe | 0:de9d1462a835 | 48 | short _x1; |
dreschpe | 0:de9d1462a835 | 49 | short _x2; |
dreschpe | 0:de9d1462a835 | 50 | short _y1; |
dreschpe | 0:de9d1462a835 | 51 | short _y2; |
dreschpe | 0:de9d1462a835 | 52 | |
dreschpe | 0:de9d1462a835 | 53 | }; |
dreschpe | 0:de9d1462a835 | 54 | |
dreschpe | 0:de9d1462a835 | 55 | #endif |