Revenge of the Mouse

Dependencies:   4DGL-uLCD-SE EthernetInterface Game_Synchronizer LCD_fonts MMA8452 SDFileSystem mbed-rtos mbed wave_player

Fork of 2035_Tanks_Shell by ECE2035 Spring 2015 TA

Committer:
eriklomas
Date:
Tue Nov 01 18:59:29 2016 +0000
Revision:
28:fdaa7ecfbd80
4180;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
eriklomas 28:fdaa7ecfbd80 1 /*
eriklomas 28:fdaa7ecfbd80 2 Copyright (c) 2011 Anthony Buckton (abuckton [at] blackink [dot} net {dot} au)
eriklomas 28:fdaa7ecfbd80 3
eriklomas 28:fdaa7ecfbd80 4
eriklomas 28:fdaa7ecfbd80 5 Permission is hereby granted, free of charge, to any person obtaining a copy
eriklomas 28:fdaa7ecfbd80 6 of this software and associated documentation files (the "Software"), to deal
eriklomas 28:fdaa7ecfbd80 7 in the Software without restriction, including without limitation the rights
eriklomas 28:fdaa7ecfbd80 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
eriklomas 28:fdaa7ecfbd80 9 copies of the Software, and to permit persons to whom the Software is
eriklomas 28:fdaa7ecfbd80 10 furnished to do so, subject to the following conditions:
eriklomas 28:fdaa7ecfbd80 11
eriklomas 28:fdaa7ecfbd80 12 The above copyright notice and this permission notice shall be included in
eriklomas 28:fdaa7ecfbd80 13 all copies or substantial portions of the Software.
eriklomas 28:fdaa7ecfbd80 14
eriklomas 28:fdaa7ecfbd80 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
eriklomas 28:fdaa7ecfbd80 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
eriklomas 28:fdaa7ecfbd80 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
eriklomas 28:fdaa7ecfbd80 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
eriklomas 28:fdaa7ecfbd80 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
eriklomas 28:fdaa7ecfbd80 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
eriklomas 28:fdaa7ecfbd80 21 THE SOFTWARE.
eriklomas 28:fdaa7ecfbd80 22
eriklomas 28:fdaa7ecfbd80 23 Parts written by Jim Lindblom of Sparkfun
eriklomas 28:fdaa7ecfbd80 24 Ported to mbed by A.Buckton, Feb 2011
eriklomas 28:fdaa7ecfbd80 25 */
eriklomas 28:fdaa7ecfbd80 26
eriklomas 28:fdaa7ecfbd80 27 #ifndef MPR121_H
eriklomas 28:fdaa7ecfbd80 28 #define MPR121_H
eriklomas 28:fdaa7ecfbd80 29
eriklomas 28:fdaa7ecfbd80 30 //using namespace std;
eriklomas 28:fdaa7ecfbd80 31
eriklomas 28:fdaa7ecfbd80 32 class Mpr121
eriklomas 28:fdaa7ecfbd80 33 {
eriklomas 28:fdaa7ecfbd80 34
eriklomas 28:fdaa7ecfbd80 35 public:
eriklomas 28:fdaa7ecfbd80 36 // i2c Addresses, bit-shifted
eriklomas 28:fdaa7ecfbd80 37 enum Address { ADD_VSS = 0xb4,// ADD->VSS = 0x5a <-wiring on Sparkfun board
eriklomas 28:fdaa7ecfbd80 38 ADD_VDD = 0xb6,// ADD->VDD = 0x5b
eriklomas 28:fdaa7ecfbd80 39 ADD_SCL = 0xb8,// ADD->SDA = 0x5c
eriklomas 28:fdaa7ecfbd80 40 ADD_SDA = 0xba // ADD->SCL = 0x5d
eriklomas 28:fdaa7ecfbd80 41 };
eriklomas 28:fdaa7ecfbd80 42
eriklomas 28:fdaa7ecfbd80 43 // Real initialiser, takes the i2c address of the device.
eriklomas 28:fdaa7ecfbd80 44 Mpr121(I2C *i2c, Address i2cAddress);
eriklomas 28:fdaa7ecfbd80 45
eriklomas 28:fdaa7ecfbd80 46 bool getProximityMode();
eriklomas 28:fdaa7ecfbd80 47
eriklomas 28:fdaa7ecfbd80 48 void setProximityMode(bool mode);
eriklomas 28:fdaa7ecfbd80 49
eriklomas 28:fdaa7ecfbd80 50 int readTouchData();
eriklomas 28:fdaa7ecfbd80 51
eriklomas 28:fdaa7ecfbd80 52 unsigned char read(int key);
eriklomas 28:fdaa7ecfbd80 53
eriklomas 28:fdaa7ecfbd80 54 int write(int address, unsigned char value);
eriklomas 28:fdaa7ecfbd80 55 int writeMany(int start, unsigned char* dataSet, int length);
eriklomas 28:fdaa7ecfbd80 56
eriklomas 28:fdaa7ecfbd80 57 void setElectrodeThreshold(int electrodeId, unsigned char touchThreshold, unsigned char releaseThreshold);
eriklomas 28:fdaa7ecfbd80 58
eriklomas 28:fdaa7ecfbd80 59 protected:
eriklomas 28:fdaa7ecfbd80 60 // Configures the MPR with standard settings. This is permitted to be overwritten by sub-classes.
eriklomas 28:fdaa7ecfbd80 61 void configureSettings();
eriklomas 28:fdaa7ecfbd80 62
eriklomas 28:fdaa7ecfbd80 63 private:
eriklomas 28:fdaa7ecfbd80 64 // The I2C bus instance.
eriklomas 28:fdaa7ecfbd80 65 I2C *i2c;
eriklomas 28:fdaa7ecfbd80 66
eriklomas 28:fdaa7ecfbd80 67 // i2c address of this mpr121
eriklomas 28:fdaa7ecfbd80 68 Address address;
eriklomas 28:fdaa7ecfbd80 69 };
eriklomas 28:fdaa7ecfbd80 70
eriklomas 28:fdaa7ecfbd80 71
eriklomas 28:fdaa7ecfbd80 72 // MPR121 Register Defines
eriklomas 28:fdaa7ecfbd80 73 #define MHD_R 0x2B
eriklomas 28:fdaa7ecfbd80 74 #define NHD_R 0x2C
eriklomas 28:fdaa7ecfbd80 75 #define NCL_R 0x2D
eriklomas 28:fdaa7ecfbd80 76 #define FDL_R 0x2E
eriklomas 28:fdaa7ecfbd80 77 #define MHD_F 0x2F
eriklomas 28:fdaa7ecfbd80 78 #define NHD_F 0x30
eriklomas 28:fdaa7ecfbd80 79 #define NCL_F 0x31
eriklomas 28:fdaa7ecfbd80 80 #define FDL_F 0x32
eriklomas 28:fdaa7ecfbd80 81 #define NHDT 0x33
eriklomas 28:fdaa7ecfbd80 82 #define NCLT 0x34
eriklomas 28:fdaa7ecfbd80 83 #define FDLT 0x35
eriklomas 28:fdaa7ecfbd80 84 // Proximity sensing controls
eriklomas 28:fdaa7ecfbd80 85 #define MHDPROXR 0x36
eriklomas 28:fdaa7ecfbd80 86 #define NHDPROXR 0x37
eriklomas 28:fdaa7ecfbd80 87 #define NCLPROXR 0x38
eriklomas 28:fdaa7ecfbd80 88 #define FDLPROXR 0x39
eriklomas 28:fdaa7ecfbd80 89 #define MHDPROXF 0x3A
eriklomas 28:fdaa7ecfbd80 90 #define NHDPROXF 0x3B
eriklomas 28:fdaa7ecfbd80 91 #define NCLPROXF 0x3C
eriklomas 28:fdaa7ecfbd80 92 #define FDLPROXF 0x3D
eriklomas 28:fdaa7ecfbd80 93 #define NHDPROXT 0x3E
eriklomas 28:fdaa7ecfbd80 94 #define NCLPROXT 0x3F
eriklomas 28:fdaa7ecfbd80 95 #define FDLPROXT 0x40
eriklomas 28:fdaa7ecfbd80 96 // Electrode Touch/Release thresholds
eriklomas 28:fdaa7ecfbd80 97 #define ELE0_T 0x41
eriklomas 28:fdaa7ecfbd80 98 #define ELE0_R 0x42
eriklomas 28:fdaa7ecfbd80 99 #define ELE1_T 0x43
eriklomas 28:fdaa7ecfbd80 100 #define ELE1_R 0x44
eriklomas 28:fdaa7ecfbd80 101 #define ELE2_T 0x45
eriklomas 28:fdaa7ecfbd80 102 #define ELE2_R 0x46
eriklomas 28:fdaa7ecfbd80 103 #define ELE3_T 0x47
eriklomas 28:fdaa7ecfbd80 104 #define ELE3_R 0x48
eriklomas 28:fdaa7ecfbd80 105 #define ELE4_T 0x49
eriklomas 28:fdaa7ecfbd80 106 #define ELE4_R 0x4A
eriklomas 28:fdaa7ecfbd80 107 #define ELE5_T 0x4B
eriklomas 28:fdaa7ecfbd80 108 #define ELE5_R 0x4C
eriklomas 28:fdaa7ecfbd80 109 #define ELE6_T 0x4D
eriklomas 28:fdaa7ecfbd80 110 #define ELE6_R 0x4E
eriklomas 28:fdaa7ecfbd80 111 #define ELE7_T 0x4F
eriklomas 28:fdaa7ecfbd80 112 #define ELE7_R 0x50
eriklomas 28:fdaa7ecfbd80 113 #define ELE8_T 0x51
eriklomas 28:fdaa7ecfbd80 114 #define ELE8_R 0x52
eriklomas 28:fdaa7ecfbd80 115 #define ELE9_T 0x53
eriklomas 28:fdaa7ecfbd80 116 #define ELE9_R 0x54
eriklomas 28:fdaa7ecfbd80 117 #define ELE10_T 0x55
eriklomas 28:fdaa7ecfbd80 118 #define ELE10_R 0x56
eriklomas 28:fdaa7ecfbd80 119 #define ELE11_T 0x57
eriklomas 28:fdaa7ecfbd80 120 #define ELE11_R 0x58
eriklomas 28:fdaa7ecfbd80 121 // Proximity Touch/Release thresholds
eriklomas 28:fdaa7ecfbd80 122 #define EPROXTTH 0x59
eriklomas 28:fdaa7ecfbd80 123 #define EPROXRTH 0x5A
eriklomas 28:fdaa7ecfbd80 124 // Debounce configuration
eriklomas 28:fdaa7ecfbd80 125 #define DEB_CFG 0x5B
eriklomas 28:fdaa7ecfbd80 126 // AFE- Analogue Front End configuration
eriklomas 28:fdaa7ecfbd80 127 #define AFE_CFG 0x5C
eriklomas 28:fdaa7ecfbd80 128 // Filter configuration
eriklomas 28:fdaa7ecfbd80 129 #define FIL_CFG 0x5D
eriklomas 28:fdaa7ecfbd80 130 // Electrode configuration - transistions to "active mode"
eriklomas 28:fdaa7ecfbd80 131 #define ELE_CFG 0x5E
eriklomas 28:fdaa7ecfbd80 132
eriklomas 28:fdaa7ecfbd80 133 #define GPIO_CTRL0 0x73
eriklomas 28:fdaa7ecfbd80 134 #define GPIO_CTRL1 0x74
eriklomas 28:fdaa7ecfbd80 135 #define GPIO_DATA 0x75
eriklomas 28:fdaa7ecfbd80 136 #define GPIO_DIR 0x76
eriklomas 28:fdaa7ecfbd80 137 #define GPIO_EN 0x77
eriklomas 28:fdaa7ecfbd80 138 #define GPIO_SET 0x78
eriklomas 28:fdaa7ecfbd80 139 #define GPIO_CLEAR 0x79
eriklomas 28:fdaa7ecfbd80 140 #define GPIO_TOGGLE 0x7A
eriklomas 28:fdaa7ecfbd80 141 // Auto configration registers
eriklomas 28:fdaa7ecfbd80 142 #define AUTO_CFG_0 0x7B
eriklomas 28:fdaa7ecfbd80 143 #define AUTO_CFG_U 0x7D
eriklomas 28:fdaa7ecfbd80 144 #define AUTO_CFG_L 0x7E
eriklomas 28:fdaa7ecfbd80 145 #define AUTO_CFG_T 0x7F
eriklomas 28:fdaa7ecfbd80 146
eriklomas 28:fdaa7ecfbd80 147 // Threshold defaults
eriklomas 28:fdaa7ecfbd80 148 // Electrode touch threshold
eriklomas 28:fdaa7ecfbd80 149 #define E_THR_T 0x0F
eriklomas 28:fdaa7ecfbd80 150 // Electrode release threshold
eriklomas 28:fdaa7ecfbd80 151 #define E_THR_R 0x0A
eriklomas 28:fdaa7ecfbd80 152 // Prox touch threshold
eriklomas 28:fdaa7ecfbd80 153 #define PROX_THR_T 0x02
eriklomas 28:fdaa7ecfbd80 154 // Prox release threshold
eriklomas 28:fdaa7ecfbd80 155 #define PROX_THR_R 0x02
eriklomas 28:fdaa7ecfbd80 156
eriklomas 28:fdaa7ecfbd80 157 #endif