Uses the same fonts as the SPI_TFT_ILI9341 Library (I have many, and a html/php font editor for that)
Diff: SPI_TFT_ILI9225.h
- Revision:
- 13:9e6589dc8864
- Parent:
- 10:a640680b5309
- Child:
- 14:a7640e7e9f80
--- a/SPI_TFT_ILI9225.h Wed Nov 23 12:56:39 2016 +0000 +++ b/SPI_TFT_ILI9225.h Wed Nov 23 13:30:20 2016 +0000 @@ -103,7 +103,8 @@ #define COLOR_YELLOW RGB888_RGB565(0xFFFF00u) /// Main and core class -class TFT_22_ILI9225 : public Stream { +class TFT_22_ILI9225 : public Stream +{ public: @@ -112,11 +113,6 @@ */ TFT_22_ILI9225(PinName sdi, PinName clk, PinName cs, PinName rs, PinName rst, PinName led, const char *name); - /** Claim standard output - * - */ - virtual bool claim (FILE *stream); - /** Initialization * */ @@ -183,51 +179,6 @@ */ uint8_t getOrientation(void); - /** Font size, x-axis - * - * @return horizontal size of current font, in pixels - * - */ - uint8_t fontX(void); - - /** Font size, y-axis - * - * @return vertical size of current font, in pixels - * - */ - uint8_t fontY(void); - - /** Screen size, x-axis - * - * @return horizontal size of the screen, in pixels - * @note 219 means 0..219 coordinates (decimal) - * - */ - uint16_t maxX(void); - - /** Screen size, x-axis - * - * @return horizontal size of the screen, in pixels - * @note 220 means 220 pixels and thus 0..219 coordinates (decimal) - * - */ - uint16_t width(void); - - /** Screen size, y-axis - * - * @return vertical size of the screen, in pixels - * @note 175 means 0..175 coordinates (decimal) - * - */ - uint16_t maxY(void); - - /** Screen size, y-axis - * - * @return vertical size of the screen, in pixels - * @note 176 means 176 pixels and thus 0..175 coordinates (decimal) - * - */ - uint16_t height(void); // Graphics functions @@ -352,6 +303,38 @@ */ void roundrect(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t rad, bool fill, uint16_t color); + /** Screen size, x-axis + * + * @return horizontal size of the screen, in pixels + * @note 219 means 0..219 coordinates (decimal) + * + */ + uint16_t maxX(void); + + /** Screen size, y-axis + * + * @return vertical size of the screen, in pixels + * @note 175 means 0..175 coordinates (decimal) + * + */ + uint16_t maxY(void); + + /** Screen size, x-axis + * + * @return horizontal size of the screen, in pixels + * @note 220 means 220 pixels and thus 0..219 coordinates (decimal) + * + */ + uint16_t width(void); + + /** Screen size, y-axis + * + * @return vertical size of the screen, in pixels + * @note 176 means 176 pixels and thus 0..175 coordinates (decimal) + * + */ + uint16_t height(void); + /** Calculate 16-bit color from 8-bit Red-Green-Blue components * * @param red red component, 0x00..0xff @@ -372,6 +355,9 @@ */ void splitColor(uint16_t rgb, uint8_t &red, uint8_t &green, uint8_t &blue); + + // Text functions + /** Set current font * * @param font Font name @@ -379,6 +365,20 @@ */ void setFont(uint8_t* font); + /** Font size, x-axis + * + * @return horizontal size of current font, in pixels + * + */ + uint8_t fontX(void); + + /** Font size, y-axis + * + * @return vertical size of current font, in pixels + * + */ + uint8_t fontY(void); + /** put a char on the screen * * @param value char to print @@ -462,21 +462,42 @@ */ void unicode2ascii(char *uni_str, char *ascii_str); -void window (unsigned int x, unsigned int y, unsigned int w, unsigned int h); + /** Claim standard output + * + */ + virtual bool claim (FILE *stream); private: - SPI spi; + + SPI _spi; + DigitalOut _rst; + DigitalOut _rs; + DigitalOut _cs; + PwmOut _led; + + float _brightness; + uint16_t _entryMode; + uint16_t _maxX, _maxY; + uint8_t _orientation; + + // for claim + uint16_t _column; + uint16_t _row; + char *_path; unsigned char* font; unsigned int char_x; unsigned int char_y; unsigned int char_line_spacing; - // colours + // colors uint16_t _foreground; uint16_t _background; + + // Private functions + /** Swap two values * * @param a b @@ -485,11 +506,6 @@ */ void _swap(uint16_t &a, uint16_t &b); - /** Maximize window to entire screen - * - */ - void _setWindowMax(void); - /** Set window * * @param x0 @@ -500,6 +516,11 @@ */ void _setWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1); + /** Maximize window to entire screen + * + */ + void _setWindowMax(void); + /** Set coordinates * * @param x @@ -516,23 +537,6 @@ */ void _writeRegister(uint16_t reg, uint16_t data); - /** Start writing data - * - */ - void _startData(void); - - /** End writing data - * - */ - void _endData(void); - - /** Write data - * - * @param uint16_t data - * - */ - void _writeData(uint16_t data); - /** Write a command * * @param HI @@ -541,32 +545,32 @@ */ void _writeCommand(uint8_t HI, uint8_t LO); - float _brightness; - - uint16_t _entryMode; - - uint16_t _maxX, _maxY; + /** Start writing data + * + */ + void _startData(void); - DigitalOut _rst; - DigitalOut _rs; - DigitalOut _cs; - - uint8_t _orientation; + /** Write data + * + * @param uint16_t data + * + */ + void _writeData(uint16_t data); - PwmOut _led; + /** End writing data + * + */ + void _endData(void); - // character location - uint16_t _column; - uint16_t _row; - char *_path; protected: + //used by printf - supply a new _putc virtual function for the new device virtual int _putc(int c) { putc(c); //your new LCD put to print an ASCII character on LCD return 0; }; -//assuming no reads from LCD + //assuming no reads from LCD virtual int _getc() { return -1; }