Bluetooth Connected TOF Sensor
Dependencies: BLE_API X_NUCLEO_6180XA1 X_NUCLEO_IDB0XA1 mbed
Fork of BLE_HeartRate_IDB0XA1 by
bricks/print.h@29:cf61a5826426, 2017-02-01 (annotated)
- Committer:
- hux
- Date:
- Wed Feb 01 22:35:28 2017 +0000
- Revision:
- 29:cf61a5826426
Small modification to reduce display flickering
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hux | 29:cf61a5826426 | 1 | // print.h - print value of a characteristic |
hux | 29:cf61a5826426 | 2 | // |
hux | 29:cf61a5826426 | 3 | // Synopsis: |
hux | 29:cf61a5826426 | 4 | // |
hux | 29:cf61a5826426 | 5 | // See also: CHARACTERISTIC, GET, SET |
hux | 29:cf61a5826426 | 6 | // |
hux | 29:cf61a5826426 | 7 | #ifndef _PRINT_H_ |
hux | 29:cf61a5826426 | 8 | #define _PRINT_H_ |
hux | 29:cf61a5826426 | 9 | |
hux | 29:cf61a5826426 | 10 | #include <stdio.h> |
hux | 29:cf61a5826426 | 11 | #include "ble/Gap.h" |
hux | 29:cf61a5826426 | 12 | #include "bricks/o.h" |
hux | 29:cf61a5826426 | 13 | #include "bricks/types.h" |
hux | 29:cf61a5826426 | 14 | #include "bricks/characteristic.h" |
hux | 29:cf61a5826426 | 15 | |
hux | 29:cf61a5826426 | 16 | //============================================================================== |
hux | 29:cf61a5826426 | 17 | // Some Callbacks |
hux | 29:cf61a5826426 | 18 | //============================================================================== |
hux | 29:cf61a5826426 | 19 | |
hux | 29:cf61a5826426 | 20 | inline void print(O&o, Characteristic<Buffer> &chr, const char *name) |
hux | 29:cf61a5826426 | 21 | { |
hux | 29:cf61a5826426 | 22 | //Serial out(USBTX, USBRX); // serial port to PC terminal |
hux | 29:cf61a5826426 | 23 | |
hux | 29:cf61a5826426 | 24 | Buffer data; uint8_t *p = data; |
hux | 29:cf61a5826426 | 25 | get(o,chr,data); |
hux | 29:cf61a5826426 | 26 | |
hux | 29:cf61a5826426 | 27 | printf("%s: %02x-%02x-%02x-%02x-%02x-",name,(int)(p[0]),(int)(p[1]),(int)(p[2]),(int)(p[3]),(int)(p[4])); |
hux | 29:cf61a5826426 | 28 | printf("%02x-%02x-%02x-%02x-%02x\r\n",(int)(p[5]),(int)(p[6]),(int)(p[7]),(int)(p[8]),(int)(p[9])); |
hux | 29:cf61a5826426 | 29 | } |
hux | 29:cf61a5826426 | 30 | |
hux | 29:cf61a5826426 | 31 | inline void print(O&o, Characteristic<Bool> &chr, const char *name) |
hux | 29:cf61a5826426 | 32 | { |
hux | 29:cf61a5826426 | 33 | //Serial out(USBTX, USBRX); // serial port to PC terminal |
hux | 29:cf61a5826426 | 34 | Bool data; |
hux | 29:cf61a5826426 | 35 | |
hux | 29:cf61a5826426 | 36 | get(o,chr,data); |
hux | 29:cf61a5826426 | 37 | printf("%s: %02x\r\n",name,data); |
hux | 29:cf61a5826426 | 38 | } |
hux | 29:cf61a5826426 | 39 | |
hux | 29:cf61a5826426 | 40 | // we provide also some PRINT methods for non Characteristics. If the value of |
hux | 29:cf61a5826426 | 41 | // a characteristic needs to be printed the value must be fetched before with |
hux | 29:cf61a5826426 | 42 | // the GET function. |
hux | 29:cf61a5826426 | 43 | |
hux | 29:cf61a5826426 | 44 | inline void print(O&o, Bool data, const char *name) |
hux | 29:cf61a5826426 | 45 | { |
hux | 29:cf61a5826426 | 46 | printf("%s: %02x\r\n",name,(int)data); |
hux | 29:cf61a5826426 | 47 | } |
hux | 29:cf61a5826426 | 48 | |
hux | 29:cf61a5826426 | 49 | #endif // _PRINT_H_ |