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

TouchInfo/TouchInfo.h

Committer:
yangcq88517
Date:
2015-10-07
Revision:
1:621c4e9238ef
Child:
2:c7d984193741

File content as of revision 1:621c4e9238ef:

#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.
*/

class TouchInfo
{
private:
    int value;
    int count;

public:
    static const int TouchSouthElectrode = 0x0100;
    static const int TouchWestElectrode = 0x0200;
    static const int TouchNorthElectrode = 0x0400;
    static const int TouchEastElectrode = 0x0800;
    static const int TouchCenterElectrode = 0x1000;
    static const int TapSouthElectrode = 0x2000;
    static const int TapWestElectrode = 0x4000;
    static const int TapNorthElectrode = 0x8000;
    static const int TapEastElectrode = 0x0001;
    static const int TapCenterElectrode = 0x0002;
    static const int DoubleTapSouthElectrode = 0x0004;
    static const int DoubleTapWestElectrode = 0x0008;
    static const int DoubleTapNorthElectrode = 0x0010;
    static const int DoubleTapEastElectrode = 0x0020;
    static const int DoubleTapCenterElectrode = 0x0040;

    void set(int touchEvent, int counter) {
        value = touchEvent;
        count = 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.
    */
    int getCounter() {
        return count;
    }

    bool isTouchSouthElectrode() {
        return (value & TouchSouthElectrode) == TouchSouthElectrode? true : false;
    }

    bool isTouchWestElectrode() {
        return (value & TouchWestElectrode) == TouchWestElectrode? true : false;
    }

    bool isTouchNorthElectrode() {
        return (value & TouchNorthElectrode) == TouchNorthElectrode? true : false;
    }

    bool isTouchEastElectrode() {
        return (value & TouchEastElectrode) == TouchEastElectrode? true : false;
    }

    bool isTouchCenterElectrode() {
        return (value & TouchCenterElectrode) == TouchCenterElectrode? true : false;
    }

    bool isTapSouthElectrode() {
        return (value & TapSouthElectrode) == TapSouthElectrode? true : false;
    }

    bool isTapWestElectrode() {
        return (value & TapWestElectrode) == TapWestElectrode? true : false;
    }

    bool isTapNorthElectrode() {
        return (value & TapNorthElectrode) == TapNorthElectrode? true : false;
    }

    bool isTapEastElectrode() {
        return (value & TapEastElectrode) == TapEastElectrode? true : false;
    }

    bool isTapCenterElectrode() {
        return (value & TapCenterElectrode) == TapCenterElectrode? true : false;
    }

    bool isDoubleTapSouthElectrode() {
        return (value & DoubleTapSouthElectrode) == DoubleTapSouthElectrode? true : false;
    }

    bool isDoubleTapWestElectrode() {
        return (value & DoubleTapWestElectrode) == DoubleTapWestElectrode? true : false;
    }

    bool isDoubleTapNorthElectrode() {
        return (value & DoubleTapNorthElectrode) == DoubleTapNorthElectrode? true : false;
    }

    bool isDoubleTapEastElectrode() {
        return (value & DoubleTapEastElectrode) == DoubleTapEastElectrode? true : false;
    }

    bool isDoubleTapCenterElectrode() {
        return (value & DoubleTapCenterElectrode) == DoubleTapCenterElectrode? true : false;
    }
};

#endif