Skip to content

Added Airwheel feature to Hover Library … #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Hover/Hover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,19 @@ Gesture Hover::getGesture(void) {
return Gesture(gtype, gid, gval);
}

Airwheel::Airwheel (uint16_t value){
wheelValue = value;
}

Airwheel Hover::getAirWheelData(void){
uint16_t value;
value = _dat[19] << 8 | _dat[18];
return Airwheel(value);
}

void Hover::readGestureData(char * gtype, uint8_t * gid, uint8_t * gval) {


switch (_dat[10]){
case 2:
strcpy(gtype, "Right Swipe");
Expand Down Expand Up @@ -141,7 +152,6 @@ void Hover::readGestureData(char * gtype, uint8_t * gid, uint8_t * gval) {

}


Touch::Touch(){
strcpy(touchType, "none");
touchID = 0;
Expand Down
15 changes: 12 additions & 3 deletions Hover/Hover.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ class Gesture {
uint8_t gestureValue;
};

class Airwheel {
public:
Airwheel(uint16_t wheelValue);
uint16_t wheelValue;
};

class Touch {
public:
Touch();
Expand All @@ -51,15 +57,19 @@ class Position {
uint16_t x, y, z;
};



class Hover {
public:
Hover(uint8_t ts, uint8_t rst, uint8_t gestmode, uint8_t touchmode, uint8_t tapmode, uint8_t posmode);
void begin();
Position getPosition(void);
Gesture getGesture(void);
Airwheel getAirWheelData(void);
Touch getTouch(void);
void readI2CData(void);



private:
boolean _valid;
uint8_t _dat[26], _i2caddr, _ts, _rst, _gestmode, _touchmode, _tapmode, _posmode;
Expand All @@ -68,8 +78,7 @@ class Hover {
void readPositionData(uint16_t *x, uint16_t *y, uint16_t *z);
void readGestureData(char * gtype, uint8_t * gid, uint8_t * gval);
void readTouchData(char * ttype, uint8_t * tid, uint8_t * tval);

};


#endif
#endif
12 changes: 11 additions & 1 deletion Hover/examples/HoverDemo/HoverDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,15 @@
| 3D Position | 0 to 100 | 0 to 100 | 0 to 100 |
-------------------------------------------------------------

=============================================================
| Airwheel Data - 2 bytes
=============================================================
# HISTORY
v1.0 - Initial Release
v2.0 - Standardized Output Definition, On Github
v2.1 - Fixed Count Issue, Update Output String with examples
v3.0 - Major library update -- added 3D Position, Touch, Double Tap
v3.1 - Added Airwheel detection data output feature

# INSTALLATION
The 3 library files (Hover.cpp, Hover.h and keywords.txt) in the Hover folder should be placed in your Arduino Library folder.
Expand Down Expand Up @@ -123,7 +127,13 @@ void loop(void) {
Gesture g = hover.getGesture();
Touch t = hover.getTouch();
Position p = hover.getPosition();

Airwheel a = hover.getAirWheelData();

//Read Airwheel gesture value
if(a.wheelValue)
{
Serial.print("Airwheel: "); Serial.print(a.wheelValue); Serial.print("\r\n");
}
// print Gesture data
if ( g.gestureID != 0){
Serial.print("Event: "); Serial.print(g.gestureType); Serial.print("\t");
Expand Down
3 changes: 2 additions & 1 deletion Hover/keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ readI2CData KEYWORD2
getGesture KEYWORD2
readGestureData KEYWORD2
getTouch KEYWORD2
readTouchData KEYWORD2
readTouchData KEYWORD2
getAirWheelData KEYWORD2