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.h
- Revision:
- 0:2a85075b8467
- Child:
- 1:95917b856631
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Pixart_OTS.h Wed Mar 06 21:02:39 2019 +0000 @@ -0,0 +1,60 @@ +/* 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 + */ + +#pragma once +#include "mbed.h" +#include "Build_info.h" +#include "Pixart_ComPort.h" +#include "Pixart_OTS_GrabData.h" +#include "Pixart_OTS_InitSetting.h" + +#include <vector> +#include <string> + +enum Pixart_OTS_Model +{ + PIXART_OTS_MODEL_9125, + PIXART_OTS_MODEL_9126, + PIXART_OTS_MODEL_9150, + PIXART_OTS_MODEL_9130, + PIXART_OTS_MODEL_5101, +}; + +struct Pixart_OTS_Register +{ + uint8_t addr; + uint8_t value; +}; + + +class Pixart_OTS +{ +public: + Pixart_OTS(Serial &pc, Pixart_ComPort *comPort, Pixart_OTS_GrabData *grabData, const std::vector<Pixart_OTS_Register> &initRegisters, const std::string &model, const std::string &HwVer); + + bool sensor_init(); + void periodic_callback(); + static int get_default_i2c_slave_address(); + std::string get_model() const; + std::string get_HwVer() const; + +private: + Serial &m_pc; + Pixart_ComPort *m_comPort; + Pixart_OTS_GrabData *m_grabData; + std::vector<Pixart_OTS_Register> m_initRegisters; + std::string m_model; + std::string m_HwVer; + + int16_t m_totalX; + int16_t m_totalY; + + void print_build_info(); +}; + +Pixart_OTS* create_pixart_ots(Pixart_OTS_Model model, Serial &pc, I2C &i2c); +Pixart_OTS* create_pixart_ots(Pixart_OTS_Model model, Serial &pc, SPI &spi, DigitalOut &cs);