The purpose of this project was to create a system that would allow users to monitor a locked device using a Bluetooth device. This Bluetooth device will show the last user that unlocked the device, and also allows the user to unlock the device using the Bluetooth device. This device can be physically unlocked using a capacitive touch keypad sensor.

Dependencies:   mbed Motor Servo

Fork of SerialPassthrough_LPC1768 by jim hamblen

Committer:
ewilliams61
Date:
Tue Mar 15 19:14:45 2016 +0000
Revision:
7:79d0b30fedb4
Works :)

Who changed what in which revision?

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