The MGC3130 is the world’s first electrical-field (E-field) based three-dimensional (3D) tracking and gesture controller
Dependents: NucleoMGC3130 i2c_master
Diff: TouchInfo/TouchInfo.h
- Revision:
- 2:c7d984193741
- Parent:
- 1:621c4e9238ef
--- a/TouchInfo/TouchInfo.h Wed Oct 07 20:43:39 2015 +0000 +++ b/TouchInfo/TouchInfo.h Thu Oct 08 11:14:18 2015 +0000 @@ -1,40 +1,41 @@ #ifndef UK_AC_HERTS_SMARTLAB_MGC3130_TouchInfo #define UK_AC_HERTS_SMARTLAB_MGC3130_TouchInfo -/* -Bit 0: Touch South electrode -Bit 1: Touch West electrode -Bit 2: Touch North electrode -Bit 3: Touch East electrode -Bit 4: Touch Center electrode -Bit 5: Tap South electrode -Bit 6: Tap West electrode -Bit 7: Tap North electrode -Bit 8: Tap East electrode -Bit 9: Tap Center electrode -Bit 10: Double Tap South electrode -Bit 11: Double Tap West electrode -Bit 12: Double Tap North electrode -Bit 13: Double Tap East electrode -Bit 14: Double Tap Center electrode -Bit 15: This bit is reserved. -Bits 16...23:Touch Counter: 8-bit counter; this counter determines the -period between the time when the hand starts moving to -touch until it is detected. This period is equal to [Touch -Counter Value] x 5 (ms). The counter starts counting when -the minimum approach speed required to detect a touch -event is exceeded, until the touch is detected. After each -touch detection, the counter is reset. -Bits 24...31:These bits are reserved. -*/ - +/// Contains touch information class TouchInfo { private: + /** 2 bytes bit mask + *Bit 0: Touch South electrode + *Bit 1: Touch West electrode + *Bit 2: Touch North electrode + *Bit 3: Touch East electrode + *Bit 4: Touch Center electrode + *Bit 5: Tap South electrode + *Bit 6: Tap West electrode + *Bit 7: Tap North electrode + *Bit 8: Tap East electrode + *Bit 9: Tap Center electrode + *Bit 10: Double Tap South electrode + *Bit 11: Double Tap West electrode + *Bit 12: Double Tap North electrode + *Bit 13: Double Tap East electrode + *Bit 14: Double Tap Center electrode + *Bit 15: This bit is reserved. + */ int value; + + /** Bits 16...23:Touch Counter: 8-bit counter; this counter determines the + *period between the time when the hand starts moving to + *touch until it is detected. This period is equal to [Touch + *Counter Value] x 5 (ms). The counter starts counting when + *the minimum approach speed required to detect a touch + *event is exceeded, until the touch is detected. After each + *touch detection, the counter is reset. + *Bits 24...31:These bits are reserved. + */ int count; - -public: + static const int TouchSouthElectrode = 0x0100; static const int TouchWestElectrode = 0x0200; static const int TouchNorthElectrode = 0x0400; @@ -51,83 +52,146 @@ static const int DoubleTapEastElectrode = 0x0020; static const int DoubleTapCenterElectrode = 0x0040; - void set(int touchEvent, int counter) { - value = touchEvent; - count = counter; - } +public: + /** Set the internal memory, used by API itself. + * + * @param touchEvent 2 bytes bit mask + * @param counter 1 byte + */ + void set(int touchEvent, int counter); - /* - Touch Counter: 8-bit counter; this counter determines the - period between the time when the hand starts moving to - touch until it is detected. This period is equal to [Touch - Counter Value] x 5 (ms). The counter starts counting when - the minimum approach speed required to detect a touch - event is exceeded, until the touch is detected. After each - touch detection, the counter is reset. + /** + *Touch Counter: this counter determines the + *period between the time when the hand starts moving to + *touch until it is detected. This period is equal to [Touch + *Counter Value] x 5 (ms). The counter starts counting when + *the minimum approach speed required to detect a touch + *event is exceeded, until the touch is detected. After each + *touch detection, the counter is reset. + * + * @returns 8-bit counter */ - int getCounter() { - return count; - } + int getCounter(); + + /** Check if touch south electrode is detected. + * + * @returns + * true qualified + * false not qualified + */ + bool isTouchSouthElectrode(); - bool isTouchSouthElectrode() { - return (value & TouchSouthElectrode) == TouchSouthElectrode? true : false; - } + /** Check if touch west electrode is detected. + * + * @returns + * true qualified + * false not qualified + */ + bool isTouchWestElectrode(); - bool isTouchWestElectrode() { - return (value & TouchWestElectrode) == TouchWestElectrode? true : false; - } + /** Check if touch north electrode is detected. + * + * @returns + * true qualified + * false not qualified + */ + bool isTouchNorthElectrode(); - bool isTouchNorthElectrode() { - return (value & TouchNorthElectrode) == TouchNorthElectrode? true : false; - } + /** Check if touch east electrode is detected. + * + * @returns + * true qualified + * false not qualified + */ + bool isTouchEastElectrode(); - bool isTouchEastElectrode() { - return (value & TouchEastElectrode) == TouchEastElectrode? true : false; - } + /** Check if touch center electrode is detected. + * + * @returns + * true qualified + * false not qualified + */ + bool isTouchCenterElectrode(); - bool isTouchCenterElectrode() { - return (value & TouchCenterElectrode) == TouchCenterElectrode? true : false; - } + /** Check if tap south electrode is detected. + * + * @returns + * true qualified + * false not qualified + */ + bool isTapSouthElectrode(); - bool isTapSouthElectrode() { - return (value & TapSouthElectrode) == TapSouthElectrode? true : false; - } + /** Check if tap west electrode is detected. + * + * @returns + * true qualified + * false not qualified + */ + bool isTapWestElectrode(); - bool isTapWestElectrode() { - return (value & TapWestElectrode) == TapWestElectrode? true : false; - } + /** Check if tap north electrode is detected. + * + * @returns + * true qualified + * false not qualified + */ + bool isTapNorthElectrode(); - bool isTapNorthElectrode() { - return (value & TapNorthElectrode) == TapNorthElectrode? true : false; - } + /** Check if tap east electrode is detected. + * + * @returns + * true qualified + * false not qualified + */ + bool isTapEastElectrode(); - bool isTapEastElectrode() { - return (value & TapEastElectrode) == TapEastElectrode? true : false; - } - - bool isTapCenterElectrode() { - return (value & TapCenterElectrode) == TapCenterElectrode? true : false; - } + /** Check if tap center electrode is detected. + * + * @returns + * true qualified + * false not qualified + */ + bool isTapCenterElectrode(); - bool isDoubleTapSouthElectrode() { - return (value & DoubleTapSouthElectrode) == DoubleTapSouthElectrode? true : false; - } + /** Check if double tap south electrode is detected. + * + * @returns + * true qualified + * false not qualified + */ + bool isDoubleTapSouthElectrode(); - bool isDoubleTapWestElectrode() { - return (value & DoubleTapWestElectrode) == DoubleTapWestElectrode? true : false; - } + /** Check if double tap west electrode is detected. + * + * @returns + * true qualified + * false not qualified + */ + bool isDoubleTapWestElectrode(); - bool isDoubleTapNorthElectrode() { - return (value & DoubleTapNorthElectrode) == DoubleTapNorthElectrode? true : false; - } + /** Check if double tap north electrode is detected. + * + * @returns + * true qualified + * false not qualified + */ + bool isDoubleTapNorthElectrode(); - bool isDoubleTapEastElectrode() { - return (value & DoubleTapEastElectrode) == DoubleTapEastElectrode? true : false; - } + /** Check if double tap east electrode is detected. + * + * @returns + * true qualified + * false not qualified + */ + bool isDoubleTapEastElectrode(); - bool isDoubleTapCenterElectrode() { - return (value & DoubleTapCenterElectrode) == DoubleTapCenterElectrode? true : false; - } + /** Check if double tap center electrode is detected. + * + * @returns + * true qualified + * false not qualified + */ + bool isDoubleTapCenterElectrode(); }; #endif \ No newline at end of file