1st half of mbed DDR game
Dependencies: 4DGL-uLCD-SE PinDetect mbed
Revision 0:5a54aaccd065, committed 2014-04-29
- Comitter:
- jmelliadis3
- Date:
- Tue Apr 29 23:24:46 2014 +0000
- Commit message:
- To put on primary mbed
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/4DGL-uLCD-SE.lib Tue Apr 29 23:24:46 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/4180_1/code/4DGL-uLCD-SE/#e39a44de229a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PinDetect.lib Tue Apr 29 23:24:46 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/AjK/code/PinDetect/#cb3afc45028b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Apr 29 23:24:46 2014 +0000 @@ -0,0 +1,628 @@ +#include "mbed.h" + +#include "uLCD_4DGL.h" +#include "PinDetect.h" +#include <mpr121.h> + + +uLCD_4DGL uLCD(p28, p27, p29); // create a global lcd object + +// Create the interrupt receiver object on pin 26 +InterruptIn interrupt(p26); + +// Setup the i2c bus on pins 28 and 27 +I2C i2c(p9, p10); + +// Setup the Mpr121: +// constructor(i2c object, i2c address of the mpr121) +Mpr121 mpr121(&i2c, Mpr121::ADD_VSS); + +DigitalOut start (p21); +DigitalOut stop (p22); +InterruptIn songOver (p23); + + + +//PinDetect pb1(p26); + +int volatile score = 0; +int volatile meter = 15; +int scrollSpeed = 6; + +int volatile rightPressed = 0; +int volatile leftPressed = 0; +int volatile upPressed = 0; +int volatile downPressed = 0; + +struct arrow { + int yPos; + int alive; + arrow *next; +}; + +arrow* leftRoot = NULL; +arrow* rightRoot = NULL; +arrow* upRoot = NULL; +arrow* downRoot = NULL; + + +enum gameState{ + begin, + playing, + over}; + +int volatile state; + +enum node{ + up, + down, + left, + right, + none +}; + +enum difficultyLevels{ + easy, + medium, + hard +}; + +int volatile nodeToDelete(none); + +int volatile difficulty(easy); + +void deleteRoot (arrow* &root, int direction) { + arrow* temp = root; + + switch(direction) { + case 0: + uLCD.line(4, root->yPos-scrollSpeed,24, root->yPos-scrollSpeed,0x0000FF); + uLCD.line(4, root->yPos-scrollSpeed, 14, root->yPos+10-scrollSpeed, 0x0000FF); + uLCD.line(4, root->yPos-scrollSpeed, 14, root->yPos-10-scrollSpeed, 0x0000FF); + break; + + case 1: + uLCD.line(47,root->yPos-scrollSpeed-10,47,root->yPos-scrollSpeed+10,0x0000FF); + uLCD.line(47, root->yPos-scrollSpeed-10, 37, root->yPos-scrollSpeed, 0x0000FF); + uLCD.line(47, root->yPos-scrollSpeed-10, 57, root->yPos-scrollSpeed, 0x0000FF); + break; + + case 2: + uLCD.line(80,root->yPos-scrollSpeed-10,80,root->yPos-scrollSpeed+10,0x0000FF); + uLCD.line(80, root->yPos-scrollSpeed+10, 70, root->yPos-scrollSpeed, 0x0000FF); + uLCD.line(80, root->yPos-scrollSpeed+10, 90, root->yPos-scrollSpeed, 0x0000FF); + break; + + case 3: + uLCD.line(104,root->yPos-scrollSpeed,124,root->yPos-scrollSpeed,0x0000FF); + uLCD.line(124, root->yPos-scrollSpeed, 114, root->yPos-scrollSpeed+10, 0x0000FF); + uLCD.line(124, root->yPos-scrollSpeed, 114, root->yPos-scrollSpeed-10, 0x0000FF); + break; + } + + root = root->next; + delete temp; +} + +void addToEnd (arrow* &root) { + arrow * temp = root; + if (root == NULL) + { + root = new arrow; + root->yPos = 10; + root->alive = 1; + root->next = 0; + } + else { + while (temp->next) + { + temp = temp->next; + } + + temp->next = new arrow; + temp = temp->next; + temp->yPos = 10; + temp->alive = 1; + temp->next = 0; + } +} + +void fallInterrupt() { + int key_code=0; + int i=0; + int value=mpr121.read(0x00); + value +=mpr121.read(0x01)<<8; + + i=0; + // puts key number out to LEDs for demo + for (i=0; i<12; i++) { + if (((value>>i)&0x01)==1) key_code=i+1; + } + + switch (key_code) { + case 2: + upPressed = 1; + if (upRoot) { + if (upRoot->yPos > 100 && upRoot->yPos < 120) + { + score++; + meter+=2; + } + if (upRoot->yPos > 95) + { + nodeToDelete = up; + } + } + break; + + case 5: + leftPressed = 1; + if (leftRoot) { + if (leftRoot->yPos > 100 && leftRoot->yPos < 120) + { + score++; + meter+=2; + } + if (leftRoot->yPos > 95) + { + nodeToDelete = left; + } + } + break; + + case 6: + switch (state) { + case begin: + state = playing; + break; + case playing: + break; + case over: + state = begin; + break; + } + break; + + case 7: + rightPressed = 1; + if (rightRoot) { + if (rightRoot->yPos > 100 && rightRoot->yPos < 120) + { + score++; + meter+=2; + } + if (rightRoot->yPos > 95) + { + nodeToDelete = right; + } + } + break; + + case 10: + downPressed = 1; + if (downRoot) { + if (downRoot->yPos > 100 && downRoot->yPos < 120) + { + score++; + meter+=2; + } + if (downRoot->yPos > 95) + { + nodeToDelete = down; + } + } + break; + + case 4: + if (state == begin) { + difficulty = easy; + } + break; + + case 8: + if (state == begin) { + difficulty = medium; + } + break; + + case 12: + if (state == begin) { + difficulty = hard; + } + break; + } + +} + + +void pb1_hit_callback() { + + switch (state) { + case begin: + state = playing; + break; + case playing: + break; + case over: + state = begin; + break; + } +} + +void drawLeftArrow (int y) { + + uLCD.line(4,y-scrollSpeed,24,y-scrollSpeed,0x0000FF); + uLCD.line(4, y-scrollSpeed, 14, y-scrollSpeed+10, 0x0000FF); + uLCD.line(4, y-scrollSpeed, 14, y-scrollSpeed-10, 0x0000FF); + + + uLCD.line(4,y,24,y,0x000000); + uLCD.line(4, y, 14, y+10, 0x000000); + uLCD.line(4, y, 14, y-10, 0x000000); +} + +void drawUpArrow (int y) { + uLCD.line(47,y-scrollSpeed-10,47,y-scrollSpeed+10,0x0000FF); + uLCD.line(47, y-scrollSpeed-10, 37, y-scrollSpeed, 0x0000FF); + uLCD.line(47, y-scrollSpeed-10, 57, y-scrollSpeed, 0x0000FF); + + uLCD.line(47,y-10,47,y+10,0x000000); + uLCD.line(47, y-10, 37, y, 0x000000); + uLCD.line(47, y-10, 57, y, 0x000000); +} + +void drawDownArrow (int y) { + uLCD.line(80,y-scrollSpeed-10,80,y-scrollSpeed+10,0x0000FF); + uLCD.line(80, y-scrollSpeed+10, 70, y-scrollSpeed, 0x0000FF); + uLCD.line(80, y-scrollSpeed+10, 90, y-scrollSpeed, 0x0000FF); + + uLCD.line(80,y-10,80,y+10,0x000000); + uLCD.line(80, y+10, 70, y, 0x000000); + uLCD.line(80, y+10, 90, y, 0x000000); +} + +void drawRightArrow (int y) { + uLCD.line(104,y-scrollSpeed,124,y-scrollSpeed,0x0000FF); + uLCD.line(124, y-scrollSpeed, 114, y-scrollSpeed+10, 0x0000FF); + uLCD.line(124, y-scrollSpeed, 114, y-scrollSpeed-10, 0x0000FF); + + uLCD.line(104,y,124,y,0x000000); + uLCD.line(124, y, 114, y+10, 0x000000); + uLCD.line(124, y, 114, y-10, 0x000000); +} + +void songOverInterrupt () { + state = over; +} + +int main() { + + state = begin; + srand(time(NULL)); + + interrupt.fall(&fallInterrupt); + interrupt.mode(PullUp); + + songOver.rise(&songOverInterrupt); + + uLCD.baudrate(3000000); + uLCD.cls(); + + uLCD.filled_rectangle(0,0,128,128,0x0000FF); + + int go = 1; + int scoreWrite = 1; + int ready; + int leftCounter; + int rightCounter; + int upCounter; + int downCounter; + + int deleted = 0; + + int drawArrow = 1; + + + Timer t; + float time = 0.0; + + arrow * temp; + + while(go) { + t.reset(); + t.start(); + drawArrow = 1; + + switch (state) { + case begin: + uLCD.locate(5,2); + uLCD.color(WHITE); + uLCD.textbackground_color(BLUE); + uLCD.text_mode(OPAQUE); + uLCD.set_font(FONT_7X8); + uLCD.printf("MBED DDR"); + + uLCD.locate(0,4); + uLCD.printf("Difficulty: 3,7,11"); + + uLCD.locate(1,10); + uLCD.printf("Press 5 to Start"); + + switch (difficulty) { + case easy: + leftCounter = rand()%200 + 75; + rightCounter = rand()%200 + 75; + upCounter = rand()%200 + 75; + downCounter = rand()%200 + 75; + scrollSpeed = 2; + + uLCD.locate(7,6); + uLCD.printf("Easy "); + break; + + case medium: + leftCounter = rand()%150 + 50; + rightCounter = rand()%150 + 50; + upCounter = rand()%150 + 50; + downCounter = rand()%150 + 50; + scrollSpeed = 4; + + uLCD.locate(7,6); + uLCD.printf("Medium"); + break; + + case hard: + leftCounter = rand()%100 + 25; + rightCounter = rand()%100 + 25; + upCounter = rand()%100 + 25; + downCounter = rand()%100 + 25; + scrollSpeed = 6; + + uLCD.locate(7,6); + uLCD.printf("Hard "); + break; + } + + ready = 0; + + + + break; + + case playing: + + if (!ready) + { + uLCD.cls(); + + uLCD.filled_rectangle(0,0,128,128,0x0000FF); + + uLCD.filled_rectangle(0,100,3,120,0xFFFFFF); + uLCD.filled_rectangle(25,100,36,120,0xFFFFFF); + uLCD.filled_rectangle(58,100,69,120,0xFFFFFF); + uLCD.filled_rectangle(91,100,103,120,0xFFFFFF); + uLCD.filled_rectangle(125,100,128,120,0xFFFFFF); + + ready = 1; + start = 1; + stop = 0; + } + + if (leftCounter <= 0){ + addToEnd(leftRoot); + + switch (difficulty) { + case easy: + leftCounter = rand()%200 + 75; + break; + + case medium: + leftCounter = rand()%150 + 50; + break; + + case hard: + leftCounter = rand()%100 + 25; + break; + } + drawArrow = 0; + } + + leftCounter-=scrollSpeed; + + temp = leftRoot; + while (temp != NULL) + { + drawLeftArrow(temp->yPos); + (temp->yPos)+=scrollSpeed; + temp = temp->next; + } + + if (leftRoot != NULL) { + if (leftRoot->yPos >= 120 || nodeToDelete == left) { + meter--; + deleteRoot(leftRoot, 0); + deleted = 1; + } + } + + + + + + if (downCounter <= 0 && drawArrow){ + addToEnd(downRoot); + switch (difficulty) { + case easy: + downCounter = rand()%200 + 75; + break; + + case medium: + downCounter = rand()%150 + 50; + break; + + case hard: + downCounter = rand()%100 + 25; + break; + } + drawArrow = 0; + } + + downCounter-=scrollSpeed; + + temp = downRoot; + while (temp != NULL) + { + drawDownArrow(temp->yPos); + (temp->yPos)+=scrollSpeed; + temp = temp->next; + } + + if (downRoot != NULL) { + if (downRoot->yPos >= 120 || nodeToDelete == down) { + meter--; + deleteRoot(downRoot, 2); + deleted = 1; + } + } + + + + + + if (rightCounter <= 0 && drawArrow){ + addToEnd(rightRoot); + switch (difficulty) { + case easy: + rightCounter = rand()%200 + 75; + break; + + case medium: + rightCounter = rand()%150 + 50; + break; + + case hard: + rightCounter = rand()%100 + 25; + break; + } + + drawArrow = 0; + } + + rightCounter-=scrollSpeed; + + temp = rightRoot; + while (temp != NULL) + { + drawRightArrow(temp->yPos); + (temp->yPos)+=scrollSpeed; + temp = temp->next; + } + + if (rightRoot != NULL) { + if (rightRoot->yPos >= 120 || nodeToDelete == right) { + meter--; + deleteRoot(rightRoot, 3); + deleted = 1; + } + } + + + + + + if (upCounter <= 0 && drawArrow){ + addToEnd(upRoot); + switch (difficulty) { + case easy: + upCounter = rand()%200 + 75; + break; + + case medium: + upCounter = rand()%150 + 50; + break; + + case hard: + upCounter = rand()%100 + 25; + break; + } + + drawArrow = 0; + } + + upCounter-=scrollSpeed; + + temp = upRoot; + while (temp != NULL) + { + drawUpArrow(temp->yPos); + (temp->yPos)+=scrollSpeed; + temp = temp->next; + } + + if (upRoot != NULL) { + if (upRoot->yPos >= 120 || nodeToDelete == up) { + meter--; + deleteRoot(upRoot, 1); + deleted = 1; + } + } + + break; + + case over: + if (ready) + { + stop = 1; + start = 0; + while (leftRoot) { + deleteRoot(leftRoot,0); + } + + while (upRoot) { + deleteRoot(upRoot,1); + } + + while (downRoot) { + deleteRoot(downRoot,2); + } + + while (rightRoot) { + deleteRoot(rightRoot,3); + } + + uLCD.locate(5,8); + uLCD.color(WHITE); + uLCD.textbackground_color(BLUE); + uLCD.text_mode(OPAQUE); + uLCD.set_font(FONT_7X8); + uLCD.printf("Game Over"); + + uLCD.locate(14,0); + uLCD.printf("%04d", score); + ready = 0; + score = 0; + meter = 15; + } + break; + } + t.stop(); + time = .1-t.read(); + if (time < 0) time = 0; + uLCD.locate(0,0); + uLCD.printf("%04d", score); + + + if (meter > 15) meter = 15; + uLCD.locate(14,0); + uLCD.printf("%4d", meter); + + if (meter < 0) state = over; + + if (deleted) + { + nodeToDelete = none; + deleted = 0; + } + wait(time); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Apr 29 23:24:46 2014 +0000 @@ -0,0 +1,1 @@ +http://world3.dev.mbed.org/users/mbed_official/code/mbed/builds/824293ae5e43 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mpr121.cpp Tue Apr 29 23:24:46 2014 +0000 @@ -0,0 +1,221 @@ +/* +Copyright (c) 2011 Anthony Buckton (abuckton [at] blackink [dot} net {dot} au) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include <mbed.h> +#include <sstream> +#include <string> +#include <list> + +#include <mpr121.h> + +Mpr121::Mpr121(I2C *i2c, Address i2cAddress) +{ + this->i2c = i2c; + + address = i2cAddress; + + // Configure the MPR121 settings to default + this->configureSettings(); +} + + +void Mpr121::configureSettings() +{ + // Put the MPR into setup mode + this->write(ELE_CFG,0x00); + + // Electrode filters for when data is > baseline + unsigned char gtBaseline[] = { + 0x01, //MHD_R + 0x01, //NHD_R + 0x00, //NCL_R + 0x00 //FDL_R + }; + + writeMany(MHD_R,gtBaseline,4); + + // Electrode filters for when data is < baseline + unsigned char ltBaseline[] = { + 0x01, //MHD_F + 0x01, //NHD_F + 0xFF, //NCL_F + 0x02 //FDL_F + }; + + writeMany(MHD_F,ltBaseline,4); + + // Electrode touch and release thresholds + unsigned char electrodeThresholds[] = { + E_THR_T, // Touch Threshhold + E_THR_R // Release Threshold + }; + + for(int i=0; i<12; i++){ + int result = writeMany((ELE0_T+(i*2)),electrodeThresholds,2); + } + + // Proximity Settings + unsigned char proximitySettings[] = { + 0xff, //MHD_Prox_R + 0xff, //NHD_Prox_R + 0x00, //NCL_Prox_R + 0x00, //FDL_Prox_R + 0x01, //MHD_Prox_F + 0x01, //NHD_Prox_F + 0xFF, //NCL_Prox_F + 0xff, //FDL_Prox_F + 0x00, //NHD_Prox_T + 0x00, //NCL_Prox_T + 0x00 //NFD_Prox_T + }; + writeMany(MHDPROXR,proximitySettings,11); + + unsigned char proxThresh[] = { + PROX_THR_T, // Touch Threshold + PROX_THR_R // Release Threshold + }; + writeMany(EPROXTTH,proxThresh,2); + + this->write(FIL_CFG,0x04); + + // Set the electrode config to transition to active mode + this->write(ELE_CFG,0x0c); +} + +void Mpr121::setElectrodeThreshold(int electrode, unsigned char touch, unsigned char release){ + + if(electrode > 11) return; + + // Get the current mode + unsigned char mode = this->read(ELE_CFG); + + // Put the MPR into setup mode + this->write(ELE_CFG,0x00); + + // Write the new threshold + this->write((ELE0_T+(electrode*2)), touch); + this->write((ELE0_T+(electrode*2)+1), release); + + //Restore the operating mode + this->write(ELE_CFG, mode); +} + + +unsigned char Mpr121::read(int key){ + + unsigned char data[2]; + + //Start the command + i2c->start(); + + // Address the target (Write mode) + int ack1= i2c->write(address); + + // Set the register key to read + int ack2 = i2c->write(key); + + // Re-start for read of data + i2c->start(); + + // Re-send the target address in read mode + int ack3 = i2c->write(address+1); + + // Read in the result + data[0] = i2c->read(0); + + // Reset the bus + i2c->stop(); + + return data[0]; +} + + +int Mpr121::write(int key, unsigned char value){ + + //Start the command + i2c->start(); + + // Address the target (Write mode) + int ack1= i2c->write(address); + + // Set the register key to write + int ack2 = i2c->write(key); + + // Read in the result + int ack3 = i2c->write(value); + + // Reset the bus + i2c->stop(); + + return (ack1+ack2+ack3)-3; +} + + +int Mpr121::writeMany(int start, unsigned char* dataSet, int length){ + //Start the command + i2c->start(); + + // Address the target (Write mode) + int ack= i2c->write(address); + if(ack!=1){ + return -1; + } + + // Set the register key to write + ack = i2c->write(start); + if(ack!=1){ + return -1; + } + + // Write the date set + int count = 0; + while(ack==1 && (count < length)){ + ack = i2c->write(dataSet[count]); + count++; + } + // Stop the cmd + i2c->stop(); + + return count; +} + + +bool Mpr121::getProximityMode(){ + if(this->read(ELE_CFG) > 0x0c) + return true; + else + return false; +} + +void Mpr121::setProximityMode(bool mode){ + this->write(ELE_CFG,0x00); + if(mode){ + this->write(ELE_CFG,0x30); //Sense proximity from ALL pads + } else { + this->write(ELE_CFG,0x0c); //Sense touch, all 12 pads active. + } +} + + +int Mpr121::readTouchData(){ + return this->read(0x00); +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mpr121.h Tue Apr 29 23:24:46 2014 +0000 @@ -0,0 +1,157 @@ +/* +Copyright (c) 2011 Anthony Buckton (abuckton [at] blackink [dot} net {dot} au) + + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + Parts written by Jim Lindblom of Sparkfun + Ported to mbed by A.Buckton, Feb 2011 +*/ + +#ifndef MPR121_H +#define MPR121_H + +//using namespace std; + +class Mpr121 +{ + +public: + // i2c Addresses, bit-shifted + enum Address { ADD_VSS = 0xb4,// ADD->VSS = 0x5a <-wiring on Sparkfun board + ADD_VDD = 0xb6,// ADD->VDD = 0x5b + ADD_SCL = 0xb8,// ADD->SDA = 0x5c + ADD_SDA = 0xba // ADD->SCL = 0x5d + }; + + // Real initialiser, takes the i2c address of the device. + Mpr121(I2C *i2c, Address i2cAddress); + + bool getProximityMode(); + + void setProximityMode(bool mode); + + int readTouchData(); + + unsigned char read(int key); + + int write(int address, unsigned char value); + int writeMany(int start, unsigned char* dataSet, int length); + + void setElectrodeThreshold(int electrodeId, unsigned char touchThreshold, unsigned char releaseThreshold); + +protected: + // Configures the MPR with standard settings. This is permitted to be overwritten by sub-classes. + void configureSettings(); + +private: + // The I2C bus instance. + I2C *i2c; + + // i2c address of this mpr121 + Address address; +}; + + +// MPR121 Register Defines +#define MHD_R 0x2B +#define NHD_R 0x2C +#define NCL_R 0x2D +#define FDL_R 0x2E +#define MHD_F 0x2F +#define NHD_F 0x30 +#define NCL_F 0x31 +#define FDL_F 0x32 +#define NHDT 0x33 +#define NCLT 0x34 +#define FDLT 0x35 +// Proximity sensing controls +#define MHDPROXR 0x36 +#define NHDPROXR 0x37 +#define NCLPROXR 0x38 +#define FDLPROXR 0x39 +#define MHDPROXF 0x3A +#define NHDPROXF 0x3B +#define NCLPROXF 0x3C +#define FDLPROXF 0x3D +#define NHDPROXT 0x3E +#define NCLPROXT 0x3F +#define FDLPROXT 0x40 +// Electrode Touch/Release thresholds +#define ELE0_T 0x41 +#define ELE0_R 0x42 +#define ELE1_T 0x43 +#define ELE1_R 0x44 +#define ELE2_T 0x45 +#define ELE2_R 0x46 +#define ELE3_T 0x47 +#define ELE3_R 0x48 +#define ELE4_T 0x49 +#define ELE4_R 0x4A +#define ELE5_T 0x4B +#define ELE5_R 0x4C +#define ELE6_T 0x4D +#define ELE6_R 0x4E +#define ELE7_T 0x4F +#define ELE7_R 0x50 +#define ELE8_T 0x51 +#define ELE8_R 0x52 +#define ELE9_T 0x53 +#define ELE9_R 0x54 +#define ELE10_T 0x55 +#define ELE10_R 0x56 +#define ELE11_T 0x57 +#define ELE11_R 0x58 +// Proximity Touch/Release thresholds +#define EPROXTTH 0x59 +#define EPROXRTH 0x5A +// Debounce configuration +#define DEB_CFG 0x5B +// AFE- Analogue Front End configuration +#define AFE_CFG 0x5C +// Filter configuration +#define FIL_CFG 0x5D +// Electrode configuration - transistions to "active mode" +#define ELE_CFG 0x5E + +#define GPIO_CTRL0 0x73 +#define GPIO_CTRL1 0x74 +#define GPIO_DATA 0x75 +#define GPIO_DIR 0x76 +#define GPIO_EN 0x77 +#define GPIO_SET 0x78 +#define GPIO_CLEAR 0x79 +#define GPIO_TOGGLE 0x7A +// Auto configration registers +#define AUTO_CFG_0 0x7B +#define AUTO_CFG_U 0x7D +#define AUTO_CFG_L 0x7E +#define AUTO_CFG_T 0x7F + +// Threshold defaults +// Electrode touch threshold +#define E_THR_T 0x0F +// Electrode release threshold +#define E_THR_R 0x0A +// Prox touch threshold +#define PROX_THR_T 0x02 +// Prox release threshold +#define PROX_THR_R 0x02 + +#endif