Caiou
Dependents: LCD_Proj LCD_imagetest LCD_Proj_rtc
Fork of DmTftLibrary by
DmTouch.h@3:02c19cbc707c, 2014-05-21 (annotated)
- Committer:
- displaymodule
- Date:
- Wed May 21 14:43:08 2014 +0000
- Revision:
- 3:02c19cbc707c
- Parent:
- 0:d6ff5fa503e8
- Child:
- 7:6cd8c36cbdb3
Fixed bug in Touch.cpp. Added delays in the pulse_* macros to lower the clock frequency in the simulated SPI communication.
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 | |
displaymodule | 0:d6ff5fa503e8 | 13 | #ifndef DM_TOUCH_h |
displaymodule | 0:d6ff5fa503e8 | 14 | #define DM_TOUCH_h |
displaymodule | 0:d6ff5fa503e8 | 15 | |
displaymodule | 0:d6ff5fa503e8 | 16 | #include "dm_platform.h" |
displaymodule | 0:d6ff5fa503e8 | 17 | |
displaymodule | 0:d6ff5fa503e8 | 18 | class DmTouch |
displaymodule | 0:d6ff5fa503e8 | 19 | { |
displaymodule | 0:d6ff5fa503e8 | 20 | public: |
displaymodule | 0:d6ff5fa503e8 | 21 | enum Display { |
displaymodule | 0:d6ff5fa503e8 | 22 | DM_TFT28_103, |
displaymodule | 0:d6ff5fa503e8 | 23 | DM_TFT24_104, |
displaymodule | 0:d6ff5fa503e8 | 24 | DM_TFT28_105, |
displaymodule | 0:d6ff5fa503e8 | 25 | DM_TFT35_107, |
displaymodule | 0:d6ff5fa503e8 | 26 | }; |
displaymodule | 0:d6ff5fa503e8 | 27 | |
displaymodule | 0:d6ff5fa503e8 | 28 | #if defined (DM_TOOLCHAIN_ARDUINO) |
displaymodule | 0:d6ff5fa503e8 | 29 | DmTouch(Display disp, uint8_t cs, int8_t tIrq = -1, uint8_t hardwareSpi = 1, uint8_t clk = -1, uint8_t mosi = -1, uint8_t miso = -1, uint16_t width = 240, uint16_t height = 320); |
displaymodule | 0:d6ff5fa503e8 | 30 | #elif defined (DM_TOOLCHAIN_MBED) |
displaymodule | 0:d6ff5fa503e8 | 31 | DmTouch(Display disp, bool hardwareSPI=true); |
displaymodule | 0:d6ff5fa503e8 | 32 | #endif |
displaymodule | 0:d6ff5fa503e8 | 33 | void init(); |
displaymodule | 0:d6ff5fa503e8 | 34 | void readTouchData(uint16_t& posX, uint16_t& posY, bool& touching); |
displaymodule | 0:d6ff5fa503e8 | 35 | uint8_t isTouched(); |
displaymodule | 0:d6ff5fa503e8 | 36 | private: |
displaymodule | 0:d6ff5fa503e8 | 37 | void spiWrite(uint8_t data); |
displaymodule | 0:d6ff5fa503e8 | 38 | uint8_t spiRead(); |
displaymodule | 0:d6ff5fa503e8 | 39 | uint16_t readData12(uint8_t command); |
displaymodule | 0:d6ff5fa503e8 | 40 | void enableIrq(); |
displaymodule | 0:d6ff5fa503e8 | 41 | |
displaymodule | 0:d6ff5fa503e8 | 42 | uint16_t _width, _height; |
displaymodule | 0:d6ff5fa503e8 | 43 | uint8_t _cs, _clk, _mosi, _miso; |
displaymodule | 0:d6ff5fa503e8 | 44 | uint8_t _irq; |
displaymodule | 0:d6ff5fa503e8 | 45 | |
displaymodule | 0:d6ff5fa503e8 | 46 | int _calibLowX, _calibLowY; |
displaymodule | 0:d6ff5fa503e8 | 47 | float _calibModifierX, _calibModifierY; |
displaymodule | 0:d6ff5fa503e8 | 48 | bool _calibInvertedTouch; |
displaymodule | 0:d6ff5fa503e8 | 49 | bool _hardwareSpi; |
displaymodule | 0:d6ff5fa503e8 | 50 | |
displaymodule | 0:d6ff5fa503e8 | 51 | #if defined (DM_TOOLCHAIN_ARDUINO) |
displaymodule | 0:d6ff5fa503e8 | 52 | regtype *_pinDC, *_pinCS, *_pinCLK, *_pinMOSI, *_pinMISO, *_pinIrq; |
displaymodule | 0:d6ff5fa503e8 | 53 | regsize _bitmaskDC, _bitmaskCS, _bitmaskCLK, _bitmaskMOSI, _bitmaskMISO, _bitmaskIrq; |
displaymodule | 0:d6ff5fa503e8 | 54 | uint8_t _spiSettings; |
displaymodule | 0:d6ff5fa503e8 | 55 | #elif defined (DM_TOOLCHAIN_MBED) |
displaymodule | 3:02c19cbc707c | 56 | DigitalOut *_pinDC, *_pinCS, *_pinCLK, *_pinMOSI, *_led; |
displaymodule | 3:02c19cbc707c | 57 | DigitalIn *_pinIrq, *_pinMISO; |
displaymodule | 0:d6ff5fa503e8 | 58 | SPI *_spi; |
displaymodule | 0:d6ff5fa503e8 | 59 | #endif |
displaymodule | 0:d6ff5fa503e8 | 60 | |
displaymodule | 0:d6ff5fa503e8 | 61 | }; |
displaymodule | 0:d6ff5fa503e8 | 62 | #endif |
displaymodule | 0:d6ff5fa503e8 | 63 | |
displaymodule | 0:d6ff5fa503e8 | 64 | |
displaymodule | 0:d6ff5fa503e8 | 65 | |
displaymodule | 0:d6ff5fa503e8 | 66 |