|
RevEng_PAJ7620
1.5.0
|
#include <Arduino.h>#include <Wire.h>

Go to the source code of this file.
Classes | |
| class | RevEng_PAJ7620 |
| PAJ7620 Device API class - As developed by RevEng Devs. More... | |
Enumerations | |
| enum | Gesture { GES_NONE = 0 , GES_UP , GES_DOWN , GES_LEFT , GES_RIGHT , GES_FORWARD , GES_BACKWARD , GES_CLOCKWISE , GES_ANTICLOCKWISE , GES_WAVE } |
| Gesture result definitions. More... | |
| enum | Bank_e { BANK0 = 0 , BANK1 } |
| Used for selecting PAJ7620 memory bank to read/write from. More... | |
| enum | Corner { CORNER_NONE = 0 , CORNER_NE = 1 , CORNER_NW = 2 , CORNER_SW = 3 , CORNER_SE = 4 , CORNER_MIDDLE = 5 , QUADRANT_NONE = 0 , QUADRANT_I = 1 , QUADRANT_II = 2 , QUADRANT_III = 3 , QUADRANT_IV = 4 } |
| Used for reading the corners in corners mode and PIN mode. More... | |
Variables | |
| const unsigned short | initRegisterArray [] |
| Initial device register addresses and values. More... | |
| const unsigned short | setGestureModeRegisterArray [] |
| Gesture mode specific register addresses and values. More... | |
| const unsigned short | setCursorModeRegisterArray [] |
| Cursor mode specific register addresses and values. More... | |
Additional contributions:
Description: This demo can recognize 9 gestures and output the result, including move up, move down, move left, move right, move forward, move backward, circle-clockwise, circle-anti (counter) clockwise, and wave.
License: 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.
PAJ7620U2 Sensor data sheet for reference found here: https://datasheetspdf.com/pdf-file/1309990/PixArt/PAJ7620U2/1
Driver sources, latest code, and authors available at: https://github.com/acrandal/RevEng_PAJ7620
| #define CORNERS_BUFFER_LOWER (int)(GESTURE_RANGE_MID - (CORNERS_BUFFER_WIDTH / 2)) |
| #define CORNERS_BUFFER_UPPER (int)(GESTURE_RANGE_MID + (CORNERS_BUFFER_WIDTH / 2)) |
| #define CORNERS_BUFFER_WIDTH (int)((GESTURE_RANGE_MAX - GESTURE_RANGE_MIN) * CORNERS_BUFFER_WIDTH_PCT) |
| #define CORNERS_BUFFER_WIDTH_PCT 0.20 |
| #define CUR_HAS_OBJECT 0x04 |
| #define CUR_NO_OBJECT 0x80 |
| #define GES_ANTI_CLOCKWISE_FLAG 0x80 |
Bit set -> Anticlockwise gesture detected.
| #define GES_BACKWARD_FLAG 0x20 |
Bit set -> Backward gesture detected.
| #define GES_CLOCKWISE_FLAG 0x40 |
Bit set -> Clockwise gesture detected.
| #define GES_DOWN_FLAG 0x02 |
Bit set -> Down gesture detected.
| #define GES_FORWARD_FLAG 0x10 |
Bit set -> Forward gesture detected.
| #define GES_LEFT_FLAG 0x04 |
Bit set -> Left gesture detected.
| #define GES_RIGHT_FLAG 0x08 |
Bit set -> Right gesture detected.
| #define GES_UP_FLAG 0x01 |
Bit set -> Up gesture detected.
| #define GES_WAVE_FLAG 0x01 |
Bit set -> Wave gesture detected.
| #define GESTURE_RANGE_MAX 3712 |
| #define GESTURE_RANGE_MID ((GESTURE_RANGE_MAX - GESTURE_RANGE_MIN) / 2) |
| #define GESTURE_RANGE_MIN 0 |
| #define INIT_REG_ARRAY_SIZE (sizeof(initRegisterArray)/sizeof(initRegisterArray[0])) |
Generated size of the register init array.
| #define PAJ7620_ADDR_BASE 0x00 |
Base address for accessing registers.
| #define PAJ7620_ADDR_CURSOR_INT (PAJ7620_ADDR_BASE + 0x44) |
| #define PAJ7620_ADDR_CURSOR_X_HIGH (PAJ7620_ADDR_BASE + 0x3C) |
| #define PAJ7620_ADDR_CURSOR_X_LOW (PAJ7620_ADDR_BASE + 0x3B) |
| #define PAJ7620_ADDR_CURSOR_Y_HIGH (PAJ7620_ADDR_BASE + 0x3E) |
| #define PAJ7620_ADDR_CURSOR_Y_LOW (PAJ7620_ADDR_BASE + 0x3D) |
| #define PAJ7620_ADDR_GES_PS_DET_FLAG_0 (PAJ7620_ADDR_BASE + 0x43) |
| #define PAJ7620_ADDR_GES_PS_DET_FLAG_1 (PAJ7620_ADDR_BASE + 0x44) |
| #define PAJ7620_ADDR_GES_PS_DET_MASK_0 (PAJ7620_ADDR_BASE + 0x41) |
| #define PAJ7620_ADDR_GES_PS_DET_MASK_1 (PAJ7620_ADDR_BASE + 0x42) |
| #define PAJ7620_ADDR_GES_RESULT_0 (PAJ7620_ADDR_BASE + 0x43) |
| #define PAJ7620_ADDR_GES_RESULT_1 (PAJ7620_ADDR_BASE + 0x44) |
| #define PAJ7620_ADDR_IDLE_S1_STEP_0 (PAJ7620_ADDR_BASE + 0x67) |
| #define PAJ7620_ADDR_IDLE_S1_STEP_1 (PAJ7620_ADDR_BASE + 0x68) |
| #define PAJ7620_ADDR_IDLE_S2_STEP_0 (PAJ7620_ADDR_BASE + 0x69) |
| #define PAJ7620_ADDR_IDLE_S2_STEP_1 (PAJ7620_ADDR_BASE + 0x6A) |
| #define PAJ7620_ADDR_LENS_ORIENTATION (PAJ7620_ADDR_BASE + 0x04) |
| #define PAJ7620_ADDR_NO_MOTION_COUNT (PAJ7620_ADDR_BASE + 0xB9) |
| #define PAJ7620_ADDR_NO_OBJECT_COUNT (PAJ7620_ADDR_BASE + 0xB8) |
| #define PAJ7620_ADDR_OBJECT_BRIGHTNESS (PAJ7620_ADDR_BASE + 0xB0) |
| #define PAJ7620_ADDR_OBJECT_CENTER_X_LSB (PAJ7620_ADDR_BASE + 0xAC) |
| #define PAJ7620_ADDR_OBJECT_CENTER_X_MSB (PAJ7620_ADDR_BASE + 0xAD) |
| #define PAJ7620_ADDR_OBJECT_CENTER_Y_LSB (PAJ7620_ADDR_BASE + 0xAE) |
| #define PAJ7620_ADDR_OBJECT_CENTER_Y_MSB (PAJ7620_ADDR_BASE + 0xAF) |
| #define PAJ7620_ADDR_OBJECT_SIZE_LSB (PAJ7620_ADDR_BASE + 0xB1) |
| #define PAJ7620_ADDR_OBJECT_SIZE_MSB (PAJ7620_ADDR_BASE + 0xB2) |
| #define PAJ7620_ADDR_OBJECT_VEL_X_LSB (PAJ7620_ADDR_BASE + 0xC3) |
| #define PAJ7620_ADDR_OBJECT_VEL_X_MSB (PAJ7620_ADDR_BASE + 0xC4) |
| #define PAJ7620_ADDR_OBJECT_VEL_Y_LSB (PAJ7620_ADDR_BASE + 0xC5) |
| #define PAJ7620_ADDR_OBJECT_VEL_Y_MSB (PAJ7620_ADDR_BASE + 0xC6) |
| #define PAJ7620_ADDR_OP_TO_S1_STEP_0 (PAJ7620_ADDR_BASE + 0x6B) |
| #define PAJ7620_ADDR_OP_TO_S1_STEP_1 (PAJ7620_ADDR_BASE + 0x6C) |
| #define PAJ7620_ADDR_OP_TO_S2_STEP_0 (PAJ7620_ADDR_BASE + 0x6D) |
| #define PAJ7620_ADDR_OP_TO_S2_STEP_1 (PAJ7620_ADDR_BASE + 0x6E) |
| #define PAJ7620_ADDR_OPERATION_ENABLE (PAJ7620_ADDR_BASE + 0x72) |
| #define PAJ7620_ADDR_PART_ID_0 (PAJ7620_ADDR_BASE + 0x00) |
| #define PAJ7620_ADDR_PART_ID_1 (PAJ7620_ADDR_BASE + 0x01) |
| #define PAJ7620_ADDR_PS_APPROACH_STATE (PAJ7620_ADDR_BASE + 0x6B) |
| #define PAJ7620_ADDR_PS_APPROACH_STATE (PAJ7620_ADDR_BASE + 0x6B) |
| #define PAJ7620_ADDR_PS_GAIN (PAJ7620_ADDR_BASE + 0x44) |
| #define PAJ7620_ADDR_PS_HIGH_THRESHOLD (PAJ7620_ADDR_BASE + 0x69) |
| #define PAJ7620_ADDR_PS_LOW_THRESHOLD (PAJ7620_ADDR_BASE + 0x6A) |
| #define PAJ7620_ADDR_PS_RAW_DATA (PAJ7620_ADDR_BASE + 0x6C) |
| #define PAJ7620_ADDR_R_IDLE_TIME_0 (PAJ7620_ADDR_BASE + 0x65) |
| #define PAJ7620_ADDR_R_IDLE_TIME_1 (PAJ7620_ADDR_BASE + 0x66) |
| #define PAJ7620_ADDR_S_AVE_Y_BRIGHTNESS (PAJ7620_ADDR_BASE + 0x6C) |
| #define PAJ7620_ADDR_STATE_INDICATOR (PAJ7620_ADDR_BASE + 0x45) |
| #define PAJ7620_ADDR_SUSPEND_CMD (PAJ7620_ADDR_BASE + 0x03) |
| #define PAJ7620_ADDR_WAVE_COUNT (PAJ7620_ADDR_BASE + 0xB7) |
| #define PAJ7620_BANK0 0x00 |
| #define PAJ7620_BANK1 0x01 |
| #define PAJ7620_DISABLE 0x00 |
Disable the device and stop reading data.
| #define PAJ7620_ENABLE 0x01 |
Enable the device to start reading data.
| #define PAJ7620_GAME_SPEED 0x30 |
Set to "game mode" speed of 240 fps.
| #define PAJ7620_I2C_BUS_ADDR 0x73 |
DEVICE'S I2C ID - defined by manufacturer.
| #define PAJ7620_I2C_SUSPEND 0x00 |
Suspend the device.
| #define PAJ7620_I2C_WAKEUP 0x01 |
Wakeup the device.
| #define PAJ7620_NORMAL_SPEED 0xAC |
Set to "normal" speed of 120 fps.
| #define PAJ7620_PART_ID_LSB 0x20 |
| #define PAJ7620_PART_ID_MSB 0x76 |
| #define PAJ7620_REGISTER_BANK_SEL (PAJ7620_ADDR_BASE + 0xEF) |
Register bank select address.
| #define SET_CURSOR_MODE_REG_ARRAY_SIZE (sizeof(setCursorModeRegisterArray)/sizeof(setCursorModeRegisterArray[0])) |
Generated size of the register set cursor mode array.
| #define SET_GES_MODE_REG_ARRAY_SIZE (sizeof(setGestureModeRegisterArray)/sizeof(setGestureModeRegisterArray[0])) |
Generated size of the register set gesture mode array.
| enum Bank_e |
| enum Corner |
Used for reading the corners in corners mode and PIN mode.
| enum Gesture |
Gesture result definitions.
Used as return value from readGesture call
| const unsigned short initRegisterArray[] |
Initial device register addresses and values.
| const unsigned short setCursorModeRegisterArray[] |
Cursor mode specific register addresses and values.
| const unsigned short setGestureModeRegisterArray[] |
Gesture mode specific register addresses and values.