upm  0.5.1
Sensor/Actuator repository for libmraa (v0.9.1)
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
Public Types | Public Member Functions
AT42QT1070 Class Reference

API for the Atmel AT42QT1070 QTouch Sensor. More...

Detailed Description

This class implements support for the Atmel AT42QT1070 QTouch sensor, which supports 7 capacitive buttons.

It was developed using a Grove-Q Touch Sensor board.

at42qt1070.jpg
// Instantiate an AT42QT1070 on I2C bus 0
upm::AT42QT1070 *touch = new upm::AT42QT1070(AT42QT1070_I2C_BUS,
AT42QT1070_DEFAULT_I2C_ADDR);
while (shouldRun)
{
touch->updateState();
printButtons(touch);
usleep(100000);
}

Public Types

enum  AT42QT1070_REG_T {
  REG_CHIPID = 0, REG_FWVERS = 1, REG_DETSTATUS = 2, REG_KEYSTATUS = 3,
  REG_KEYSIG0_H = 4, REG_KEYSIG0_L = 5, REG_KEYSIG1_H = 6, REG_KEYSIG1_L = 7,
  REG_KEYSIG2_H = 8, REG_KEYSIG2_L = 9, REG_KEYSIG3_H = 10, REG_KEYSIG3_L = 11,
  REG_KEYSIG4_H = 12, REG_KEYSIG4_L = 13, REG_KEYSIG5_H = 14, REG_KEYSIG5_L = 15,
  REG_KEYSIG6_H = 16, REG_KEYSIG6_L = 17, REG_REFDATA0_H = 18, REG_REFDATA0_L = 19,
  REG_REFDATA1_H = 20, REG_REFDATA1_L = 21, REG_REFDATA2_H = 22, REG_REFDATA2_L = 23,
  REG_REFDATA3_H = 24, REG_REFDATA3_L = 25, REG_REFDATA4_H = 26, REG_REFDATA4_L = 27,
  REG_REFDATA5_H = 28, REG_REFDATA5_L = 29, REG_REFDATA6_H = 30, REG_REFDATA6_L = 31,
  REG_NTHR0 = 32, REG_NTHR1 = 33, REG_NTHR2 = 34, REG_NTHR3 = 35,
  REG_NTHR4 = 36, REG_NTHR5 = 37, REG_NTHR6 = 38, REG_AVE0 = 39,
  REG_AVE1 = 40, REG_AVE2 = 41, REG_AVE3 = 42, REG_AVE4 = 43,
  REG_AVE5 = 44, REG_AVE6 = 45, REG_DI0 = 46, REG_DI1 = 47,
  REG_DI2 = 48, REG_DI3 = 49, REG_DI4 = 50, REG_DI5 = 51,
  REG_DI6 = 52, REG_GUARD = 53, REG_LP = 54, REG_MAXON = 55,
  REG_CALIBRATE = 56, REG_RESET = 57
}
 
enum  AT42QT1070_DET_T { DET_TOUCH = 0x01, DET_OVERFLOW = 0x40, DET_CALIBRATE = 0x80 }
 

Public Member Functions

 AT42QT1070 (int bus, uint8_t address=AT42QT1070_DEFAULT_I2C_ADDR)
 
 ~AT42QT1070 ()
 
bool writeByte (uint8_t reg, uint8_t byte)
 
bool writeWord (uint8_t reg, uint16_t word)
 
uint8_t readByte (uint8_t reg)
 
uint16_t readWord (uint8_t reg)
 
uint8_t readChipID (void)
 
void updateState ()
 
uint8_t getLPMode (void)
 
uint8_t setLPMode (uint8_t mode)
 
uint8_t getAVE (uint8_t key)
 
uint8_t setAVE (uint8_t key, uint8_t ave)
 
uint8_t getAKSGroup (uint8_t key)
 
uint8_t setAKSGroup (uint8_t key, uint8_t group)
 
bool isOverflowed ()
 
bool isCalibrating ()
 
bool reset ()
 
bool calibrate ()
 
uint8_t getButtons ()
 

Constructor & Destructor Documentation

AT42QT1070 ( int  bus,
uint8_t  address = AT42QT1070_DEFAULT_I2C_ADDR 
)

AT42QT1070 constructor

Parameters
busI2C bus to use
addressAddress for this sensor
~AT42QT1070 ( )

AT42QT1070 destructor

Member Function Documentation

bool writeByte ( uint8_t  reg,
uint8_t  byte 
)

Writes a byte value into the register

Parameters
regRegister location to write into
byteByte to write
Returns
True if successful
bool writeWord ( uint8_t  reg,
uint16_t  word 
)

Writes a word value into the register. Note: the device must have the auto-increment bit set in the MODE1 register to work.

Parameters
regRegister location to write into
wordWord to write
Returns
True if successful
uint8_t readByte ( uint8_t  reg)

Read a byte value from the register

Parameters
regRegister location to read from
Returns
Value in the specified register
uint16_t readWord ( 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.

Parameters
regRegister location to read from
Returns
Value in the specified register
uint8_t readChipID ( void  )

Reads the Chip ID register on the sensor

Returns
Value of the Chip ID register
void updateState ( )

Reads the current touch status and detection state

Returns
Key status bits for all keys (0-6)
uint8_t getLPMode ( void  )

Reads the current low-power mode setting

Returns
Low-power mode setting from the sensor
uint8_t setLPMode ( uint8_t  mode)

Changes the low-pomer mode setting on the sensor

Parameters
modedDsired new mode
Returns
New setting on the sensor
uint8_t getAVE ( uint8_t  key)

Reads the current averaging factor setting for a key

Parameters
keyKey being read
Returns
Averaging factor
uint8_t setAVE ( uint8_t  key,
uint8_t  ave 
)

Changes the averaging factor setting for a key

Parameters
keyKey being changed
aveNew averaging factor
Returns
New averaging factor as read from the device
uint8_t getAKSGroup ( uint8_t  key)

Reads the AKS group of which a key is part

Parameters
keyKey (0-6) being queried
Returns
AKS group of which the key is part
uint8_t setAKSGroup ( uint8_t  key,
uint8_t  group 
)

Changes the AKS group of which a key is part

Parameters
keyKey (0-6) being changed
groupNew group for the key
Returns
New value on the sensor
bool isOverflowed ( )
inline

Returns the overflow indicator

Returns
True if overflow is indicated
bool isCalibrating ( )
inline

Returns the calibrating indicator

Returns
True if calibration is in progress
bool reset ( )

Issues a reset command

Returns
True if successful
bool calibrate ( )

Issues a calibrate command

Returns
True if successful
uint8_t getButtons ( )
inline

Gets the current button states

Returns
Button states

The documentation for this class was generated from the following files: