PixArt Optical Track Sensor, OTS, demo program for P9125 sensor with library. Imported and modified from P9125 demo program. Initial release v1.0.

Dependencies:   Pixart_OTS

Fork of OTS_P9125_Demo by Hill Chen

main.cpp

Committer:
PixArtHC
Date:
2019-03-06
Revision:
4:1b406caf9581
Parent:
2:be9899699c7c

File content as of revision 4:1b406caf9581:

/* mbed Microcontroller Library
 * Copyright (c) 2018 ARM Limited
 * SPDX-License-Identifier: Apache-2.0
 */

/* PAT9125EL: 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
 */
 
/* Demo Code Revision History
 * V1.0: March 6, 2019
 * First release.
 */

#include "mbed.h"
#include "Pixart_OTS.h"

Serial  pc(USBTX, USBRX);
SPI spi(p23, p24, p25); //mosi, miso, sclk
DigitalOut cs(p22);     //chip select

static const Pixart_OTS_Model OTS_MODEL = PIXART_OTS_MODEL_9125;

int main()
{
    pc.baud(115200);

    Pixart_OTS *pixart_ots = create_pixart_ots(OTS_MODEL, pc, spi, cs);

    if (!pixart_ots)
    {
        pc.printf("\r\n\n Not on library support list %d", OTS_MODEL);
        while (true);
    }

    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        
    }
}