Added Discovery F429ZI 8 bit SPI support. Added helper methods to character based locate.
Fork of SPI_TFT_ILI9341 by
Added Discovery F429ZI 8 bit SPI support to the original lib.
Revision 15:b7848705d2ab, committed 2017-02-12
- Comitter:
- vargham
- Date:
- Sun Feb 12 10:34:05 2017 +0000
- Parent:
- 14:a1133923c034
- Commit message:
- Added text align modes (left, center, right) when used with monospaced font.
Changed in this revision
SPI_TFT_ILI9341.cpp | Show annotated file Show diff for this revision Revisions of this file |
SPI_TFT_ILI9341.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r a1133923c034 -r b7848705d2ab SPI_TFT_ILI9341.cpp --- a/SPI_TFT_ILI9341.cpp Sat Feb 11 18:56:31 2017 +0000 +++ b/SPI_TFT_ILI9341.cpp Sun Feb 12 10:34:05 2017 +0000 @@ -804,9 +804,22 @@ return(1); } -void SPI_TFT_ILI9341::locateChar(uint16_t row, uint16_t column) +void SPI_TFT_ILI9341::locateChar(uint16_t row, uint16_t column, Text_AlignModeTypdef mode, uint16_t textLength) { - locate(getCharLeft(column), getCharTop(row)); + uint16_t x = 0; + switch (mode) + { + case LEFT_MODE: + x = getCharLeft(column); + break; + case CENTER_MODE: + x = (width() / 2) - ((textLength + 1) * font[FONT_WIDTH_INDEX]) / 2; + break; + case RIGHT_MODE: + x = width() - textLength * font[FONT_WIDTH_INDEX]; + break; + } + locate(x, getCharTop(row)); } uint16_t SPI_TFT_ILI9341::getCharLeft(uint16_t column) @@ -829,5 +842,9 @@ return font[FONT_WIDTH_INDEX] * (column + 1) - 1; } +void SPI_TFT_ILI9341::ClearStringLine(uint16_t row) +{ + fillrect(0, getCharTop(row), width(), getCharBottom(row), _background); +} + #endif -
diff -r a1133923c034 -r b7848705d2ab SPI_TFT_ILI9341.h --- a/SPI_TFT_ILI9341.h Sat Feb 11 18:56:31 2017 +0000 +++ b/SPI_TFT_ILI9341.h Sun Feb 12 10:34:05 2017 +0000 @@ -42,11 +42,48 @@ #define Orange 0xFD20 /* 255, 165, 0 */ #define GreenYellow 0xAFE5 /* 173, 255, 47 */ +#define LCD_COLOR_BLUE Blue +#define LCD_COLOR_GREEN Green +#define LCD_COLOR_RED Red +#define LCD_COLOR_CYAN Cyan +#define LCD_COLOR_MAGENTA Magenta +#define LCD_COLOR_YELLOW Yellow +//#define LCD_COLOR_LIGHTBLUE 0xFF8080FF +//#define LCD_COLOR_LIGHTGREEN 0xFF80FF80 +//#define LCD_COLOR_LIGHTRED 0xFFFF8080 +//#define LCD_COLOR_LIGHTCYAN 0xFF80FFFF +//#define LCD_COLOR_LIGHTMAGENTA 0xFFFF80FF +//#define LCD_COLOR_LIGHTYELLOW 0xFFFFFF80 +//#define LCD_COLOR_DARKBLUE 0xFF000080 +#define LCD_COLOR_DARKGREEN DarkGreen +#define LCD_COLOR_DARKRED RGB(0x80, 0x0, 0x0) +#define LCD_COLOR_DARKCYAN DarkCyan +//#define LCD_COLOR_DARKMAGENTA 0xFF800080 +//#define LCD_COLOR_DARKYELLOW 0xFF808000 +#define LCD_COLOR_WHITE White +#define LCD_COLOR_LIGHTGRAY LightGrey +//#define LCD_COLOR_GRAY 0xFF808080 +#define LCD_COLOR_DARKGRAY DarkGrey +#define LCD_COLOR_BLACK Black +//#define LCD_COLOR_BROWN 0xFFA52A2A +#define LCD_COLOR_ORANGE Orange +#define LCD_COLOR_TRANSPARENT 0xFF000000 + #define FONT_OFFSET_INDEX 0 #define FONT_WIDTH_INDEX 1 #define FONT_HEIGHT_INDEX 2 #define FONT_BSP_INDEX 3 +/** + * @brief Line mode structures definition + */ +enum Text_AlignModeTypdef +{ + CENTER_MODE = 0x01, /* center mode */ + RIGHT_MODE = 0x02, /* right mode */ + LEFT_MODE = 0x03, /* left mode */ +}; + /** Display control class, based on GraphicsDisplay and TextDisplay * * Example: @@ -287,7 +324,7 @@ * @param row * @param column */ - void locateChar(uint16_t row, uint16_t column); + void locateChar(uint16_t row, uint16_t column, Text_AlignModeTypdef mode = LEFT_MODE, uint16_t textLength = 1); /** Calculates character's left coordinate in pixels. * @@ -321,6 +358,8 @@ */ uint16_t getCharRight(uint16_t column); + void ClearStringLine(uint16_t row); + DigitalOut _cs; DigitalOut _reset; DigitalOut _dc; @@ -452,4 +491,3 @@ }; #endif -