Driver Library for our displays
Dependents: dm_bubbles dm_calc dm_paint dm_sdcard_with_adapter ... more
Revision 10:d263094e666d, committed 2014-07-09
- Comitter:
- displaymodule
- Date:
- Wed Jul 09 08:31:34 2014 +0000
- Parent:
- 9:bac5439e3c1c
- Child:
- 11:264e19992620
- Commit message:
- Added better out-of-bounds checks for touch. If the coordinate is outside the display area then it is considered as not touching.
Changed in this revision
DmTouch.cpp | Show annotated file Show diff for this revision Revisions of this file |
DmTouch.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/DmTouch.cpp Mon Jul 07 13:30:33 2014 +0000 +++ b/DmTouch.cpp Wed Jul 09 08:31:34 2014 +0000 @@ -28,6 +28,7 @@ DmTouch::DmTouch(Display disp, SpiMode spiMode) #endif { + _disp = disp; switch (disp) { // Display with 40-pin connector on top of adapter board case DmTouch::DM_TFT28_103: @@ -37,6 +38,8 @@ _clk = A1; _mosi = A0; _miso = D9; + _width = 240; + _height = 320; _hardwareSpi = false; break; @@ -46,6 +49,8 @@ _clk = D13; _mosi = D11; _miso = D12; + _width = 240; + _height = 320; _hardwareSpi = true; break; @@ -56,6 +61,8 @@ _clk = D13; _mosi = D11; _miso = D12; + _width = 320; + _height = 240; _hardwareSpi = true; break; } @@ -250,7 +257,7 @@ #if defined (DM_TOOLCHAIN_ARDUINO) touching = isTouched(); #elif defined (DM_TOOLCHAIN_MBED) - touching = (posX < 4096 && posY < 4096); + touching = (posX < _width && posY < _height); #endif }
--- a/DmTouch.h Mon Jul 07 13:30:33 2014 +0000 +++ b/DmTouch.h Wed Jul 09 08:31:34 2014 +0000 @@ -49,6 +49,7 @@ void waitForTouch(); void waitForTouchRelease(); uint32_t rescaleFactor() { return 1000000; }; + Display getDisplay() { return _disp; }; private: void spiWrite(uint8_t data); @@ -62,6 +63,8 @@ uint16_t calculateMiddleValue(uint16_t values[], uint8_t count); bool isSampleValid(); + Display _disp; + uint16_t _width, _height; bool _hardwareSpi; uint8_t _samplesPerMeasurement; CalibrationMatrix _calibrationMatrix;