“GestureSenso.readGesture()”的版本间的差异
(创建页面,内容为“{| style="width: 800px;" |- | <p style="color: #666666;font-size:220%">'''GestureSensor.begin()'''</p> <br> <p style="color: #E87E05;font-size:135%">描述</p> 手…”) |
502748957@qq.com(讨论 | 贡献) |
||
(未显示另一用户的1个中间版本) | |||
第5行: | 第5行: | ||
<br> | <br> | ||
<p style="color: #E87E05;font-size:135%">描述</p> | <p style="color: #E87E05;font-size:135%">描述</p> | ||
− | + | 读取手势 | |
<p style="color: #E87E05;font-size:135%">参数</p> | <p style="color: #E87E05;font-size:135%">参数</p> | ||
− | + | 无 | |
<p style="color: #E87E05;font-size:135%">返回值</p> | <p style="color: #E87E05;font-size:135%">返回值</p> | ||
无 | 无 | ||
第28行: | 第28行: | ||
} else { | } else { | ||
Serial.println(F("Something went wrong during Gesture init!")); | Serial.println(F("Something went wrong during Gesture init!")); | ||
+ | } | ||
+ | |||
+ | if (gestureSensor.setGestureGain(GGAIN_2X)) { //GGAIN_1X GGAIN_2X GGAIN_4X GGAIN_8X | ||
+ | Serial.println(F("Gesture setGestureGain complete")); | ||
+ | } else { | ||
+ | Serial.println(F("Something went wrong during APDS-9960 setGestureGain!")); | ||
} | } | ||
第39行: | 第45行: | ||
void loop() { | void loop() { | ||
+ | if ( gestureSensor.isGestureAvailable() ) { | ||
+ | switch ( gestureSensor.readGesture() ) { | ||
+ | case DIR_UP: | ||
+ | Serial.println("UP"); | ||
+ | break; | ||
+ | case DIR_DOWN: | ||
+ | Serial.println("DOWN"); | ||
+ | break; | ||
+ | case DIR_LEFT: | ||
+ | Serial.println("LEFT"); | ||
+ | break; | ||
+ | case DIR_RIGHT: | ||
+ | Serial.println("RIGHT"); | ||
+ | break; | ||
+ | case DIR_NEAR: | ||
+ | Serial.println("NEAR"); | ||
+ | break; | ||
+ | case DIR_FAR: | ||
+ | Serial.println("FAR"); | ||
+ | break; | ||
+ | default: | ||
+ | Serial.println("NONE"); | ||
+ | } | ||
+ | } | ||
} | } | ||
</source> | </source> | ||
<p style="color: #E87E05;font-size:135%">其他</p> | <p style="color: #E87E05;font-size:135%">其他</p> | ||
− | *[[ | + | *[[GestureSensor.begin()|begin()]] |
*[[gestureSensor.setGestureGain()|setGestureGain()]] | *[[gestureSensor.setGestureGain()|setGestureGain()]] | ||
*[[gestureSensor.enableGestureSensor()|enableGestureSensor()]] | *[[gestureSensor.enableGestureSensor()|enableGestureSensor()]] |
2018年5月16日 (三) 09:40的最新版本
GestureSensor.begin()
描述 读取手势 参数 无 返回值 无 示例 #include <Microduino_Gesture.h>
// Global Variables
Gesture gestureSensor;
void setup() {
// Initialize Serial port
Serial.begin(9600);
// Initialize Gesture (configure I2C and initial values)
if ( gestureSensor.begin() ) {
Serial.println(F("Gesture initialization complete"));
} else {
Serial.println(F("Something went wrong during Gesture init!"));
}
if (gestureSensor.setGestureGain(GGAIN_2X)) { //GGAIN_1X GGAIN_2X GGAIN_4X GGAIN_8X
Serial.println(F("Gesture setGestureGain complete"));
} else {
Serial.println(F("Something went wrong during APDS-9960 setGestureGain!"));
}
// Start running the Gesture gesture sensor engine
if ( gestureSensor.enableGestureSensor(true) ) {
Serial.println(F("Gesture sensor is now running"));
} else {
Serial.println(F("Something went wrong during gesture sensor init!"));
}
}
void loop() {
if ( gestureSensor.isGestureAvailable() ) {
switch ( gestureSensor.readGesture() ) {
case DIR_UP:
Serial.println("UP");
break;
case DIR_DOWN:
Serial.println("DOWN");
break;
case DIR_LEFT:
Serial.println("LEFT");
break;
case DIR_RIGHT:
Serial.println("RIGHT");
break;
case DIR_NEAR:
Serial.println("NEAR");
break;
case DIR_FAR:
Serial.println("FAR");
break;
default:
Serial.println("NONE");
}
}
}
其他 |