Driver Library for our displays

Dependents:   dm_bubbles dm_calc dm_paint dm_sdcard_with_adapter ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers DmTpFt6x06.h Source File

DmTpFt6x06.h

00001 /**********************************************************************************************
00002  Copyright (c) 2015 DisplayModule. All rights reserved.
00003 
00004  Redistribution and use of this source code, part of this source code or any compiled binary
00005  based on this source code is permitted as long as the above copyright notice and following
00006  disclaimer is retained.
00007 
00008  DISCLAIMER:
00009  THIS SOFTWARE IS SUPPLIED "AS IS" WITHOUT ANY WARRANTIES AND SUPPORT. DISPLAYMODULE ASSUMES
00010  NO RESPONSIBILITY OR LIABILITY FOR THE USE OF THE SOFTWARE.
00011  ********************************************************************************************/
00012 
00013 #ifndef DM_TPFT6X06_h
00014 #define DM_TPFT6X06_h
00015 
00016 #include "dm_platform.h"
00017 #if defined (DM_TOOLCHAIN_ARDUINO)
00018 #include <Wire.h>
00019 #elif defined (DM_TOOLCHAIN_MBED)
00020 #include "mbed.h"
00021 #endif
00022 
00023 #if defined (DM_TOOLCHAIN_ARDUINO)
00024 #define FT6x06_ADDR                   0x38
00025 #elif defined (DM_TOOLCHAIN_MBED)
00026 #define FT6x06_ADDR                   0x70
00027 #endif
00028 
00029 #define FT6x06_DEV_MODE               0x00
00030 #define FT6x06_GEST_ID                0x01
00031 #define FT6x06_TD_STATUS              0x02
00032 #define FT6x06_TH_GROUP               0x80
00033 #define FT6x06_PERIODACTIVE           0x88
00034 #define FT6x06_CHIPER                 0xA3
00035 #define FT6x06_G_MODE                 0xA4
00036 #define FT6x06_FIRMID                 0xA6
00037 #define FT6x06_FOCALTECH_ID           0xA8
00038 #define FT6x06_RELEASE_CODE_ID        0xAF
00039 
00040 #define WAIT_ACK_TIMEOUT              100
00041 #define COM_OK                        0
00042 #define ACK_ERROR                     1   
00043 
00044 class DmTpFt6x06
00045 {
00046 public:
00047   enum Display {
00048     DM_TFT28_116 = 116,
00049   };
00050  
00051 #if defined (DM_TOOLCHAIN_ARDUINO)  
00052   DmTpFt6x06(Display disp, bool useIrq=true);
00053 #elif defined (DM_TOOLCHAIN_MBED)
00054   DmTpFt6x06(Display disp, I2C &i2c, bool useIrq=true);
00055 #endif  
00056   void init();
00057   void readTouchData(uint16_t& posX, uint16_t& posY, bool& touching);
00058   bool readTouchData(uint16_t& posX, uint16_t& posY);
00059   bool isTouched();
00060   
00061 private:
00062  uint8_t readRegister8(uint8_t reg);  
00063  void writeRegister8(uint8_t reg, uint8_t val); 
00064   void enableIrq();
00065 #if defined (DM_TOOLCHAIN_ARDUINO)
00066   int8_t _irq; 
00067   regtype *_pinIrq;
00068   regsize _bitmaskIrq;
00069 #elif defined (DM_TOOLCHAIN_MBED)
00070   PinName _irq;
00071   long map(long x, long in_min, long in_max, long out_min, long out_max);
00072   DigitalIn *_pinIrq;
00073   I2C *_i2c;
00074 #endif
00075 };
00076 #endif