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