You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
/*
Notice: When you want to recognize the Forward/Backward gestures, your gestures' reaction time must less than GES_ENTRY_TIME(0.8s).
You also can adjust the reaction time according to the actual circumstance.
*/
#define GES_REACTION_TIME 500 // You can adjust the reaction time according to the actual circumstance.
#define GES_ENTRY_TIME 800 // When you want to recognize the Forward/Backward gestures, your gestures' reaction time must less than GES_ENTRY_TIME(0.8s).
#define GES_QUIT_TIME 1000
Serial.begin(9600);
Serial.println("\nPAJ7620U2 TEST DEMO: Recognize 9 gestures.");
error = paj7620Init(); // initialize Paj7620 registers
if (error)
{
Serial.print("INIT ERROR,CODE:");
Serial.println(error);
}
else
{
Serial.println("INIT OK");
}
Serial.println("Please input your gestures:\n");
// clear the internal memory
}
void loop()
{
uint8_t data = 0, data1 = 0, error;
u8g2.setFont(u8g2_font_ncenB10_tr);
error = paj7620ReadReg(0x43, 1, &data); // Read Bank_0_Reg_0x43/0x44 for gesture result.
if (!error)
{
switch (data) // When different gestures be detected, the variable 'data' will be set to different values by paj7620ReadReg(0x43, 1, &data).
{
case GES_RIGHT_FLAG:
delay(GES_ENTRY_TIME);
paj7620ReadReg(0x43, 1, &data);
if(data == GES_FORWARD_FLAG)
{
Serial.println("Forward");
delay(GES_QUIT_TIME);
u8g2.clearBuffer(); // clear the internal memory
u8g2.drawStr(5,10,"Forward"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
}
else if(data == GES_BACKWARD_FLAG)
{
Serial.println("Backward");
delay(GES_QUIT_TIME);
u8g2.drawStr(5,10,"Backward"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
}
else
{
Serial.println("Up");
u8g2.clearBuffer(); // clear the internal memory
u8g2.drawStr(5,10,"Up"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
}
break;
case GES_LEFT_FLAG:
delay(GES_ENTRY_TIME);
paj7620ReadReg(0x43, 1, &data);
if(data == GES_FORWARD_FLAG)
{
Serial.println("Forward");
delay(GES_QUIT_TIME);
u8g2.clearBuffer(); // clear the internal memory
u8g2.drawStr(5,10,"Forward"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
}
else if(data == GES_BACKWARD_FLAG)
{
Serial.println("Backward");
delay(GES_QUIT_TIME);
u8g2.clearBuffer(); // clear the internal memory
u8g2.drawStr(5,10,"Backward"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
}
else
{
Serial.println("Down");
u8g2.clearBuffer(); // clear the internal memory
u8g2.drawStr(5,10,"Down"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
}
break;
case GES_UP_FLAG:
delay(GES_ENTRY_TIME);
paj7620ReadReg(0x43, 1, &data);
if(data == GES_FORWARD_FLAG)
{
Serial.println("Forward");
delay(GES_QUIT_TIME);
u8g2.clearBuffer(); // clear the internal memory
u8g2.drawStr(5,10,"Forward"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
}
else if(data == GES_BACKWARD_FLAG)
{
Serial.println("Backward");
delay(GES_QUIT_TIME);
u8g2.clearBuffer(); // clear the internal memory
u8g2.drawStr(5,10,"Backward"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
}
else
{
Serial.println("Left");
u8g2.clearBuffer(); // clear the internal memory
u8g2.drawStr(5,10,"Left"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
}
break;
case GES_DOWN_FLAG:
delay(GES_ENTRY_TIME);
paj7620ReadReg(0x43, 1, &data);
if(data == GES_FORWARD_FLAG)
{
Serial.println("Forward");
delay(GES_QUIT_TIME);
u8g2.clearBuffer(); // clear the internal memory
u8g2.drawStr(5,10,"Forward"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
}
else if(data == GES_BACKWARD_FLAG)
{
Serial.println("Backward");
delay(GES_QUIT_TIME);
u8g2.clearBuffer(); // clear the internal memory
u8g2.drawStr(5,10,"Backward"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
}
else
{
Serial.println("Right");u8g2.clearBuffer(); // clear the internal memory
u8g2.drawStr(5,10,"Right"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
}
break;
case GES_FORWARD_FLAG:
Serial.println("Forward");u8g2.clearBuffer(); // clear the internal memory
u8g2.drawStr(5,10,"Forward"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
break;
case GES_BACKWARD_FLAG:
Serial.println("Backward");u8g2.clearBuffer(); // clear the internal memory
u8g2.setFont(u8g2_font_ncenB08_tr); // choose a suitable font
u8g2.drawStr(5,10,"Backward"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
break;
case GES_CLOCKWISE_FLAG:
Serial.println("Clockwise");u8g2.clearBuffer(); // clear the internal memory
u8g2.drawStr(5,10,"Clockwise"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
break;
case GES_COUNT_CLOCKWISE_FLAG:
Serial.println("anti-clockwise");u8g2.clearBuffer(); // clear the internal memory
u8g2.drawStr(5,10,"anti-clockwis"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
break;
default:
paj7620ReadReg(0x44, 1, &data1);
if (data1 == GES_WAVE_FLAG)
{
Serial.println("wave");u8g2.clearBuffer(); // clear the internal memory
u8g2.drawStr(5,10,"wave"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
}
break;
}
}
delay(100);
}
The text was updated successfully, but these errors were encountered:
#include <Wire.h>
#include "paj7620.h"
#include <Arduino.h>
#include <U8g2lib.h>
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
/*
Notice: When you want to recognize the Forward/Backward gestures, your gestures' reaction time must less than GES_ENTRY_TIME(0.8s).
You also can adjust the reaction time according to the actual circumstance.
*/
#define GES_REACTION_TIME 500 // You can adjust the reaction time according to the actual circumstance.
#define GES_ENTRY_TIME 800 // When you want to recognize the Forward/Backward gestures, your gestures' reaction time must less than GES_ENTRY_TIME(0.8s).
#define GES_QUIT_TIME 1000
U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=/ SCL, / data=/ SDA, / reset=*/ U8X8_PIN_NONE);
void setup()
{
u8g2.begin();
uint8_t error = 0;
}
void loop()
{
uint8_t data = 0, data1 = 0, error;
u8g2.setFont(u8g2_font_ncenB10_tr);
error = paj7620ReadReg(0x43, 1, &data); // Read Bank_0_Reg_0x43/0x44 for gesture result.
if (!error)
{
switch (data) // When different gestures be detected, the variable 'data' will be set to different values by paj7620ReadReg(0x43, 1, &data).
{
case GES_RIGHT_FLAG:
delay(GES_ENTRY_TIME);
paj7620ReadReg(0x43, 1, &data);
if(data == GES_FORWARD_FLAG)
{
Serial.println("Forward");
delay(GES_QUIT_TIME);
u8g2.clearBuffer(); // clear the internal memory
u8g2.drawStr(5,10,"Forward"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
}
else if(data == GES_BACKWARD_FLAG)
{
Serial.println("Backward");
delay(GES_QUIT_TIME);
u8g2.drawStr(5,10,"Backward"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
}
The text was updated successfully, but these errors were encountered: