Atmel AT42QT1070 Seven-channel QTouch® Touch Sensor IC

Files at this revision

API Documentation at this revision

Comitter:
mederic
Date:
Thu Jun 28 08:08:14 2018 +0000
Parent:
0:cdb98fa5056a
Commit message:
replace "x%=X_MAX;" by "if(x>X_MAX)x=X_MAX;"

Changed in this revision

QT1070.cpp Show annotated file Show diff for this revision Revisions of this file
QT1070.h Show annotated file Show diff for this revision Revisions of this file
--- a/QT1070.cpp	Wed Jun 27 06:25:51 2018 +0000
+++ b/QT1070.cpp	Thu Jun 28 08:08:14 2018 +0000
@@ -49,8 +49,8 @@
 
 char QT1070::aksAve(char key, char group, char ave){
     key%=KEY_NUM;
-    ave%=AVEMAX;
-    group%=AKSMAX;
+    if(ave>AVEMAX)ave=AVEMAX;
+    if(group>AKSMAX)group=AKSMAX;
     write(REG_AVEAKS0+key,(ave<<QT1070_BIT_AVE)|(group));
     return read(REG_AVEAKS0+key);
 }
@@ -77,7 +77,8 @@
 }
 
 void QT1070::lowpwr(unsigned short ms){
-    char reg  = (ms%2040)>>3;
+    if(ms>2040)ms=2040;
+    char reg  = ms>>3;
     write(REG_LOWPWR, reg);
     
 }
--- a/QT1070.h	Wed Jun 27 06:25:51 2018 +0000
+++ b/QT1070.h	Thu Jun 28 08:08:14 2018 +0000
@@ -1,7 +1,6 @@
 #ifndef QT1070_H
 #define QT1070_H
 
-#include <stdint.h>
 #include "mbed.h"
 
 /** AT42QT1070 class
@@ -36,7 +35,7 @@
         enum state{
             I2C_ADDR = 0x36,    //I2C adress 
             KEY_NUM = 0x07,     //Number of channel
-            AVEMAX = 32,        //Averaging maximum
+            AVEMAX = 31,        //Averaging maximum
             AKSMAX = 3          //Group maximum
         };