The MGC3130 is the world’s first electrical-field (E-field) based three-dimensional (3D) tracking and gesture controller

Dependencies:   BufferedArray

Dependents:   NucleoMGC3130 i2c_master

Committer:
yangcq88517
Date:
Wed Oct 07 20:43:39 2015 +0000
Revision:
1:621c4e9238ef
Child:
2:c7d984193741
add new functions

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yangcq88517 1:621c4e9238ef 1 #ifndef UK_AC_HERTS_SMARTLAB_MGC3130_TouchInfo
yangcq88517 1:621c4e9238ef 2 #define UK_AC_HERTS_SMARTLAB_MGC3130_TouchInfo
yangcq88517 1:621c4e9238ef 3
yangcq88517 1:621c4e9238ef 4 /*
yangcq88517 1:621c4e9238ef 5 Bit 0: Touch South electrode
yangcq88517 1:621c4e9238ef 6 Bit 1: Touch West electrode
yangcq88517 1:621c4e9238ef 7 Bit 2: Touch North electrode
yangcq88517 1:621c4e9238ef 8 Bit 3: Touch East electrode
yangcq88517 1:621c4e9238ef 9 Bit 4: Touch Center electrode
yangcq88517 1:621c4e9238ef 10 Bit 5: Tap South electrode
yangcq88517 1:621c4e9238ef 11 Bit 6: Tap West electrode
yangcq88517 1:621c4e9238ef 12 Bit 7: Tap North electrode
yangcq88517 1:621c4e9238ef 13 Bit 8: Tap East electrode
yangcq88517 1:621c4e9238ef 14 Bit 9: Tap Center electrode
yangcq88517 1:621c4e9238ef 15 Bit 10: Double Tap South electrode
yangcq88517 1:621c4e9238ef 16 Bit 11: Double Tap West electrode
yangcq88517 1:621c4e9238ef 17 Bit 12: Double Tap North electrode
yangcq88517 1:621c4e9238ef 18 Bit 13: Double Tap East electrode
yangcq88517 1:621c4e9238ef 19 Bit 14: Double Tap Center electrode
yangcq88517 1:621c4e9238ef 20 Bit 15: This bit is reserved.
yangcq88517 1:621c4e9238ef 21 Bits 16...23:Touch Counter: 8-bit counter; this counter determines the
yangcq88517 1:621c4e9238ef 22 period between the time when the hand starts moving to
yangcq88517 1:621c4e9238ef 23 touch until it is detected. This period is equal to [Touch
yangcq88517 1:621c4e9238ef 24 Counter Value] x 5 (ms). The counter starts counting when
yangcq88517 1:621c4e9238ef 25 the minimum approach speed required to detect a touch
yangcq88517 1:621c4e9238ef 26 event is exceeded, until the touch is detected. After each
yangcq88517 1:621c4e9238ef 27 touch detection, the counter is reset.
yangcq88517 1:621c4e9238ef 28 Bits 24...31:These bits are reserved.
yangcq88517 1:621c4e9238ef 29 */
yangcq88517 1:621c4e9238ef 30
yangcq88517 1:621c4e9238ef 31 class TouchInfo
yangcq88517 1:621c4e9238ef 32 {
yangcq88517 1:621c4e9238ef 33 private:
yangcq88517 1:621c4e9238ef 34 int value;
yangcq88517 1:621c4e9238ef 35 int count;
yangcq88517 1:621c4e9238ef 36
yangcq88517 1:621c4e9238ef 37 public:
yangcq88517 1:621c4e9238ef 38 static const int TouchSouthElectrode = 0x0100;
yangcq88517 1:621c4e9238ef 39 static const int TouchWestElectrode = 0x0200;
yangcq88517 1:621c4e9238ef 40 static const int TouchNorthElectrode = 0x0400;
yangcq88517 1:621c4e9238ef 41 static const int TouchEastElectrode = 0x0800;
yangcq88517 1:621c4e9238ef 42 static const int TouchCenterElectrode = 0x1000;
yangcq88517 1:621c4e9238ef 43 static const int TapSouthElectrode = 0x2000;
yangcq88517 1:621c4e9238ef 44 static const int TapWestElectrode = 0x4000;
yangcq88517 1:621c4e9238ef 45 static const int TapNorthElectrode = 0x8000;
yangcq88517 1:621c4e9238ef 46 static const int TapEastElectrode = 0x0001;
yangcq88517 1:621c4e9238ef 47 static const int TapCenterElectrode = 0x0002;
yangcq88517 1:621c4e9238ef 48 static const int DoubleTapSouthElectrode = 0x0004;
yangcq88517 1:621c4e9238ef 49 static const int DoubleTapWestElectrode = 0x0008;
yangcq88517 1:621c4e9238ef 50 static const int DoubleTapNorthElectrode = 0x0010;
yangcq88517 1:621c4e9238ef 51 static const int DoubleTapEastElectrode = 0x0020;
yangcq88517 1:621c4e9238ef 52 static const int DoubleTapCenterElectrode = 0x0040;
yangcq88517 1:621c4e9238ef 53
yangcq88517 1:621c4e9238ef 54 void set(int touchEvent, int counter) {
yangcq88517 1:621c4e9238ef 55 value = touchEvent;
yangcq88517 1:621c4e9238ef 56 count = counter;
yangcq88517 1:621c4e9238ef 57 }
yangcq88517 1:621c4e9238ef 58
yangcq88517 1:621c4e9238ef 59 /*
yangcq88517 1:621c4e9238ef 60 Touch Counter: 8-bit counter; this counter determines the
yangcq88517 1:621c4e9238ef 61 period between the time when the hand starts moving to
yangcq88517 1:621c4e9238ef 62 touch until it is detected. This period is equal to [Touch
yangcq88517 1:621c4e9238ef 63 Counter Value] x 5 (ms). The counter starts counting when
yangcq88517 1:621c4e9238ef 64 the minimum approach speed required to detect a touch
yangcq88517 1:621c4e9238ef 65 event is exceeded, until the touch is detected. After each
yangcq88517 1:621c4e9238ef 66 touch detection, the counter is reset.
yangcq88517 1:621c4e9238ef 67 */
yangcq88517 1:621c4e9238ef 68 int getCounter() {
yangcq88517 1:621c4e9238ef 69 return count;
yangcq88517 1:621c4e9238ef 70 }
yangcq88517 1:621c4e9238ef 71
yangcq88517 1:621c4e9238ef 72 bool isTouchSouthElectrode() {
yangcq88517 1:621c4e9238ef 73 return (value & TouchSouthElectrode) == TouchSouthElectrode? true : false;
yangcq88517 1:621c4e9238ef 74 }
yangcq88517 1:621c4e9238ef 75
yangcq88517 1:621c4e9238ef 76 bool isTouchWestElectrode() {
yangcq88517 1:621c4e9238ef 77 return (value & TouchWestElectrode) == TouchWestElectrode? true : false;
yangcq88517 1:621c4e9238ef 78 }
yangcq88517 1:621c4e9238ef 79
yangcq88517 1:621c4e9238ef 80 bool isTouchNorthElectrode() {
yangcq88517 1:621c4e9238ef 81 return (value & TouchNorthElectrode) == TouchNorthElectrode? true : false;
yangcq88517 1:621c4e9238ef 82 }
yangcq88517 1:621c4e9238ef 83
yangcq88517 1:621c4e9238ef 84 bool isTouchEastElectrode() {
yangcq88517 1:621c4e9238ef 85 return (value & TouchEastElectrode) == TouchEastElectrode? true : false;
yangcq88517 1:621c4e9238ef 86 }
yangcq88517 1:621c4e9238ef 87
yangcq88517 1:621c4e9238ef 88 bool isTouchCenterElectrode() {
yangcq88517 1:621c4e9238ef 89 return (value & TouchCenterElectrode) == TouchCenterElectrode? true : false;
yangcq88517 1:621c4e9238ef 90 }
yangcq88517 1:621c4e9238ef 91
yangcq88517 1:621c4e9238ef 92 bool isTapSouthElectrode() {
yangcq88517 1:621c4e9238ef 93 return (value & TapSouthElectrode) == TapSouthElectrode? true : false;
yangcq88517 1:621c4e9238ef 94 }
yangcq88517 1:621c4e9238ef 95
yangcq88517 1:621c4e9238ef 96 bool isTapWestElectrode() {
yangcq88517 1:621c4e9238ef 97 return (value & TapWestElectrode) == TapWestElectrode? true : false;
yangcq88517 1:621c4e9238ef 98 }
yangcq88517 1:621c4e9238ef 99
yangcq88517 1:621c4e9238ef 100 bool isTapNorthElectrode() {
yangcq88517 1:621c4e9238ef 101 return (value & TapNorthElectrode) == TapNorthElectrode? true : false;
yangcq88517 1:621c4e9238ef 102 }
yangcq88517 1:621c4e9238ef 103
yangcq88517 1:621c4e9238ef 104 bool isTapEastElectrode() {
yangcq88517 1:621c4e9238ef 105 return (value & TapEastElectrode) == TapEastElectrode? true : false;
yangcq88517 1:621c4e9238ef 106 }
yangcq88517 1:621c4e9238ef 107
yangcq88517 1:621c4e9238ef 108 bool isTapCenterElectrode() {
yangcq88517 1:621c4e9238ef 109 return (value & TapCenterElectrode) == TapCenterElectrode? true : false;
yangcq88517 1:621c4e9238ef 110 }
yangcq88517 1:621c4e9238ef 111
yangcq88517 1:621c4e9238ef 112 bool isDoubleTapSouthElectrode() {
yangcq88517 1:621c4e9238ef 113 return (value & DoubleTapSouthElectrode) == DoubleTapSouthElectrode? true : false;
yangcq88517 1:621c4e9238ef 114 }
yangcq88517 1:621c4e9238ef 115
yangcq88517 1:621c4e9238ef 116 bool isDoubleTapWestElectrode() {
yangcq88517 1:621c4e9238ef 117 return (value & DoubleTapWestElectrode) == DoubleTapWestElectrode? true : false;
yangcq88517 1:621c4e9238ef 118 }
yangcq88517 1:621c4e9238ef 119
yangcq88517 1:621c4e9238ef 120 bool isDoubleTapNorthElectrode() {
yangcq88517 1:621c4e9238ef 121 return (value & DoubleTapNorthElectrode) == DoubleTapNorthElectrode? true : false;
yangcq88517 1:621c4e9238ef 122 }
yangcq88517 1:621c4e9238ef 123
yangcq88517 1:621c4e9238ef 124 bool isDoubleTapEastElectrode() {
yangcq88517 1:621c4e9238ef 125 return (value & DoubleTapEastElectrode) == DoubleTapEastElectrode? true : false;
yangcq88517 1:621c4e9238ef 126 }
yangcq88517 1:621c4e9238ef 127
yangcq88517 1:621c4e9238ef 128 bool isDoubleTapCenterElectrode() {
yangcq88517 1:621c4e9238ef 129 return (value & DoubleTapCenterElectrode) == DoubleTapCenterElectrode? true : false;
yangcq88517 1:621c4e9238ef 130 }
yangcq88517 1:621c4e9238ef 131 };
yangcq88517 1:621c4e9238ef 132
yangcq88517 1:621c4e9238ef 133 #endif