Skip to content

Commit

Permalink
Merge pull request #11 from Seeed-Studio/dev
Browse files Browse the repository at this point in the history
Add New sensor
  • Loading branch information
Maxwelltoo authored Jun 19, 2023
2 parents b55872b + 27791bc commit 05e2d6c
Show file tree
Hide file tree
Showing 13 changed files with 931 additions and 763 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Gesture_PAJ7620 [![Build Status](https://travis-ci.com/Seeed-Studio/Gesture_PAJ7620.svg?branch=master)](https://travis-ci.com/Seeed-Studio/Gesture_PAJ7620)
# Grove Gesture [![Build Status](https://travis-ci.com/Seeed-Studio/Gesture_PAJ7620.svg?branch=master)](https://travis-ci.com/Seeed-Studio/Gesture_PAJ7620)

<img src=https://statics3.seeedstudio.com/seeed/img/2016-08/5dxWtS1rxWLzukUaHBvGoIG9.jpg width=300><img src=https://statics3.seeedstudio.com/seeed/img/2016-08/3EmTCa2USbPnqZszQNngy8ss.jpg width=300>

Expand Down
109 changes: 109 additions & 0 deletions examples/pag7660_combined/pag7660_combined.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
Copyright (c) 2023 seeed technology inc.
Website : www.seeed.cc
Author : JX.Weng
Modified Time: June 2023
Description: Get the pag7660 recognition result in combined mode.
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

#include "Gesture.h"

pag7660 Gesture; // Combined mode is used by default

void setup() {
Serial.begin(9600);
while(!Serial) {
delay(100);
}
Serial.println("\nPAG7660 TEST DEMO: Gesture combined mode.");

if(Gesture.init()) {
Serial.println("PAG7660 initialization success");
} else {
Serial.println("PAG7660 initialization failed");
}
Serial.println("Please input your gestures:\n");
}

void loop() {
pag7660_gesture_t result;
if (Gesture.getResult(result)) {
printResultCombinedMode(result);
}
delay(100);
}

void printResultCombinedMode(const pag7660_gesture_t& result) {
const char *cursor_str[] = {
NULL,
"Tap",
"Grab",
"Pinch",
};
switch (result.type) {
case 0:
switch (result.cursor.type) {
case 1:
case 2:
case 3:
if (result.cursor.select)
Serial.println(cursor_str[result.cursor.type]);
break;
default:
break;
}
break;
case 1:
case 2:
case 3:
case 4:
case 5:
Serial.print(result.type);
Serial.println("-finger");
break;
case 6:
Serial.print("Rotate Right ");
Serial.println(result.rotate);
break;
case 7:
Serial.print("Rotate Left ");
Serial.println(result.rotate);
break;
case 8:
Serial.println("Swipe Left");
break;
case 9:
Serial.println("Swipe Right");
break;
case 19:
case 20:
case 21:
case 22:
case 23:
Serial.print(result.type - 19 + 1);
Serial.println("-finger push");
break;
default:
break;
}
}
59 changes: 59 additions & 0 deletions examples/pag7660_thumb/pag7660_thumb.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
Copyright (c) 2023 seeed technology inc.
Website : www.seeed.cc
Author : JX.Weng
Modified Time: June 2023
Description: Get the pag7660 recognition result in thumb mode.
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

#include "Gesture.h"

#define PAG7660_CS D3
pag7660 Gesture(GESTURE_THUMB_MODE); // Thumb mode is used

void setup() {
Serial.begin(9600);
while(!Serial) {
delay(100);
}
Serial.println("\nPAG7660 TEST DEMO: Gesture thumb mode.");

// initialize with a SPI chip select pin number to use SPI
if(Gesture.init(PAG7660_CS)) {
Serial.println("PAG7660 initialization success");
} else {
Serial.println("PAG7660 initialization failed");
}
Serial.println("Please input your gestures:\n");
}

void loop() {
pag7660_gesture_t result;
if (Gesture.getResult(result)) {
if (result.thumb.up)
Serial.println("Thumb Up");
else if (result.thumb.down)
Serial.println("Thumb Down");
}
delay(100);
}
Loading

0 comments on commit 05e2d6c

Please sign in to comment.