Sudoku Game using the LCD, joystick, number pad, and speaker.

Dependencies:   4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player_copy

Fork of rtos_basic by mbed official

Committer:
decfrv
Date:
Thu Nov 03 14:45:00 2016 +0000
Revision:
7:a935e2f5ebd0
Sudoku Game

Who changed what in which revision?

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