Driver for the AT42QT1070

Revision:
1:38001f05dab3
Parent:
0:607af852fb64
Child:
2:cee8b532fc22
diff -r 607af852fb64 -r 38001f05dab3 include/at42qt1070.h
--- a/include/at42qt1070.h	Thu Dec 03 23:01:34 2015 +0000
+++ b/include/at42qt1070.h	Sun Dec 20 19:38:45 2015 +0000
@@ -24,10 +24,12 @@
 #pragma once
 
 #include <stdint.h>
-#include <sys/time.h>
+//#include <sys/time.h>
 
 #include <string>
-#include <mraa/i2c.h>
+#include <I2C.h>
+#include "PinNames.h"
+//#include <mraa/i2c.h>
 
 #define AT42QT1070_I2C_BUS 0
 #define AT42QT1070_DEFAULT_I2C_ADDR 0x1b
@@ -146,7 +148,7 @@
      * @param bus I2C bus to use
      * @param address Address for this sensor
      */
-    AT42QT1070(int bus, uint8_t address = AT42QT1070_DEFAULT_I2C_ADDR);
+    AT42QT1070(PinName sda, PinName sck, int bus, uint8_t address = AT42QT1070_DEFAULT_I2C_ADDR);
 
     /**
      * AT42QT1070 destructor
@@ -154,43 +156,6 @@
     ~AT42QT1070();
 
     /**
-     * Writes a byte value into the register
-     *
-     * @param reg Register location to write into
-     * @param byte Byte to write
-     * @return True if successful
-     */
-    bool writeByte(uint8_t reg, uint8_t byte);
-
-    /**
-     * Writes a word value into the register.  Note: the device must have the
-     * auto-increment bit set in the MODE1 register to work.
-     *
-     * @param reg Register location to write into
-     * @param word Word to write
-     * @return True if successful
-     */
-    bool writeWord(uint8_t reg, uint16_t word);
-
-    /**
-     * Read a byte value from the register
-     *
-     * @param reg Register location to read from
-     * @return Value in the specified register
-     */
-    uint8_t readByte(uint8_t reg);
-
-    /**
-     * Read a word value from the register.  Note: the device must have the
-     * auto-increment bit set in the MODE1 register to work.
-     *
-     * @param reg Register location to read from
-     * @return Value in the specified register
-     */
-    uint16_t readWord(uint8_t reg);
-
-
-    /**
      * Reads the Chip ID register on the sensor
      *
      * @return Value of the Chip ID register
@@ -210,7 +175,7 @@
      *
      * @return Low-power mode setting from the sensor
      */
-    uint8_t getLPMode(void);
+    uint8_t getLowPowerMode(void);
 
     /**
      * Changes the low-pomer mode setting on the sensor
@@ -218,7 +183,7 @@
      * @param mode dDsired new mode
      * @return New setting on the sensor
      */
-    uint8_t setLPMode(uint8_t mode);
+    uint8_t setLowPowerMode(uint8_t mode);
 
 
     /**
@@ -260,7 +225,7 @@
      *
      * @return True if overflow is indicated
      */
-    bool isOverflowed() { return m_overflow; };
+    bool isOverflowed() { return _overflow; };
 
     /**
      * Returns the calibrating indicator
@@ -288,14 +253,53 @@
      *
      * @returns Button states
      */
-    uint8_t getButtons() { return  _buttonStates; };
+    uint8_t getButtonsState();
+    
+    bool isButtonPressed(const uint8_t button);
+    
+  private:
+        /**
+     * Writes a byte value into the register
+     *
+     * @param reg Register location to write into
+     * @param byte Byte to write
+     * @return True if successful
+     */
+    bool writeByte(uint8_t reg, uint8_t byte);
+
+    /**
+     * Writes a word value into the register.  Note: the device must have the
+     * auto-increment bit set in the MODE1 register to work.
+     *
+     * @param reg Register location to write into
+     * @param word Word to write
+     * @return True if successful
+     */
+    bool writeWord(uint8_t reg, uint16_t word);
+
+    /**
+     * Read a byte value from the register
+     *
+     * @param reg Register location to read from
+     * @return Value in the specified register
+     */
+    uint8_t readByte(uint8_t reg);
+
+    /**
+     * Read a word value from the register.  Note: the device must have the
+     * auto-increment bit set in the MODE1 register to work.
+     *
+     * @param reg Register location to read from
+     * @return Value in the specified register
+     */
+    uint16_t readWord(uint8_t reg);
 
   private:
     uint8_t _buttonStates;
     bool    _calibrating;
     bool    _overflow;
 
-    mraa_i2c_context _i2c;
+    mbed::I2C        _i2cPort;
     uint8_t          _addr;
 };
 }
\ No newline at end of file