Driver Library with inverted screen and increased SPI speed (16MHz). You need to use this library with the sx1280

Dependents:   MSNV2-Terminal_V1-6 SX1280DevKit SX126xDevKit SX126xDevKit ... more

Fork of DmTftLibrary by Display Module

Committer:
displaymodule
Date:
Mon Jul 07 10:38:09 2014 +0000
Revision:
8:b24f01d148c4
Parent:
7:6cd8c36cbdb3
Child:
10:d263094e666d
Removed dependency on the T_IRQ pin.

Who changed what in which revision?

UserRevisionLine numberNew 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 7:6cd8c36cbdb3 18 typedef struct calibrationMatrix {
displaymodule 7:6cd8c36cbdb3 19 int32_t a, b, c, d, e, f;
displaymodule 7:6cd8c36cbdb3 20 } CalibrationMatrix;
displaymodule 7:6cd8c36cbdb3 21
displaymodule 0:d6ff5fa503e8 22 class DmTouch
displaymodule 0:d6ff5fa503e8 23 {
displaymodule 0:d6ff5fa503e8 24 public:
displaymodule 0:d6ff5fa503e8 25 enum Display {
displaymodule 7:6cd8c36cbdb3 26 DM_TFT28_103 = 103,
displaymodule 7:6cd8c36cbdb3 27 DM_TFT24_104 = 104,
displaymodule 7:6cd8c36cbdb3 28 DM_TFT28_105 = 105,
displaymodule 7:6cd8c36cbdb3 29 DM_TFT35_107 = 107
displaymodule 7:6cd8c36cbdb3 30 };
displaymodule 7:6cd8c36cbdb3 31
displaymodule 7:6cd8c36cbdb3 32 enum SpiMode {
displaymodule 7:6cd8c36cbdb3 33 Auto,
displaymodule 7:6cd8c36cbdb3 34 Software,
displaymodule 7:6cd8c36cbdb3 35 Hardware
displaymodule 0:d6ff5fa503e8 36 };
displaymodule 0:d6ff5fa503e8 37
displaymodule 0:d6ff5fa503e8 38 #if defined (DM_TOOLCHAIN_ARDUINO)
displaymodule 7:6cd8c36cbdb3 39 DmTouch(Display disp, SpiMode spiMode=Auto, bool useIrq=true);
displaymodule 0:d6ff5fa503e8 40 #elif defined (DM_TOOLCHAIN_MBED)
displaymodule 7:6cd8c36cbdb3 41 DmTouch(Display disp, SpiMode spiMode=Hardware);
displaymodule 0:d6ff5fa503e8 42 #endif
displaymodule 0:d6ff5fa503e8 43 void init();
displaymodule 0:d6ff5fa503e8 44 void readTouchData(uint16_t& posX, uint16_t& posY, bool& touching);
displaymodule 7:6cd8c36cbdb3 45 bool isTouched();
displaymodule 7:6cd8c36cbdb3 46 bool getMiddleXY(uint16_t &x, uint16_t &y); // Raw Touch Data, used for calibration
displaymodule 7:6cd8c36cbdb3 47 void setCalibrationMatrix(CalibrationMatrix calibrationMatrix);
displaymodule 7:6cd8c36cbdb3 48 void setPrecison(uint8_t samplesPerMeasurement);
displaymodule 7:6cd8c36cbdb3 49 void waitForTouch();
displaymodule 7:6cd8c36cbdb3 50 void waitForTouchRelease();
displaymodule 7:6cd8c36cbdb3 51 uint32_t rescaleFactor() { return 1000000; };
displaymodule 7:6cd8c36cbdb3 52
displaymodule 0:d6ff5fa503e8 53 private:
displaymodule 0:d6ff5fa503e8 54 void spiWrite(uint8_t data);
displaymodule 0:d6ff5fa503e8 55 uint8_t spiRead();
displaymodule 0:d6ff5fa503e8 56 uint16_t readData12(uint8_t command);
displaymodule 0:d6ff5fa503e8 57 void enableIrq();
displaymodule 7:6cd8c36cbdb3 58 void readRawData(uint16_t &x, uint16_t &y);
displaymodule 7:6cd8c36cbdb3 59 void getAverageXY(uint16_t &x, uint16_t &y);
displaymodule 7:6cd8c36cbdb3 60 uint16_t getDisplayCoordinateX(uint16_t x_touch, uint16_t y_touch);
displaymodule 7:6cd8c36cbdb3 61 uint16_t getDisplayCoordinateY(uint16_t x_touch, uint16_t y_touch);
displaymodule 7:6cd8c36cbdb3 62 uint16_t calculateMiddleValue(uint16_t values[], uint8_t count);
displaymodule 7:6cd8c36cbdb3 63 bool isSampleValid();
displaymodule 0:d6ff5fa503e8 64
displaymodule 0:d6ff5fa503e8 65 bool _hardwareSpi;
displaymodule 7:6cd8c36cbdb3 66 uint8_t _samplesPerMeasurement;
displaymodule 7:6cd8c36cbdb3 67 CalibrationMatrix _calibrationMatrix;
displaymodule 7:6cd8c36cbdb3 68 uint8_t _cs, _clk, _mosi, _miso;
displaymodule 7:6cd8c36cbdb3 69 int8_t _irq;
displaymodule 0:d6ff5fa503e8 70
displaymodule 0:d6ff5fa503e8 71 #if defined (DM_TOOLCHAIN_ARDUINO)
displaymodule 0:d6ff5fa503e8 72 regtype *_pinDC, *_pinCS, *_pinCLK, *_pinMOSI, *_pinMISO, *_pinIrq;
displaymodule 0:d6ff5fa503e8 73 regsize _bitmaskDC, _bitmaskCS, _bitmaskCLK, _bitmaskMOSI, _bitmaskMISO, _bitmaskIrq;
displaymodule 0:d6ff5fa503e8 74 uint8_t _spiSettings;
displaymodule 0:d6ff5fa503e8 75 #elif defined (DM_TOOLCHAIN_MBED)
displaymodule 3:02c19cbc707c 76 DigitalOut *_pinDC, *_pinCS, *_pinCLK, *_pinMOSI, *_led;
displaymodule 8:b24f01d148c4 77 DigitalIn *_pinMISO;
displaymodule 0:d6ff5fa503e8 78 SPI *_spi;
displaymodule 0:d6ff5fa503e8 79 #endif
displaymodule 0:d6ff5fa503e8 80
displaymodule 0:d6ff5fa503e8 81 };
displaymodule 0:d6ff5fa503e8 82 #endif