GAP based TOF Demo
Dependencies: BLE_API X_NUCLEO_6180XA1 mbed
Fork of BLE_HeartRate_IDB0XA1 by
shields/xn6180.h@28:86a594313434, 2018-08-20 (annotated)
- Committer:
- hux
- Date:
- Mon Aug 20 16:41:36 2018 +0000
- Revision:
- 28:86a594313434
GAP based TOF Sensor
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hux | 28:86a594313434 | 1 | // xn6180.h - X-NUCLEO 6180XA1 expansion board functionality |
hux | 28:86a594313434 | 2 | // |
hux | 28:86a594313434 | 3 | // Example 1: |
hux | 28:86a594313434 | 4 | // |
hux | 28:86a594313434 | 5 | // DisplayShield *pShield = new DisplayShield; |
hux | 28:86a594313434 | 6 | // pShield->init("INIT",1000) // display "INIT" @ 1000 ms |
hux | 28:86a594313434 | 7 | // |
hux | 28:86a594313434 | 8 | #ifndef _XN6180_H_ |
hux | 28:86a594313434 | 9 | #define _XN6180_H_ |
hux | 28:86a594313434 | 10 | |
hux | 28:86a594313434 | 11 | #include "x_nucleo_6180xa1.h" |
hux | 28:86a594313434 | 12 | |
hux | 28:86a594313434 | 13 | #define InterruptTOF range_continuous_interrupt // just an alias |
hux | 28:86a594313434 | 14 | #define InterruptALS als_continuous_interrupt // just an alias |
hux | 28:86a594313434 | 15 | #define PollTOF range_continuous_poll // just an alias |
hux | 28:86a594313434 | 16 | #define PollALS als_continuous_poll // just an alias |
hux | 28:86a594313434 | 17 | |
hux | 28:86a594313434 | 18 | enum OpModeIntPoll_t { PollMeasure, IntMeasure }; // red slider position |
hux | 28:86a594313434 | 19 | |
hux | 28:86a594313434 | 20 | typedef OperatingMode OpMode; // a short hand for Operating Mode |
hux | 28:86a594313434 | 21 | |
hux | 28:86a594313434 | 22 | class DisplayShield |
hux | 28:86a594313434 | 23 | { |
hux | 28:86a594313434 | 24 | public: |
hux | 28:86a594313434 | 25 | DevI2C *pDevice; |
hux | 28:86a594313434 | 26 | X_NUCLEO_6180XA1 *pBoard; |
hux | 28:86a594313434 | 27 | MeasureData_t data; |
hux | 28:86a594313434 | 28 | bool flagService; // data read service request flag |
hux | 28:86a594313434 | 29 | |
hux | 28:86a594313434 | 30 | public: |
hux | 28:86a594313434 | 31 | OperatingMode curMode; // board's current operating mode |
hux | 28:86a594313434 | 32 | OperatingMode prvMode; // board's previous operating mode |
hux | 28:86a594313434 | 33 | |
hux | 28:86a594313434 | 34 | public: // construction |
hux | 28:86a594313434 | 35 | DisplayShield(); // constructor |
hux | 28:86a594313434 | 36 | void init(const char *msg = 0, int msec = 1000); // initialize shield |
hux | 28:86a594313434 | 37 | |
hux | 28:86a594313434 | 38 | public: // public methods |
hux | 28:86a594313434 | 39 | void set(); // set stop request |
hux | 28:86a594313434 | 40 | void clear(); // clear stop request |
hux | 28:86a594313434 | 41 | bool request(); // stop requested? |
hux | 28:86a594313434 | 42 | void disable(); // disable interrupt |
hux | 28:86a594313434 | 43 | void ready(); // set data ready status |
hux | 28:86a594313434 | 44 | int handle(); // handle IRQ |
hux | 28:86a594313434 | 45 | int start(void (*pCb)(void));// start measurement |
hux | 28:86a594313434 | 46 | // int start(); // start measurement |
hux | 28:86a594313434 | 47 | int stop(); // stop current measurement |
hux | 28:86a594313434 | 48 | |
hux | 28:86a594313434 | 49 | void display(const char * msg); |
hux | 28:86a594313434 | 50 | void display(const char * msg, int msec); // display & wait |
hux | 28:86a594313434 | 51 | void refresh(OpMode mode); |
hux | 28:86a594313434 | 52 | void refresh(); // refresh display in current mode |
hux | 28:86a594313434 | 53 | |
hux | 28:86a594313434 | 54 | public: |
hux | 28:86a594313434 | 55 | bool slider(enum OpModeIntPoll_t OpMode); // did slider change? |
hux | 28:86a594313434 | 56 | bool setup(OpMode mode); // setup the operation mode |
hux | 28:86a594313434 | 57 | |
hux | 28:86a594313434 | 58 | void startMessage(OpMode mode); |
hux | 28:86a594313434 | 59 | void startMessage(); |
hux | 28:86a594313434 | 60 | void stopMessage(OpMode mode); |
hux | 28:86a594313434 | 61 | void stopMessage(); |
hux | 28:86a594313434 | 62 | }; |
hux | 28:86a594313434 | 63 | |
hux | 28:86a594313434 | 64 | |
hux | 28:86a594313434 | 65 | #endif // _XN6180_H_ |