63 #if defined(__AVR__) || defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
64 #define PROGMEM_COMPATIBLE
119 #define PAJ7620_I2C_BUS_ADDR 0x73
122 #define PAJ7620_ADDR_BASE 0x00
125 #define PAJ7620_REGISTER_BANK_SEL (PAJ7620_ADDR_BASE + 0xEF)
132 #define PAJ7620_PART_ID_LSB 0x20
133 #define PAJ7620_PART_ID_MSB 0x76
141 #define PAJ7620_ADDR_PART_ID_0 (PAJ7620_ADDR_BASE + 0x00)
143 #define PAJ7620_ADDR_PART_ID_1 (PAJ7620_ADDR_BASE + 0x01)
145 #define PAJ7620_ADDR_SUSPEND_CMD (PAJ7620_ADDR_BASE + 0x03)
147 #define PAJ7620_ADDR_GES_PS_DET_MASK_0 (PAJ7620_ADDR_BASE + 0x41)
149 #define PAJ7620_ADDR_GES_PS_DET_MASK_1 (PAJ7620_ADDR_BASE + 0x42)
151 #define PAJ7620_ADDR_GES_PS_DET_FLAG_0 (PAJ7620_ADDR_BASE + 0x43)
153 #define PAJ7620_ADDR_GES_PS_DET_FLAG_1 (PAJ7620_ADDR_BASE + 0x44)
155 #define PAJ7620_ADDR_STATE_INDICATOR (PAJ7620_ADDR_BASE + 0x45)
157 #define PAJ7620_ADDR_PS_HIGH_THRESHOLD (PAJ7620_ADDR_BASE + 0x69)
159 #define PAJ7620_ADDR_PS_LOW_THRESHOLD (PAJ7620_ADDR_BASE + 0x6A)
161 #define PAJ7620_ADDR_PS_APPROACH_STATE (PAJ7620_ADDR_BASE + 0x6B)
163 #define PAJ7620_ADDR_PS_RAW_DATA (PAJ7620_ADDR_BASE + 0x6C)
165 #define PAJ7620_ADDR_OBJECT_CENTER_X_LSB (PAJ7620_ADDR_BASE + 0xAC)
167 #define PAJ7620_ADDR_OBJECT_CENTER_X_MSB (PAJ7620_ADDR_BASE + 0xAD)
169 #define PAJ7620_ADDR_OBJECT_CENTER_Y_LSB (PAJ7620_ADDR_BASE + 0xAE)
171 #define PAJ7620_ADDR_OBJECT_CENTER_Y_MSB (PAJ7620_ADDR_BASE + 0xAF)
173 #define PAJ7620_ADDR_OBJECT_BRIGHTNESS (PAJ7620_ADDR_BASE + 0xB0)
175 #define PAJ7620_ADDR_OBJECT_SIZE_LSB (PAJ7620_ADDR_BASE + 0xB1)
177 #define PAJ7620_ADDR_OBJECT_SIZE_MSB (PAJ7620_ADDR_BASE + 0xB2)
179 #define PAJ7620_ADDR_WAVE_COUNT (PAJ7620_ADDR_BASE + 0xB7)
181 #define PAJ7620_ADDR_NO_OBJECT_COUNT (PAJ7620_ADDR_BASE + 0xB8)
183 #define PAJ7620_ADDR_NO_MOTION_COUNT (PAJ7620_ADDR_BASE + 0xB9)
185 #define PAJ7620_ADDR_OBJECT_VEL_X_LSB (PAJ7620_ADDR_BASE + 0xC3)
187 #define PAJ7620_ADDR_OBJECT_VEL_X_MSB (PAJ7620_ADDR_BASE + 0xC4)
189 #define PAJ7620_ADDR_OBJECT_VEL_Y_LSB (PAJ7620_ADDR_BASE + 0xC5)
191 #define PAJ7620_ADDR_OBJECT_VEL_Y_MSB (PAJ7620_ADDR_BASE + 0xC6)
193 #define PAJ7620_ADDR_GES_RESULT_0 (PAJ7620_ADDR_BASE + 0x43)
195 #define PAJ7620_ADDR_GES_RESULT_1 (PAJ7620_ADDR_BASE + 0x44)
199 #define PAJ7620_ADDR_CURSOR_X_LOW (PAJ7620_ADDR_BASE + 0x3B)
201 #define PAJ7620_ADDR_CURSOR_X_HIGH (PAJ7620_ADDR_BASE + 0x3C)
203 #define PAJ7620_ADDR_CURSOR_Y_LOW (PAJ7620_ADDR_BASE + 0x3D)
205 #define PAJ7620_ADDR_CURSOR_Y_HIGH (PAJ7620_ADDR_BASE + 0x3E)
207 #define PAJ7620_ADDR_CURSOR_INT (PAJ7620_ADDR_BASE + 0x44)
215 #define PAJ7620_ADDR_PS_APPROACH_STATE (PAJ7620_ADDR_BASE + 0x6B)
217 #define PAJ7620_ADDR_S_AVE_Y_BRIGHTNESS (PAJ7620_ADDR_BASE + 0x6C)
226 #define PAJ7620_ADDR_PS_GAIN (PAJ7620_ADDR_BASE + 0x44)
228 #define PAJ7620_ADDR_R_IDLE_TIME_0 (PAJ7620_ADDR_BASE + 0x65)
230 #define PAJ7620_ADDR_R_IDLE_TIME_1 (PAJ7620_ADDR_BASE + 0x66)
232 #define PAJ7620_ADDR_IDLE_S1_STEP_0 (PAJ7620_ADDR_BASE + 0x67)
234 #define PAJ7620_ADDR_IDLE_S1_STEP_1 (PAJ7620_ADDR_BASE + 0x68)
236 #define PAJ7620_ADDR_IDLE_S2_STEP_0 (PAJ7620_ADDR_BASE + 0x69)
238 #define PAJ7620_ADDR_IDLE_S2_STEP_1 (PAJ7620_ADDR_BASE + 0x6A)
240 #define PAJ7620_ADDR_OP_TO_S1_STEP_0 (PAJ7620_ADDR_BASE + 0x6B)
242 #define PAJ7620_ADDR_OP_TO_S1_STEP_1 (PAJ7620_ADDR_BASE + 0x6C)
244 #define PAJ7620_ADDR_OP_TO_S2_STEP_0 (PAJ7620_ADDR_BASE + 0x6D)
246 #define PAJ7620_ADDR_OP_TO_S2_STEP_1 (PAJ7620_ADDR_BASE + 0x6E)
248 #define PAJ7620_ADDR_OPERATION_ENABLE (PAJ7620_ADDR_BASE + 0x72)
252 #define PAJ7620_ADDR_LENS_ORIENTATION (PAJ7620_ADDR_BASE + 0x04)
257 #define PAJ7620_BANK0 0x00
258 #define PAJ7620_BANK1 0x01
266 #define PAJ7620_I2C_WAKEUP 0x01
268 #define PAJ7620_I2C_SUSPEND 0x00
276 #define PAJ7620_ENABLE 0x01
278 #define PAJ7620_DISABLE 0x00
287 #define PAJ7620_NORMAL_SPEED 0xAC
289 #define PAJ7620_GAME_SPEED 0x30
301 #define GES_UP_FLAG 0x01
303 #define GES_DOWN_FLAG 0x02
305 #define GES_LEFT_FLAG 0x04
307 #define GES_RIGHT_FLAG 0x08
309 #define GES_FORWARD_FLAG 0x10
311 #define GES_BACKWARD_FLAG 0x20
313 #define GES_CLOCKWISE_FLAG 0x40
315 #define GES_ANTI_CLOCKWISE_FLAG 0x80
317 #define GES_WAVE_FLAG 0x01
322 #define CUR_HAS_OBJECT 0x04
323 #define CUR_NO_OBJECT 0x80
327 #define GESTURE_RANGE_MAX 3712
328 #define GESTURE_RANGE_MIN 0
329 #define GESTURE_RANGE_MID ((GESTURE_RANGE_MAX - GESTURE_RANGE_MIN) / 2)
330 #define CORNERS_BUFFER_WIDTH_PCT 0.20
331 #define CORNERS_BUFFER_WIDTH (int)((GESTURE_RANGE_MAX - GESTURE_RANGE_MIN) * CORNERS_BUFFER_WIDTH_PCT)
332 #define CORNERS_BUFFER_LOWER (int)(GESTURE_RANGE_MID - (CORNERS_BUFFER_WIDTH / 2))
333 #define CORNERS_BUFFER_UPPER (int)(GESTURE_RANGE_MID + (CORNERS_BUFFER_WIDTH / 2))
337 #define INIT_REG_ARRAY_SIZE (sizeof(initRegisterArray)/sizeof(initRegisterArray[0]))
344 #ifdef PROGMEM_COMPATIBLE
408 #define SET_GES_MODE_REG_ARRAY_SIZE (sizeof(setGestureModeRegisterArray)/sizeof(setGestureModeRegisterArray[0]))
415 #ifdef PROGMEM_COMPATIBLE
453 #define SET_CURSOR_MODE_REG_ARRAY_SIZE (sizeof(setCursorModeRegisterArray)/sizeof(setCursorModeRegisterArray[0]))
460 #ifdef PROGMEM_COMPATIBLE
510 uint8_t
begin(TwoWire * chosenWireHandle);
571 unsigned long gestureEntryTime;
572 unsigned long gestureExitTime;
576 uint8_t writeRegister(uint8_t i2cAddress, uint8_t dataByte);
577 uint8_t readRegister(uint8_t i2cAddress, uint8_t byteCount, uint8_t data[]);
579 void selectRegisterBank(
Bank_e bank);
581 uint8_t getGesturesReg0(uint8_t data[]);
582 uint8_t getGesturesReg1(uint8_t data[]);
586 bool isPAJ7620UDevice();
587 void initializeDeviceSettings();
589 void writeRegisterArray(
const unsigned short array[],
int arraySize);
const unsigned short setGestureModeRegisterArray[]
Gesture mode specific register addresses and values.
Definition: RevEng_PAJ7620.h:418
Gesture
Gesture result definitions.
Definition: RevEng_PAJ7620.h:72
@ GES_BACKWARD
Backward gesture.
Definition: RevEng_PAJ7620.h:79
@ GES_NONE
No gesture.
Definition: RevEng_PAJ7620.h:73
@ GES_WAVE
Wave gesture.
Definition: RevEng_PAJ7620.h:82
@ GES_RIGHT
Rightward gesture.
Definition: RevEng_PAJ7620.h:77
@ GES_LEFT
Leftward gesture.
Definition: RevEng_PAJ7620.h:76
@ GES_FORWARD
Forward gesture.
Definition: RevEng_PAJ7620.h:78
@ GES_CLOCKWISE
Clockwise circular gesture.
Definition: RevEng_PAJ7620.h:80
@ GES_DOWN
Downward gesture.
Definition: RevEng_PAJ7620.h:75
@ GES_UP
Upwards gesture.
Definition: RevEng_PAJ7620.h:74
@ GES_ANTICLOCKWISE
Anticlockwise circular gesture.
Definition: RevEng_PAJ7620.h:81
const unsigned short initRegisterArray[]
Initial device register addresses and values.
Definition: RevEng_PAJ7620.h:347
const unsigned short setCursorModeRegisterArray[]
Cursor mode specific register addresses and values.
Definition: RevEng_PAJ7620.h:463
Bank_e
Used for selecting PAJ7620 memory bank to read/write from.
Definition: RevEng_PAJ7620.h:90
@ BANK1
Memory bank 1.
Definition: RevEng_PAJ7620.h:92
@ BANK0
Memory bank 0.
Definition: RevEng_PAJ7620.h:91
Corner
Used for reading the corners in corners mode and PIN mode.
Definition: RevEng_PAJ7620.h:100
@ QUADRANT_II
Object in cartesian quadrant II (NW)
Definition: RevEng_PAJ7620.h:109
@ CORNER_SW
Object in SW quadrant.
Definition: RevEng_PAJ7620.h:104
@ CORNER_NONE
No object in view.
Definition: RevEng_PAJ7620.h:101
@ QUADRANT_I
Object in cartesian quadrant I (NE)
Definition: RevEng_PAJ7620.h:108
@ QUADRANT_IV
Object in cartesian quadrant IV (SE)
Definition: RevEng_PAJ7620.h:111
@ QUADRANT_NONE
No object in view.
Definition: RevEng_PAJ7620.h:107
@ CORNER_MIDDLE
Object in between quadrants.
Definition: RevEng_PAJ7620.h:106
@ QUADRANT_III
Object in cartesian quadrant III (SW)
Definition: RevEng_PAJ7620.h:110
@ CORNER_SE
Object in SE quadrant.
Definition: RevEng_PAJ7620.h:105
@ CORNER_NE
Object in NE quadrant.
Definition: RevEng_PAJ7620.h:102
@ CORNER_NW
Object in NW quadrant.
Definition: RevEng_PAJ7620.h:103
PAJ7620 Device API class - As developed by RevEng Devs.
Definition: RevEng_PAJ7620.h:507
int getObjectVelocityY()
Gets object's current Y velocity's value.
Definition: RevEng_PAJ7620.cpp:849
void disable()
Disables sensor for reading & interrupts.
Definition: RevEng_PAJ7620.cpp:433
int getObjectVelocityY_raw()
Gets object's current Y velocity's raw value.
Definition: RevEng_PAJ7620.cpp:805
int getObjectCenterY()
Gets Gesture object's current Y location.
Definition: RevEng_PAJ7620.cpp:757
void setGestureEntryTime(unsigned long newGestureEntryTime)
Sets time sensor waits between getGesture call to reading gesture from sensor.
Definition: RevEng_PAJ7620.cpp:468
void enable()
Enables sensor for reading & interrupts.
Definition: RevEng_PAJ7620.cpp:447
bool isCursorInView()
Returns whether an object is in view as a cursor.
Definition: RevEng_PAJ7620.cpp:368
int getCursorY()
Gets cursor object's current Y location.
Definition: RevEng_PAJ7620.cpp:344
void setGestureMode()
Puts device into Gesture mode.
Definition: RevEng_PAJ7620.cpp:292
Gesture readGesture()
Reads the latest gesture from the device.
Definition: RevEng_PAJ7620.cpp:593
Corner getCorner()
Gets which quadrant an object is in.
Definition: RevEng_PAJ7620.cpp:881
int getNoObjectCount()
Get how long since the object left the view in gesture mode.
Definition: RevEng_PAJ7620.cpp:698
int getObjectCenterX()
Gets Gesture object's current X location.
Definition: RevEng_PAJ7620.cpp:732
void invertXAxis()
Inverts the X (horizontal) axis.
Definition: RevEng_PAJ7620.cpp:394
void setNormalSpeed()
Set sensor to "normal" sampling speed of 120fps.
Definition: RevEng_PAJ7620.cpp:515
int getWaveCount()
Get current count of waves by user.
Definition: RevEng_PAJ7620.cpp:543
int getObjectVelocityX_raw()
Gets object's current X velocity's raw value.
Definition: RevEng_PAJ7620.cpp:781
int getObjectSize()
Read object's size (in pixels)
Definition: RevEng_PAJ7620.cpp:676
int getNoMotionCount()
Get how long no motion has been seen in gesture mode.
Definition: RevEng_PAJ7620.cpp:716
int getObjectVelocityX()
Gets object's current X velocity's value.
Definition: RevEng_PAJ7620.cpp:830
void setGameSpeed()
Set sensor to "game mode" sampling speed of 240fps.
Definition: RevEng_PAJ7620.cpp:500
void setCursorMode()
Puts device into Cursor mode.
Definition: RevEng_PAJ7620.cpp:307
uint8_t begin()
PAJ7620 device initialization and I2C connect to default Wire bus.
Definition: RevEng_PAJ7620.cpp:64
void clearGestureInterrupts()
Clear current gesture interrupt vectors without returning gesture value.
Definition: RevEng_PAJ7620.cpp:530
void invertYAxis()
Inverts the Y (vertical) axis.
Definition: RevEng_PAJ7620.cpp:416
void setGestureExitTime(unsigned long newGestureExitTime)
Sets time sensor waits during getGesture() after gesture value read.
Definition: RevEng_PAJ7620.cpp:487
bool isObjectInView()
Gets whether an object is in view or not.
Definition: RevEng_PAJ7620.cpp:865
int getObjectBrightness()
Read object's "brightness".
Definition: RevEng_PAJ7620.cpp:660
int getCursorX()
Gets cursor object's current X location.
Definition: RevEng_PAJ7620.cpp:320