PixArt Optical Track Sensor, OTS, demo program for P9130 sensor with library. Imported and modified from P9126 demo program. Initial release v1.0.
Dependencies: Pixart_OTS
Fork of OTS_P9130_Demo by
Diff: main.cpp
- Revision:
- 2:be9899699c7c
- Parent:
- 1:4c9b5b2f001e
- Child:
- 4:1b406caf9581
--- a/main.cpp Tue Feb 26 23:02:18 2019 +0000 +++ b/main.cpp Wed Mar 06 21:03:07 2019 +0000 @@ -3,42 +3,55 @@ * SPDX-License-Identifier: Apache-2.0 */ -/* PAW3007: Finger navigation chip. +/* PAT9126JA: Optical Tracking Sensor. * By PixArt Imaging Inc. * Primary Engineer: Hill Chen (PixArt USA) * * License: Apache-2.0; http://www.apache.org/licenses/LICENSE-2.0 */ -/* Revision History - * V1.1: February 26, 2019 - * Modify typo in comments. - * - * V1.0: February 25, 2019 +/* Demo Code Revision History + * V1.0: March 6, 2019 * First release. */ - #include "mbed.h" -#include "Pixart_OFN.h" +#include "Pixart_OTS.h" Serial pc(USBTX, USBRX); I2C i2c(I2C_SDA0, I2C_SCL0); -// main() runs in its own thread in the OS +static const Pixart_OTS_Model OTS_MODEL = PIXART_OTS_MODEL_9126; + int main() { - bool Result = false; - Pixart_OFN *m_Sensor = new Pixart_OFN(&i2c, &pc, 0.25f, Result); - if(Result) pc.printf("\r\n\n %s %s initialization successfully\r\n", PRODUCT, MODEL); - else{ pc.printf("\r\n\n %s %s fail on initialization", PRODUCT, MODEL); - while (true) ; + pc.baud(115200); + + Pixart_OTS *pixart_ots = create_pixart_ots(OTS_MODEL, pc, i2c); + + if (!pixart_ots) + { + pc.printf("\r\n\n Not on library support list %d", OTS_MODEL); + while (true); } - while (true){ -#ifndef USE_CALLBACK - m_Sensor->periodicCallback(); + bool result = pixart_ots->sensor_init(); + + if (result) + { + pc.printf("\r\n\n %s %s initialization successfully\r\n", PRODUCT, pixart_ots->get_model().c_str()); + } + else + { + pc.printf("\r\n\n %s %s fail on initialization", PRODUCT, pixart_ots->get_model().c_str()); + while (true); + } + + while (true) { +#ifndef USE_CALLBACK + pixart_ots->periodic_callback(); wait_ms(250); #endif } } +