31#include "../../../SensorBuildOpt.h"
32#if !SENSORLIB_EXCLUDE_PAWA350
51 return readReg(REG_REVISION_ID);
56 int ret =
writeReg(REG_SOFT_RESET, SOFTRESET_VAL);
57 if (ret != 0)
return false;
64 if (val < 0)
return false;
71 uint8_t buffer[2] = {0};
72 buffer[0] =
readReg(REG_DELTA_X);
73 buffer[1] =
readReg(REG_DELTA_Y);
74 data.
delta_x =
static_cast<int8_t
>(buffer[0]);
75 data.
delta_y =
static_cast<int8_t
>(buffer[1]);
82 return writeReg(REG_CPI_SEL,
static_cast<uint8_t
>(cpi)) == 0;
94 return writeReg(REG_RUN_DOWNSHIFT, rd) == 0;
99 return readReg(REG_RUN_DOWNSHIFT);
107 bool rslt =
writeReg(REG_REST1_PERIOD, period) == 0;
123 return writeReg(REG_REST1_DOWNSHIFT, r1d) == 0;
128 return readReg(REG_REST1_DOWNSHIFT);
133 return writeReg(REG_REST2_PERIOD, period) == 0;
138 return readReg(REG_REST2_PERIOD);
143 return writeReg(REG_REST2_DOWNSHIFT, r2d) == 0;
148 return readReg(REG_REST2_DOWNSHIFT);
153 return writeReg(REG_REST3_PERIOD, period) == 0;
158 return readReg(REG_REST3_PERIOD);
163 int val =
readReg(REG_LED_CTRL);
164 if (val < 0)
return false;
165 return writeReg(REG_LED_CTRL, enable ? (val | MASK_LED_ON) : (val & ~MASK_LED_ON)) == 0;
170 int val =
readReg(REG_LED_CTRL);
171 return (val >= 0) && (val & MASK_LED_ON);
176 int val =
readReg(REG_LED_CTRL);
177 if (val < 0)
return false;
178 return writeReg(REG_LED_CTRL, (val & ~MASK_LED_DRV) | (current & MASK_LED_DRV)) == 0;
183 int val =
readReg(REG_LED_CTRL);
184 return (val >= 0) ? (val & MASK_LED_DRV) : -1;
189 int hi =
writeReg(REG_SHUTTER_MAX_HI, (value >> 8) & 0xFF);
190 int lo =
writeReg(REG_SHUTTER_MAX_LO, value & 0xFF);
191 return hi == 0 && lo == 0;
196 int hi =
readReg(REG_SHUTTER_MAX_HI);
197 int lo =
readReg(REG_SHUTTER_MAX_LO);
198 if (hi < 0 || lo < 0)
return -1;
199 return (hi << 8) | lo;
204 int val =
readReg(REG_MOTION_CTRL);
205 if (val < 0)
return false;
206 return writeReg(REG_MOTION_CTRL, (val & ~MASK_MOTION_INT_THRES) | (threshold & MASK_MOTION_INT_THRES)) == 0;
211 int val =
readReg(REG_MOTION_CTRL);
212 return (val >= 0) ? (val & MASK_MOTION_INT_THRES) : -1;
217 int val =
readReg(REG_FPD_FLAG);
230 return (rd > 0) ? (rd * 8 * 8) : 0;
236 return (r1r > 0) ? ((r1r + 1) * 10) : 0;
243 return (r1d > 0 && period > 0) ? (r1d * 16 * (period + 1) * 10) : 0;
249 return (r2r > 0) ? ((r2r + 1) * 10) : 0;
256 return (r2d > 0 && period > 0) ? (r2d * 128 * (period + 1) * 10) : 0;
262 return (r3r > 0) ? ((r3r + 1) * 10) : 0;
269 if (pid != PAW_A350_DEFAULT_PID) {
int readReg(uint8_t reg) const
int writeReg(uint8_t reg, uint8_t val)
uint32_t getRest2PeriodMs() const
Get Rest2 period in milliseconds.
bool checkMotion(MotionStatus &status)
Check motion status.
bool getLedOn() const
Get LED always-on status.
uint32_t getRest1PeriodMs() const
Get Rest1 period in milliseconds.
uint8_t cached_rest1_period
int getProductID() const
Get Product ID.
int getRest2DownshiftTime() const
Get Rest2 to Rest3 downshift time.
bool isMotionDetected()
Quick check if motion detected.
bool initImpl(uint8_t param) override
bool getMotionData(MotionData &data)
Get motion delta data.
bool setLedDriveCurrent(uint8_t current)
Set LED drive current.
int getRest1DownshiftTime() const
Get Rest1 to Rest2 downshift time.
int getRevisionID() const
Get Revision ID.
int getRest1Period() const
Get Rest1 frame period.
bool setRest1Period(uint8_t period)
Set Rest1 frame period.
CpiResolution
Count Per Inch (CPI) Resolution.
@ CPI_500
500 CPI - Default resolution
bool setMotionInterruptThreshold(uint8_t threshold)
Set motion interrupt threshold.
uint32_t getRest2DownshiftTimeMs() const
Get Rest2 downshift time in milliseconds.
bool clearFingerState()
Clear finger presence detect flag.
uint32_t getRunDownshiftTimeMs() const
Get Run downshift time in milliseconds.
int getRest2Period() const
Get Rest2 frame period.
int getRunDownshiftTime() const
Get Run to Rest1 downshift time.
CpiResolution getCpi() const
Get current CPI resolution.
bool setRest3Period(uint8_t period)
Set Rest3 frame period.
bool setLedOn(bool enable)
Enable/disable LED always-on mode.
int getRest3Period() const
Get Rest3 frame period.
const char * getChipName() const
Get chip name.
MotionStatus
Motion Detection Status.
@ MOTION_DETECTED
Motion occurred, data ready for reading.
@ NO_MOTION
No motion detected.
int getMotionInterruptThreshold() const
Get motion interrupt threshold.
bool setShutterMax(uint16_t value)
Set shutter maximum open time.
bool setRest2Period(uint8_t period)
Set Rest2 frame period.
int getShutterMax() const
Get shutter maximum open time.
uint32_t getRest3PeriodMs() const
Get Rest3 period in milliseconds.
bool setRunDownshiftTime(uint8_t rd)
Set Run to Rest1 downshift time.
bool setRest2DownshiftTime(uint8_t r2d)
Set Rest2 to Rest3 downshift time.
bool setRest1DownshiftTime(uint8_t r1d)
Set Rest1 to Rest2 downshift time.
bool setCpi(CpiResolution cpi)
Set CPI resolution.
int getLedDriveCurrent() const
Get LED drive current setting.
uint32_t getRest1DownshiftTimeMs() const
Get Rest1 downshift time in milliseconds.
bool softReset()
Perform software reset.
int8_t delta_x
X-axis movement (-128 to +127 counts)
int8_t delta_y
Y-axis movement (-128 to +127 counts)