PMT9123 OTS on Nucleo (Initial Release)
Fork of Pixart_9123_Nucleo_Library by
Diff: OTC.h
- Revision:
- 0:7aefc9ab3301
diff -r 000000000000 -r 7aefc9ab3301 OTC.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/OTC.h Thu May 11 17:32:04 2017 +0000
@@ -0,0 +1,45 @@
+
+/* The callback function when motion happen
+
+ */
+typedef void (*OTSCallback)(int16_t value);
+
+// Helper macro
+#define BIT_CLEAR(REG,MASK) (REG &= ~MASK)
+#define BIT_SET(REG,MASK) (REG |= MASK)
+#define IS_BIT_CLEAR(REG,MASK) ((REG & MASK)==0x00)
+#define IS_BIT_SET(REG,MASK) ((REG & MASK)==MASK)
+
+class Pixart_OTS
+{
+ private:
+ Ticker m_ticker;
+ I2C *m_i2c;
+ //Serial *m_pc;
+ int m_Period;
+ uint8_t m_Address;
+ bool m_WriteEnable;
+
+ OTSCallback m_OTSCallback;
+ void periodicCallback(void);
+ bool PMT9123_init();
+ void PMT9123_ReadMotion();
+
+ // Internal read and write function that is only single transaction
+ void writeRegister(uint8_t addr, uint8_t data);
+ uint8_t readRegister(uint8_t addr);
+
+ public:
+ /*
+ * The initial function for Gesture class
+ * i2c ==> The I2C object from outside, the clock rate should be 400k
+ * Period ==> The polling rate for gesture, in ms
+ * callback ==> The call back function for gesture status
+ * Result ==> The result for initialize
+ */
+ Pixart_OTS(I2C *i2c, int Period,OTSCallback callback,bool &Result);
+
+ // Public register read and write function, which include steps to ensure successful write and read
+ uint8_t Register_Write(uint8_t addr, uint8_t data);
+ uint8_t Register_Read(uint8_t addr);
+};
\ No newline at end of file

Low Power Right Angle Optical Track Sensor PMT9123