|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
PAW-A350 Optical Finger Navigation Sensor Driver. More...
#include <SensorPawA350.hpp>
Classes | |
| struct | MotionData |
| Motion Delta Data. More... | |
Public Types | |
| enum class | CpiResolution : uint8_t { CPI_125 = 0 , CPI_250 = 1 , CPI_500 = 2 , CPI_750 = 3 , CPI_1000 = 4 , CPI_1250 = 5 } |
| Count Per Inch (CPI) Resolution. More... | |
| enum class | MotionStatus : uint8_t { NO_MOTION = 0 , MOTION_DETECTED = 1 } |
| Motion Detection Status. More... | |
Public Member Functions | |
| SensorPawA350 ()=default | |
| const char * | getChipName () const |
| Get chip name. | |
| int | getProductID () const |
| Get Product ID. | |
| int | getRevisionID () const |
| Get Revision ID. | |
| bool | softReset () |
| Perform software reset. | |
| bool | checkMotion (MotionStatus &status) |
| Check motion status. | |
| bool | getMotionData (MotionData &data) |
| Get motion delta data. | |
| bool | setCpi (CpiResolution cpi) |
| Set CPI resolution. | |
| CpiResolution | getCpi () const |
| Get current CPI resolution. | |
| bool | setRunDownshiftTime (uint8_t rd) |
| Set Run to Rest1 downshift time. | |
| int | getRunDownshiftTime () const |
| Get Run to Rest1 downshift time. | |
| bool | setRest1Period (uint8_t period) |
| Set Rest1 frame period. | |
| int | getRest1Period () const |
| Get Rest1 frame period. | |
| bool | setRest1DownshiftTime (uint8_t r1d) |
| Set Rest1 to Rest2 downshift time. | |
| int | getRest1DownshiftTime () const |
| Get Rest1 to Rest2 downshift time. | |
| bool | setRest2Period (uint8_t period) |
| Set Rest2 frame period. | |
| int | getRest2Period () const |
| Get Rest2 frame period. | |
| bool | setRest2DownshiftTime (uint8_t r2d) |
| Set Rest2 to Rest3 downshift time. | |
| int | getRest2DownshiftTime () const |
| Get Rest2 to Rest3 downshift time. | |
| bool | setRest3Period (uint8_t period) |
| Set Rest3 frame period. | |
| int | getRest3Period () const |
| Get Rest3 frame period. | |
| bool | setLedOn (bool enable) |
| Enable/disable LED always-on mode. | |
| bool | getLedOn () const |
| Get LED always-on status. | |
| bool | setLedDriveCurrent (uint8_t current) |
| Set LED drive current. | |
| int | getLedDriveCurrent () const |
| Get LED drive current setting. | |
| bool | setShutterMax (uint16_t value) |
| Set shutter maximum open time. | |
| int | getShutterMax () const |
| Get shutter maximum open time. | |
| bool | setMotionInterruptThreshold (uint8_t threshold) |
| Set motion interrupt threshold. | |
| int | getMotionInterruptThreshold () const |
| Get motion interrupt threshold. | |
| bool | clearFingerState () |
| Clear finger presence detect flag. | |
| bool | isMotionDetected () |
| Quick check if motion detected. | |
| uint32_t | getRunDownshiftTimeMs () const |
| Get Run downshift time in milliseconds. | |
| uint32_t | getRest1PeriodMs () const |
| Get Rest1 period in milliseconds. | |
| uint32_t | getRest1DownshiftTimeMs () const |
| Get Rest1 downshift time in milliseconds. | |
| uint32_t | getRest2PeriodMs () const |
| Get Rest2 period in milliseconds. | |
| uint32_t | getRest2DownshiftTimeMs () const |
| Get Rest2 downshift time in milliseconds. | |
| uint32_t | getRest3PeriodMs () const |
| Get Rest3 period in milliseconds. | |
Public Member Functions inherited from I2CDeviceWithHal | |
| bool | begin (SensorCommCustom::CustomCallback cb, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr) |
| Initialize the sensor using custom callback interface. | |
Public Member Functions inherited from DeviceBeginCommon | |
| virtual | ~DeviceBeginCommon () |
| uint8_t | getAddress () const |
| uint8_t | getInterface () const |
Public Member Functions inherited from SensorCommWrapper | |
| SensorCommWrapper ()=default | |
| int | readReg (uint8_t reg) const |
| int | readRegBuff (uint8_t reg, uint8_t *buf, size_t len) const |
| int | readBuff (uint8_t *buf, size_t len) const |
| int | writeReg (uint8_t reg, uint8_t val) |
| int | writeRegBuff (uint8_t reg, uint8_t *buf, size_t len) |
| int | writeBuff (uint8_t *buf, size_t len) |
| int | writeThenRead (const uint8_t *write_buffer, size_t write_len, uint8_t *read_buffer, size_t read_len) |
| bool | setRegBit (uint8_t reg, uint8_t bit) |
| bool | clrRegBit (uint8_t reg, uint8_t bit) |
| bool | getRegBit (uint8_t reg, uint8_t bit) |
| int | updateBits (uint8_t reg, uint8_t mask, uint8_t value_shifted) |
| void | setAddress (uint8_t address) |
| void | setAck (bool enable) |
Public Member Functions inherited from SensorCommInterface | |
| virtual | ~SensorCommInterface ()=default |
Protected Member Functions | |
| bool | initImpl (uint8_t param) override |
Protected Member Functions inherited from I2CDeviceWithHal | |
| bool | ensureValid () const override |
| Ensure the communication interface is valid. | |
Protected Member Functions inherited from DeviceBeginCommon | |
| DeviceBeginCommon ()=default | |
| virtual SensorCommBase * | getComm () const override |
| virtual void | beforeBegin () |
| virtual void | afterCommReady () |
| virtual void | afterInitSuccess (uint8_t param) |
| virtual void | onBeginFail () |
| bool | fail () |
| void | clearCommState () |
| template<typename CreateComm > | |
| bool | beginLifecycle (uint8_t addr, uint8_t iface, uint8_t initParam, CreateComm createComm) |
Protected Attributes | |
| uint8_t | cached_rest1_period = 1 |
Protected Attributes inherited from DeviceBeginCommon | |
| std::unique_ptr< SensorCommBase > | comm |
| std::unique_ptr< SensorHal > | hal |
| std::unique_ptr< SensorCommStatic > | staticComm |
| uint8_t | _addr = 0 |
| uint8_t | _iface = COMM_CUSTOM |
PAW-A350 Optical Finger Navigation Sensor Driver.
Provides interface for Configuring and reading motion data from the PixArt PAW-A350 OFN sensor.
| Value | CPI | Description |
|---|---|---|
| 0 | 125 | Lowest resolution, highest precision |
| 1 | 250 | 2x base resolution |
| 2 | 500 | Default resolution |
| 3 | 750 | 1.5x default |
| 4 | 1000 | High resolution |
| 5 | 1250 | Highest resolution |
| Value | Description |
|---|---|
| NO_MOTION | No motion detected since last read |
| MOTION_DETECTED | Motion detected, data ready in Delta_X/Y registers |
Contains signed movement deltas in counts. The actual distance in inches is calculated as: delta / CPI
| Member | Type | Description |
|---|---|---|
| delta_x | int8_t | X axis movement (-128 to 127) |
| delta_y | int8_t | Y axis movement (-128 to 127) |
Definition at line 135 of file SensorPawA350.hpp.
|
strong |
Count Per Inch (CPI) Resolution.
Defines the sensor resolution in counts per inch. Higher CPI means more sensitivity but smaller range.
Definition at line 147 of file SensorPawA350.hpp.
|
strong |
Motion Detection Status.
Indicates whether motion has been detected since the last time the EVENT register was read.
| Enumerator | |
|---|---|
| NO_MOTION | No motion detected. |
| MOTION_DETECTED | Motion occurred, data ready for reading. |
Definition at line 165 of file SensorPawA350.hpp.
|
default |
| bool SensorPawA350::checkMotion | ( | MotionStatus & | status | ) |
Check motion status.
Reads the EVENT register (0x02) to check if motion has been detected. The EVENT register contains multiple status bits:
| [out] | status | Reference to store motion status |
Definition at line 61 of file SensorPawA350.cpp.
References MOTION_DETECTED, NO_MOTION, and SensorCommWrapper::readReg().
Referenced by isMotionDetected(), and loop().
| bool SensorPawA350::clearFingerState | ( | ) |
Clear finger presence detect flag.
Reads the FPD_FLAG register (0x7A) to clear the finger state change flag (FPD_ST) in the EVENT register.
Definition at line 215 of file SensorPawA350.cpp.
References SensorCommWrapper::readReg().
| const char * SensorPawA350::getChipName | ( | ) | const |
Get chip name.
Definition at line 39 of file SensorPawA350.cpp.
Referenced by setup().
| SensorPawA350::CpiResolution SensorPawA350::getCpi | ( | ) | const |
Get current CPI resolution.
Definition at line 85 of file SensorPawA350.cpp.
References CPI_500, and SensorCommWrapper::readReg().
Referenced by setup().
| int SensorPawA350::getLedDriveCurrent | ( | ) | const |
Get LED drive current setting.
Definition at line 181 of file SensorPawA350.cpp.
References SensorCommWrapper::readReg().
Referenced by setup().
| bool SensorPawA350::getLedOn | ( | ) | const |
Get LED always-on status.
Definition at line 168 of file SensorPawA350.cpp.
References SensorCommWrapper::readReg().
Referenced by setup().
| bool SensorPawA350::getMotionData | ( | MotionData & | data | ) |
Get motion delta data.
Reads Delta_X (0x03) and Delta_Y (0x04) registers sequentially to get motion deltas. Values are 8-bit signed integers in two's complement format.
| [out] | data | Reference to store motion data |
Definition at line 69 of file SensorPawA350.cpp.
References SensorPawA350::MotionData::delta_x, SensorPawA350::MotionData::delta_y, SensorCommWrapper::readReg(), and SensorCommWrapper::writeReg().
Referenced by loop().
| int SensorPawA350::getMotionInterruptThreshold | ( | ) | const |
Get motion interrupt threshold.
Definition at line 209 of file SensorPawA350.cpp.
References SensorCommWrapper::readReg().
Referenced by setup().
| int SensorPawA350::getProductID | ( | ) | const |
Get Product ID.
Reads the PRODUCT_ID register (0x00) which contains a unique identification number assigned to the PAW-A350. The value is fixed at 0x88 and can be used to verify I2C communication is working correctly.
Definition at line 44 of file SensorPawA350.cpp.
References SensorCommWrapper::readReg().
Referenced by initImpl(), setup(), and softReset().
| int SensorPawA350::getRest1DownshiftTime | ( | ) | const |
Get Rest1 to Rest2 downshift time.
Definition at line 126 of file SensorPawA350.cpp.
References SensorCommWrapper::readReg().
Referenced by getRest1DownshiftTimeMs(), and setup().
| uint32_t SensorPawA350::getRest1DownshiftTimeMs | ( | ) | const |
Get Rest1 downshift time in milliseconds.
Definition at line 239 of file SensorPawA350.cpp.
References getRest1DownshiftTime(), and getRest1Period().
Referenced by setup().
| int SensorPawA350::getRest1Period | ( | ) | const |
Get Rest1 frame period.
Definition at line 114 of file SensorPawA350.cpp.
References cached_rest1_period.
Referenced by getRest1DownshiftTimeMs(), getRest1PeriodMs(), and setup().
| uint32_t SensorPawA350::getRest1PeriodMs | ( | ) | const |
Get Rest1 period in milliseconds.
Definition at line 233 of file SensorPawA350.cpp.
References getRest1Period().
Referenced by setup().
| int SensorPawA350::getRest2DownshiftTime | ( | ) | const |
Get Rest2 to Rest3 downshift time.
Definition at line 146 of file SensorPawA350.cpp.
References SensorCommWrapper::readReg().
Referenced by getRest2DownshiftTimeMs(), and setup().
| uint32_t SensorPawA350::getRest2DownshiftTimeMs | ( | ) | const |
Get Rest2 downshift time in milliseconds.
Definition at line 252 of file SensorPawA350.cpp.
References getRest2DownshiftTime(), and getRest2Period().
Referenced by setup().
| int SensorPawA350::getRest2Period | ( | ) | const |
Get Rest2 frame period.
Definition at line 136 of file SensorPawA350.cpp.
References SensorCommWrapper::readReg().
Referenced by getRest2DownshiftTimeMs(), getRest2PeriodMs(), and setup().
| uint32_t SensorPawA350::getRest2PeriodMs | ( | ) | const |
Get Rest2 period in milliseconds.
Definition at line 246 of file SensorPawA350.cpp.
References getRest2Period().
Referenced by setup().
| int SensorPawA350::getRest3Period | ( | ) | const |
Get Rest3 frame period.
Definition at line 156 of file SensorPawA350.cpp.
References SensorCommWrapper::readReg().
Referenced by getRest3PeriodMs(), and setup().
| uint32_t SensorPawA350::getRest3PeriodMs | ( | ) | const |
Get Rest3 period in milliseconds.
Definition at line 259 of file SensorPawA350.cpp.
References getRest3Period().
Referenced by setup().
| int SensorPawA350::getRevisionID | ( | ) | const |
Get Revision ID.
Reads the REVISION_ID register (0x01) which contains the IC revision number. This value may change when new silicon versions are released.
Definition at line 49 of file SensorPawA350.cpp.
References SensorCommWrapper::readReg().
Referenced by setup().
| int SensorPawA350::getRunDownshiftTime | ( | ) | const |
Get Run to Rest1 downshift time.
Definition at line 97 of file SensorPawA350.cpp.
References SensorCommWrapper::readReg().
Referenced by getRunDownshiftTimeMs(), and setup().
| uint32_t SensorPawA350::getRunDownshiftTimeMs | ( | ) | const |
Get Run downshift time in milliseconds.
Calculates actual downshift time in ms based on Run_Downshift register value.
Definition at line 227 of file SensorPawA350.cpp.
References getRunDownshiftTime().
Referenced by setup().
| int SensorPawA350::getShutterMax | ( | ) | const |
Get shutter maximum open time.
Definition at line 194 of file SensorPawA350.cpp.
References SensorCommWrapper::readReg().
Referenced by setup().
|
overrideprotectedvirtual |
Implements DeviceBeginCommon.
Definition at line 265 of file SensorPawA350.cpp.
References cached_rest1_period, and getProductID().
| bool SensorPawA350::isMotionDetected | ( | ) |
Quick check if motion detected.
Convenience function to check if motion flag is set in EVENT register.
Definition at line 221 of file SensorPawA350.cpp.
References checkMotion(), and MOTION_DETECTED.
| bool SensorPawA350::setCpi | ( | CpiResolution | cpi | ) |
Set CPI resolution.
Configures the CPI_SEL register (0x62) to set the count per inch resolution. Higher CPI provides more sensitivity but smaller usable range.
| cpi | Resolution setting |
Definition at line 80 of file SensorPawA350.cpp.
References SensorCommWrapper::writeReg().
Referenced by setup().
| bool SensorPawA350::setLedDriveCurrent | ( | uint8_t | current | ) |
Set LED drive current.
Configures LED drive current in LED_CTRL register (0x1A).
| current | Drive current (0=13mA, 2=9.6mA, 7=27mA) |
Definition at line 174 of file SensorPawA350.cpp.
References SensorCommWrapper::readReg(), and SensorCommWrapper::writeReg().
Referenced by setup().
| bool SensorPawA350::setLedOn | ( | bool | enable | ) |
Enable/disable LED always-on mode.
Controls the LED_On bit in LED_CTRL register (0x1A). When disabled (default), LED operates normally. When enabled, LED stays always on.
| enable | true to keep LED on, false for normal operation |
Definition at line 161 of file SensorPawA350.cpp.
References SensorCommWrapper::readReg(), and SensorCommWrapper::writeReg().
Referenced by setup().
| bool SensorPawA350::setMotionInterruptThreshold | ( | uint8_t | threshold | ) |
Set motion interrupt threshold.
Configures MOTION_CTRL register (0x74) to set the motion interrupt threshold.
| threshold | Threshold value (0-7, default: 0) |
Definition at line 202 of file SensorPawA350.cpp.
References SensorCommWrapper::readReg(), and SensorCommWrapper::writeReg().
Referenced by setup().
| bool SensorPawA350::setRest1DownshiftTime | ( | uint8_t | r1d | ) |
Set Rest1 to Rest2 downshift time.
Writes to Rest1_Downshift register (0x15) to set the time before transitioning from Rest1 to Rest2.
| r1d | Downshift time value (1-242, default: 31) |
Definition at line 121 of file SensorPawA350.cpp.
References SensorCommWrapper::writeReg().
Referenced by setup().
| bool SensorPawA350::setRest1Period | ( | uint8_t | period | ) |
Set Rest1 frame period.
Writes to Rest1_Period register (0x11) to set the frame period in Rest1 power state.
| period | Period value (1-256, default: 1) |
Definition at line 102 of file SensorPawA350.cpp.
References cached_rest1_period, and SensorCommWrapper::writeReg().
Referenced by setup().
| bool SensorPawA350::setRest2DownshiftTime | ( | uint8_t | r2d | ) |
Set Rest2 to Rest3 downshift time.
Writes to Rest2_Downshift register (0x17) to set the time before transitioning from Rest2 to Rest3.
| r2d | Downshift time value (1-242, default: 47) |
Definition at line 141 of file SensorPawA350.cpp.
References SensorCommWrapper::writeReg().
Referenced by setup().
| bool SensorPawA350::setRest2Period | ( | uint8_t | period | ) |
Set Rest2 frame period.
Writes to Rest2_Period register (0x16) to set the frame period in Rest2 power state.
| period | Period value (1-256, default: 9) |
Definition at line 131 of file SensorPawA350.cpp.
References SensorCommWrapper::writeReg().
Referenced by setup().
| bool SensorPawA350::setRest3Period | ( | uint8_t | period | ) |
Set Rest3 frame period.
Writes to Rest3_Period register (0x18) to set the frame period in Rest3 (lowest power) state.
| period | Period value (1-256, default: 49) |
Definition at line 151 of file SensorPawA350.cpp.
References SensorCommWrapper::writeReg().
Referenced by setup().
| bool SensorPawA350::setRunDownshiftTime | ( | uint8_t | rd | ) |
Set Run to Rest1 downshift time.
Writes to Run_Downshift register (0x13) to set the time before transitioning from Run state to Rest1 state when no motion is detected.
| rd | Downshift time value (2-242, default: 4) |
Definition at line 92 of file SensorPawA350.cpp.
References SensorCommWrapper::writeReg().
Referenced by setup().
| bool SensorPawA350::setShutterMax | ( | uint16_t | value | ) |
Set shutter maximum open time.
Writes to Shutter_Max_Hi (0x3B) and Shutter_Max_Lo (0x3C) registers to set the maximum exposure time.
| value | Shutter max value (0-2929, default: 2929) |
Definition at line 187 of file SensorPawA350.cpp.
References SensorCommWrapper::writeReg().
Referenced by setup().
| bool SensorPawA350::softReset | ( | ) |
Perform software reset.
Writes to the SOFT_RESET register (0x3A) with value 0x5A to trigger a software reset. After reset, all registers return to their default values.
Definition at line 54 of file SensorPawA350.cpp.
References getProductID(), and SensorCommWrapper::writeReg().
Referenced by setup().
|
protected |
Definition at line 587 of file SensorPawA350.hpp.
Referenced by getRest1Period(), initImpl(), and setRest1Period().