Caiou
Dependents: LCD_Proj LCD_imagetest LCD_Proj_rtc
Fork of DmTftLibrary by
DmTftBase.h@17:67d1b918afe2, 2015-12-21 (annotated)
- Committer:
- Nikolas
- Date:
- Mon Dec 21 14:29:20 2015 +0000
- Revision:
- 17:67d1b918afe2
- Parent:
- 11:264e19992620
,jggfjlf;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
displaymodule | 0:d6ff5fa503e8 | 1 | /********************************************************************************************** |
displaymodule | 0:d6ff5fa503e8 | 2 | Copyright (c) 2014 DisplayModule. All rights reserved. |
displaymodule | 0:d6ff5fa503e8 | 3 | |
displaymodule | 0:d6ff5fa503e8 | 4 | Redistribution and use of this source code, part of this source code or any compiled binary |
displaymodule | 0:d6ff5fa503e8 | 5 | based on this source code is permitted as long as the above copyright notice and following |
displaymodule | 0:d6ff5fa503e8 | 6 | disclaimer is retained. |
displaymodule | 0:d6ff5fa503e8 | 7 | |
displaymodule | 0:d6ff5fa503e8 | 8 | DISCLAIMER: |
displaymodule | 0:d6ff5fa503e8 | 9 | THIS SOFTWARE IS SUPPLIED "AS IS" WITHOUT ANY WARRANTIES AND SUPPORT. DISPLAYMODULE ASSUMES |
displaymodule | 0:d6ff5fa503e8 | 10 | NO RESPONSIBILITY OR LIABILITY FOR THE USE OF THE SOFTWARE. |
displaymodule | 0:d6ff5fa503e8 | 11 | ********************************************************************************************/ |
displaymodule | 0:d6ff5fa503e8 | 12 | #ifndef DMTFTBASE_h |
displaymodule | 0:d6ff5fa503e8 | 13 | #define DMTFTBASE_h |
displaymodule | 0:d6ff5fa503e8 | 14 | |
displaymodule | 0:d6ff5fa503e8 | 15 | #include "dm_platform.h" |
displaymodule | 0:d6ff5fa503e8 | 16 | |
displaymodule | 0:d6ff5fa503e8 | 17 | |
displaymodule | 0:d6ff5fa503e8 | 18 | //Basic Colors |
displaymodule | 0:d6ff5fa503e8 | 19 | #define RED 0xf800 |
displaymodule | 0:d6ff5fa503e8 | 20 | #define GREEN 0x07e0 |
displaymodule | 0:d6ff5fa503e8 | 21 | #define BLUE 0x001f |
displaymodule | 0:d6ff5fa503e8 | 22 | #define BLACK 0x0000 |
displaymodule | 0:d6ff5fa503e8 | 23 | #define YELLOW 0xffe0 |
displaymodule | 0:d6ff5fa503e8 | 24 | #define WHITE 0xffff |
displaymodule | 0:d6ff5fa503e8 | 25 | |
displaymodule | 0:d6ff5fa503e8 | 26 | //Other Colors |
displaymodule | 0:d6ff5fa503e8 | 27 | #define CYAN 0x07ff |
displaymodule | 0:d6ff5fa503e8 | 28 | #define BRIGHT_RED 0xf810 |
displaymodule | 0:d6ff5fa503e8 | 29 | #define GRAY1 0x8410 |
displaymodule | 0:d6ff5fa503e8 | 30 | #define GRAY2 0x4208 |
displaymodule | 0:d6ff5fa503e8 | 31 | |
displaymodule | 0:d6ff5fa503e8 | 32 | |
displaymodule | 0:d6ff5fa503e8 | 33 | class DmTftBase { |
displaymodule | 0:d6ff5fa503e8 | 34 | public: |
displaymodule | 0:d6ff5fa503e8 | 35 | DmTftBase(const uint16_t width, const uint16_t height) : _width(width), _height(height){}; |
displaymodule | 0:d6ff5fa503e8 | 36 | virtual ~DmTftBase() { }; |
displaymodule | 0:d6ff5fa503e8 | 37 | |
embeddedartists | 2:59be7fca4581 | 38 | virtual void init(void) = 0; |
embeddedartists | 2:59be7fca4581 | 39 | |
displaymodule | 0:d6ff5fa503e8 | 40 | uint16_t width() { return _width; } |
displaymodule | 0:d6ff5fa503e8 | 41 | uint16_t height() { return _height; } |
displaymodule | 11:264e19992620 | 42 | void setWidth(uint16_t width) { _width = width; } |
displaymodule | 11:264e19992620 | 43 | void setHeight(uint16_t height) { _height = height; } |
displaymodule | 0:d6ff5fa503e8 | 44 | |
displaymodule | 0:d6ff5fa503e8 | 45 | void setTextColor(uint16_t background, uint16_t foreground) { _bgColor = background; _fgColor = foreground; } |
displaymodule | 0:d6ff5fa503e8 | 46 | |
displaymodule | 0:d6ff5fa503e8 | 47 | virtual void setPixel(uint16_t x, uint16_t y, uint16_t color); |
displaymodule | 0:d6ff5fa503e8 | 48 | virtual void setAddress(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) = 0; |
displaymodule | 0:d6ff5fa503e8 | 49 | virtual void sendData(uint16_t data) = 0; |
displaymodule | 0:d6ff5fa503e8 | 50 | |
displaymodule | 0:d6ff5fa503e8 | 51 | void clearScreen(uint16_t color = BLACK); |
displaymodule | 0:d6ff5fa503e8 | 52 | |
displaymodule | 0:d6ff5fa503e8 | 53 | void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color); |
displaymodule | 0:d6ff5fa503e8 | 54 | void drawVerticalLine(uint16_t x, uint16_t y, uint16_t length, uint16_t color); |
displaymodule | 0:d6ff5fa503e8 | 55 | void drawHorizontalLine(uint16_t x, uint16_t y, uint16_t length, uint16_t color); |
displaymodule | 0:d6ff5fa503e8 | 56 | |
displaymodule | 0:d6ff5fa503e8 | 57 | void drawRectangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color); |
displaymodule | 0:d6ff5fa503e8 | 58 | void fillRectangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color); |
displaymodule | 0:d6ff5fa503e8 | 59 | |
displaymodule | 0:d6ff5fa503e8 | 60 | void drawCircle(uint16_t x0, uint16_t y0, uint16_t r, uint16_t color); |
displaymodule | 0:d6ff5fa503e8 | 61 | void fillCircle(uint16_t x0, uint16_t y0, uint16_t r, uint16_t color); |
displaymodule | 0:d6ff5fa503e8 | 62 | |
displaymodule | 0:d6ff5fa503e8 | 63 | void drawTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color); |
displaymodule | 0:d6ff5fa503e8 | 64 | |
displaymodule | 0:d6ff5fa503e8 | 65 | void drawPoint(uint16_t x, uint16_t y, uint16_t radius=0); |
displaymodule | 0:d6ff5fa503e8 | 66 | |
displaymodule | 0:d6ff5fa503e8 | 67 | void drawChar(uint16_t x, uint16_t y, char ch, bool transparent); |
displaymodule | 0:d6ff5fa503e8 | 68 | void drawNumber(uint16_t x, uint16_t y, int num, int digitsToShow, bool leadingZeros=false); |
displaymodule | 0:d6ff5fa503e8 | 69 | void drawString(uint16_t x, uint16_t y, const char *p); |
displaymodule | 0:d6ff5fa503e8 | 70 | void drawStringCentered(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const char *p); |
displaymodule | 0:d6ff5fa503e8 | 71 | |
displaymodule | 0:d6ff5fa503e8 | 72 | void drawImage(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint16_t* data); |
displaymodule | 0:d6ff5fa503e8 | 73 | |
displaymodule | 0:d6ff5fa503e8 | 74 | void select(); |
displaymodule | 0:d6ff5fa503e8 | 75 | void unSelect(); |
displaymodule | 0:d6ff5fa503e8 | 76 | protected: |
displaymodule | 0:d6ff5fa503e8 | 77 | virtual void sendCommand(uint8_t index) = 0; |
displaymodule | 0:d6ff5fa503e8 | 78 | |
displaymodule | 0:d6ff5fa503e8 | 79 | #if defined (DM_TOOLCHAIN_ARDUINO) |
displaymodule | 0:d6ff5fa503e8 | 80 | regtype *_pinCS; |
displaymodule | 0:d6ff5fa503e8 | 81 | regsize _bitmaskCS; |
displaymodule | 0:d6ff5fa503e8 | 82 | #elif defined (DM_TOOLCHAIN_MBED) |
displaymodule | 0:d6ff5fa503e8 | 83 | DigitalOut* _pinCS; |
displaymodule | 0:d6ff5fa503e8 | 84 | uint8_t _bitmaskCS; |
displaymodule | 0:d6ff5fa503e8 | 85 | #endif |
displaymodule | 0:d6ff5fa503e8 | 86 | |
displaymodule | 0:d6ff5fa503e8 | 87 | private: |
displaymodule | 11:264e19992620 | 88 | uint16_t _width; |
displaymodule | 11:264e19992620 | 89 | uint16_t _height; |
displaymodule | 0:d6ff5fa503e8 | 90 | |
displaymodule | 0:d6ff5fa503e8 | 91 | uint16_t _bgColor; |
displaymodule | 0:d6ff5fa503e8 | 92 | uint16_t _fgColor; |
displaymodule | 0:d6ff5fa503e8 | 93 | }; |
displaymodule | 11:264e19992620 | 94 | #endif |