Creating a project for TT_Mxx
LCD/LCD_HX8347/HX8347.h@2:e8d138dfbebc, 2019-03-22 (annotated)
- Committer:
- ThunderSoft
- Date:
- Fri Mar 22 06:05:15 2019 +0000
- Revision:
- 2:e8d138dfbebc
- Parent:
- 0:7f36c2de1de6
Update LCD code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ThunderSoft | 0:7f36c2de1de6 | 1 | /********************************************************************************************** |
ThunderSoft | 0:7f36c2de1de6 | 2 | Copyright (c) 2014 DisplayModule. All rights reserved. |
ThunderSoft | 0:7f36c2de1de6 | 3 | |
ThunderSoft | 0:7f36c2de1de6 | 4 | Redistribution and use of this source code, part of this source code or any compiled binary |
ThunderSoft | 0:7f36c2de1de6 | 5 | based on this source code is permitted as long as the above copyright notice and following |
ThunderSoft | 0:7f36c2de1de6 | 6 | disclaimer is retained. |
ThunderSoft | 0:7f36c2de1de6 | 7 | |
ThunderSoft | 0:7f36c2de1de6 | 8 | DISCLAIMER: |
ThunderSoft | 0:7f36c2de1de6 | 9 | THIS SOFTWARE IS SUPPLIED "AS IS" WITHOUT ANY WARRANTIES AND SUPPORT. DISPLAYMODULE ASSUMES |
ThunderSoft | 0:7f36c2de1de6 | 10 | NO RESPONSIBILITY OR LIABILITY FOR THE USE OF THE SOFTWARE. |
ThunderSoft | 0:7f36c2de1de6 | 11 | ********************************************************************************************/ |
ThunderSoft | 0:7f36c2de1de6 | 12 | |
ThunderSoft | 0:7f36c2de1de6 | 13 | #ifndef HX8347_h |
ThunderSoft | 0:7f36c2de1de6 | 14 | #define HX8347_h |
ThunderSoft | 0:7f36c2de1de6 | 15 | |
ThunderSoft | 0:7f36c2de1de6 | 16 | #include "GraphicsDisplay.h" |
ThunderSoft | 0:7f36c2de1de6 | 17 | #include "dm_platform.h" |
ThunderSoft | 0:7f36c2de1de6 | 18 | |
ThunderSoft | 0:7f36c2de1de6 | 19 | |
ThunderSoft | 0:7f36c2de1de6 | 20 | //Other Colors |
ThunderSoft | 0:7f36c2de1de6 | 21 | #define CYAN 0x07ff |
ThunderSoft | 0:7f36c2de1de6 | 22 | #define BRIGHT_RED 0xf810 |
ThunderSoft | 0:7f36c2de1de6 | 23 | #define GRAY1 0x8410 |
ThunderSoft | 0:7f36c2de1de6 | 24 | #define GRAY2 0x4208 |
ThunderSoft | 0:7f36c2de1de6 | 25 | |
ThunderSoft | 0:7f36c2de1de6 | 26 | class HX8347 : public GraphicsDisplay |
ThunderSoft | 0:7f36c2de1de6 | 27 | { |
ThunderSoft | 0:7f36c2de1de6 | 28 | public: |
ThunderSoft | 0:7f36c2de1de6 | 29 | HX8347(PinName cs, PinName dc, PinName mosi, PinName miso, PinName clk,PinName bl); |
ThunderSoft | 0:7f36c2de1de6 | 30 | HX8347(PinName cs, PinName dc, PinName mosi, PinName miso, PinName clk); |
ThunderSoft | 0:7f36c2de1de6 | 31 | virtual ~HX8347(); |
ThunderSoft | 0:7f36c2de1de6 | 32 | virtual void init(void); |
ThunderSoft | 0:7f36c2de1de6 | 33 | |
ThunderSoft | 0:7f36c2de1de6 | 34 | /** |
ThunderSoft | 0:7f36c2de1de6 | 35 | * @brief Analize the device whether connect. |
ThunderSoft | 0:7f36c2de1de6 | 36 | * @return [true] connect [false] disconnect |
ThunderSoft | 0:7f36c2de1de6 | 37 | */ |
ThunderSoft | 0:7f36c2de1de6 | 38 | bool isConnect(); |
ThunderSoft | 0:7f36c2de1de6 | 39 | |
ThunderSoft | 0:7f36c2de1de6 | 40 | void drawChar(uint16_t x, uint16_t y, char c, uint16_t color, uint8_t size); |
ThunderSoft | 0:7f36c2de1de6 | 41 | |
ThunderSoft | 0:7f36c2de1de6 | 42 | void clearScreen(uint16_t color = BLACK); |
ThunderSoft | 0:7f36c2de1de6 | 43 | |
ThunderSoft | 0:7f36c2de1de6 | 44 | void drawchar(int x,int y,int value,int color = WHITE); |
ThunderSoft | 0:7f36c2de1de6 | 45 | |
ThunderSoft | 0:7f36c2de1de6 | 46 | void drawString(uint16_t x, uint16_t y, const char *p,int color = WHITE); |
ThunderSoft | 0:7f36c2de1de6 | 47 | |
ThunderSoft | 0:7f36c2de1de6 | 48 | void clearScreenArea(int x,int y,int color); |
ThunderSoft | 0:7f36c2de1de6 | 49 | |
ThunderSoft | 0:7f36c2de1de6 | 50 | /** |
ThunderSoft | 0:7f36c2de1de6 | 51 | * @brief Get device's id. |
ThunderSoft | 0:7f36c2de1de6 | 52 | * @return [device id] |
ThunderSoft | 0:7f36c2de1de6 | 53 | */ |
ThunderSoft | 0:7f36c2de1de6 | 54 | uint8_t getDeviceID(); |
ThunderSoft | 0:7f36c2de1de6 | 55 | private: |
ThunderSoft | 0:7f36c2de1de6 | 56 | void send8BitData(uint8_t data); |
ThunderSoft | 0:7f36c2de1de6 | 57 | void writeBus(uint8_t data); |
ThunderSoft | 0:7f36c2de1de6 | 58 | |
ThunderSoft | 0:7f36c2de1de6 | 59 | virtual void pixel(int x, int y, int colour); |
ThunderSoft | 0:7f36c2de1de6 | 60 | virtual int width(); |
ThunderSoft | 0:7f36c2de1de6 | 61 | virtual int height(); |
ThunderSoft | 0:7f36c2de1de6 | 62 | virtual void window(unsigned int x,unsigned int y,unsigned int w,unsigned int h); |
ThunderSoft | 0:7f36c2de1de6 | 63 | |
ThunderSoft | 0:7f36c2de1de6 | 64 | |
ThunderSoft | 0:7f36c2de1de6 | 65 | virtual void setAddress(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1); |
ThunderSoft | 0:7f36c2de1de6 | 66 | virtual void sendCommand(uint8_t index); |
ThunderSoft | 0:7f36c2de1de6 | 67 | virtual void sendData(uint16_t data); |
ThunderSoft | 0:7f36c2de1de6 | 68 | |
ThunderSoft | 0:7f36c2de1de6 | 69 | /** |
ThunderSoft | 0:7f36c2de1de6 | 70 | * @brief Read register's address value. |
ThunderSoft | 0:7f36c2de1de6 | 71 | * @param address [the register value] |
ThunderSoft | 0:7f36c2de1de6 | 72 | * @return [register's address value] |
ThunderSoft | 0:7f36c2de1de6 | 73 | */ |
ThunderSoft | 0:7f36c2de1de6 | 74 | uint8_t read8BitData(uint8_t address); |
ThunderSoft | 0:7f36c2de1de6 | 75 | |
ThunderSoft | 0:7f36c2de1de6 | 76 | void wr_reg(uint8_t address,uint8_t value); |
ThunderSoft | 0:7f36c2de1de6 | 77 | |
ThunderSoft | 0:7f36c2de1de6 | 78 | static const uint16_t _width; |
ThunderSoft | 0:7f36c2de1de6 | 79 | static const uint16_t _height; |
ThunderSoft | 0:7f36c2de1de6 | 80 | |
ThunderSoft | 0:7f36c2de1de6 | 81 | PinName _cs, _dc,_bl; |
ThunderSoft | 0:7f36c2de1de6 | 82 | DigitalOut *_pinDC; |
ThunderSoft | 0:7f36c2de1de6 | 83 | DigitalOut* _pinCS; |
ThunderSoft | 0:7f36c2de1de6 | 84 | DigitalOut *_pinBL; |
ThunderSoft | 0:7f36c2de1de6 | 85 | uint8_t _bitmaskCS; |
ThunderSoft | 0:7f36c2de1de6 | 86 | SPI spi; |
ThunderSoft | 0:7f36c2de1de6 | 87 | |
ThunderSoft | 0:7f36c2de1de6 | 88 | }; |
ThunderSoft | 0:7f36c2de1de6 | 89 | |
ThunderSoft | 0:7f36c2de1de6 | 90 | typedef HX8347 DmTftIli9341; |
ThunderSoft | 0:7f36c2de1de6 | 91 | typedef HX8347 LCD; |
ThunderSoft | 0:7f36c2de1de6 | 92 | |
ThunderSoft | 0:7f36c2de1de6 | 93 | #endif |
ThunderSoft | 0:7f36c2de1de6 | 94 | |
ThunderSoft | 0:7f36c2de1de6 | 95 | |
ThunderSoft | 0:7f36c2de1de6 | 96 | |
ThunderSoft | 0:7f36c2de1de6 | 97 |