PixArt Optical Track Sensor, OTS, library initial release v1.0. Supports PAT9125, PAT9126, PAT9130, PAA5101. Future to support PAT9150.
Fork of Pixart_OTS by
Diff: Pixart_OTS_GrabData.cpp
- Revision:
- 0:2a85075b8467
- Child:
- 1:95917b856631
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Pixart_OTS_GrabData.cpp Wed Mar 06 21:02:39 2019 +0000 @@ -0,0 +1,52 @@ +/* PixArt Optical Finger Navigation, OFN, sensor driver. + * By PixArt Imaging Inc. + * Primary Engineer: Hill Chen (PixArt USA) + * + * License: Apache-2.0; http://www.apache.org/licenses/LICENSE-2.0 + */ + +#include "Pixart_OTS_GrabData.h" + +Pixart_OTS_OtsData Pixart_OTS_GrabData_12bitXy::grab(Pixart_ComPort &com_port) +{ + int16_t deltaX_low = com_port.readRegister(0x03); + int16_t deltaY_low = com_port.readRegister(0x04); + int16_t deltaX_high = 0, deltaY_high = 0; + + int16_t deltaXY_h = com_port.readRegister(0x12); + deltaX_high = (deltaXY_h << 4) & 0xF00; + deltaY_high = (deltaXY_h << 8) & 0xF00; + + if (deltaX_high & 0x800) + deltaX_high |= 0xf000; + if (deltaY_high & 0x800) + deltaY_high |= 0xf000; + + Pixart_OTS_OtsData otsData; + otsData.x = deltaX_high | deltaX_low; + otsData.y = deltaY_high | deltaY_low; + return otsData; +} + +Pixart_OTS_OtsData Pixart_OTS_GrabData_16bitXy::grab(Pixart_ComPort &com_port) +{ + int16_t deltaX_low = com_port.readRegister(0x03); + int16_t deltaY_low = com_port.readRegister(0x04); + int16_t deltaX_high = 0, deltaY_high = 0; + + deltaX_high = com_port.readRegister(0x11) << 8; + deltaY_high = com_port.readRegister(0x12) << 8; + + Pixart_OTS_OtsData otsData; + otsData.x = deltaX_high | deltaX_low; + otsData.y = deltaY_high | deltaY_low; + return otsData; +} + +Pixart_OTS_OtsData Pixart_OTS_GrabData_16bitXOnly::grab(Pixart_ComPort &com_port) +{ + Pixart_OTS_OtsData otsData; + otsData.x = 0; + otsData.y = 0; + return otsData; +}