MatrixMiniR4 1.1.5
Matrix Mini R4 Arduino Library API Documentation
Loading...
Searching...
No Matches
MiniR4_MXGesture.h
Go to the documentation of this file.
1
15#ifndef _MiniR4_MXGesture_H_
16#define _MiniR4_MXGesture_H_
17
18#include <Arduino.h>
19#include <Wire.h>
20
21#ifndef ADDR_PCA954X
22#define ADDR_PCA954X 0x70
23#endif
24
25// Open this macro to check the detailed running process of the program.
26// #define ENABLE_DBG
27
28#ifdef ENABLE_DBG
29#define DBG(...) \
30 { \
31 Serial.print("["); \
32 Serial.print(__FUNCTION__); \
33 Serial.print("(): "); \
34 Serial.print(__LINE__); \
35 Serial.print(" ] "); \
36 Serial.println(__VA_ARGS__); \
37 }
38#else
39#define DBG(...)
40#endif
41
42// DEVICE ID
43#define PAJ7620_IIC_ADDR 0x73
44#define PAJ7620_PARTID 0x7620
45
46// REGISTER BANK SELECT
47#define PAJ7620_REGITER_BANK_SEL (0xEF)
48
49// REGISTER BANK 0
50#define PAJ7620_ADDR_PART_ID_LOW 0x00
51#define PAJ7620_ADDR_PART_ID_HIGH 0x01
52#define PAJ7620_ADDR_VERSION_ID 0x01
53#define PAJ7620_ADDR_SUSPEND_CMD 0x03
54#define PAJ7620_ADDR_GES_PS_DET_MASK_0 0x41
55#define PAJ7620_ADDR_GES_PS_DET_MASK_1 0x42
56#define PAJ7620_ADDR_GES_PS_DET_FLAG_0 0x43
57#define PAJ7620_ADDR_GES_PS_DET_FLAG_1 0x44
58#define PAJ7620_ADDR_STATE_INDICATOR 0x45
59#define PAJ7620_ADDR_PS_HIGH_THRESHOLD 0x69
60#define PAJ7620_ADDR_PS_LOW_THRESHOLD 0x6A
61#define PAJ7620_ADDR_PS_APPROACH_STATE 0x6B
62#define PAJ7620_ADDR_PS_RAW_DATA 0x6C
63
64// REGISTER BANK 1
65#define PAJ7620_ADDR_PS_GAIN 0x44
66#define PAJ7620_ADDR_IDLE_S1_STEP_0 0x67
67#define PAJ7620_ADDR_IDLE_S1_STEP_1 0x68
68#define PAJ7620_ADDR_IDLE_S2_STEP_0 0x69
69#define PAJ7620_ADDR_IDLE_S2_STEP_1 0x6A
70#define PAJ7620_ADDR_OP_TO_S1_STEP_0 0x6B
71#define PAJ7620_ADDR_OP_TO_S1_STEP_1 0x6C
72#define PAJ7620_ADDR_OP_TO_S2_STEP_0 0x6D
73#define PAJ7620_ADDR_OP_TO_S2_STEP_1 0x6E
74#define PAJ7620_ADDR_OPERATION_ENABLE 0x72
75
76#define PAJ7620_BANK0 0
77#define PAJ7620_BANK1 1
78
79// PAJ7620_ADDR_SUSPEND_CMD
80#define PAJ7620_I2C_WAKEUP 0x01
81#define PAJ7620_I2C_SUSPEND 0x00
82
83// PAJ7620_ADDR_OPERATION_ENABLE
84#define PAJ7620_ENABLE 0x01
85#define PAJ7620_DISABLE 0x00
86
87#define GES_REACTION_TIME 50
88#define GES_ENTRY_TIME 2000
89#define GES_QUIT_TIME 1000
90
91#define ERR_OK 0
92#define ERR_DATA_BUS -1
93#define ERR_IC_VERSION -2
94
102 public:
103 uint8_t _ch = 0;
104 TwoWire* _pWire;
105
132
137 typedef enum {
138 eBank0 = 0,
139 eBank1 = 1,
140 } eBank_t;
141
146 typedef enum {
147 eNormalRate = 0,
149 eGamingRate = 1,
151 } eRateMode_t;
152
157 typedef struct {
159 const char* description;
162
168 int begin(void);
169
175 void setGestureHighRate(bool b);
176
185 String gestureDescription(int gesture);
186
192 int getGesture(void);
193
194 private:
195 void i2cMUXSelect();
196
203 int selectBank(eBank_t bank);
204
211 int setNormalOrGamingMode(eRateMode_t mode);
212
220 void writeReg(uint8_t reg, const void* pBuf, size_t size);
221
230 uint8_t readReg(uint8_t reg, void* pBuf, size_t size);
231
233 static const uint8_t /*PROGMEM*/ initRegisterArray[219][2];
235 static const sGestureDescription_t /*PROGMEM*/ gestureDescriptionsTable[14];
237 const uint8_t _deviceAddr = PAJ7620_IIC_ADDR;
240 bool _gestureHighRate = true;
242 eGesture_t _gesture;
243
244};
245
246#endif
#define PAJ7620_IIC_ADDR
A class for MATRIX Gesture Seneor.
String gestureDescription(int gesture)
Get the string descritpion corresponding to the gesture number.
eRateMode_t
Gesture Update Rate.
eBank_t
Register Bank.
void setGestureHighRate(bool b)
Set gesture detection mode.
int getGesture(void)
Get gesture.
eGesture_t
gesture information
int begin(void)
init function