Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BufferedSerial SX1276GenericLib USBDeviceHT mbed Crypto X_NUCLEO_IKS01A2
Fork of STM32L0_LoRa by
Revision 22:2c1359292de1, committed 2018-05-22
- Comitter:
- marcozecchini
- Date:
- Tue May 22 21:33:34 2018 +0000
- Parent:
- 21:5d64f9f79190
- Child:
- 23:5d46bbe685a1
- Commit message:
- get_distance() addition
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| main.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue May 22 21:29:24 2018 +0000
+++ b/main.cpp Tue May 22 21:33:34 2018 +0000
@@ -25,13 +25,18 @@
print_stuff();
while(1){
- //Ultrasonic measurement
- long distance = sensor.distance();
- dprintf("distance %d \n",distance);
char message[8];//Message to be sent
- sprintf(message, "%d", distance);
+ get_distance(message);
SendAndBack((uint8_t*)message);
}
+}
+
+void get_distance(char message[]){
+ //Ultrasonic measurement
+ long distance = sensor.distance();
+ dprintf("distance %d \n",distance);
+
+ sprintf(message, "%d", distance);
}
\ No newline at end of file
--- a/main.h Tue May 22 21:29:24 2018 +0000 +++ b/main.h Tue May 22 21:33:34 2018 +0000 @@ -18,7 +18,7 @@ #ifdef FEATURE_USBSERIAL extern USBSerialBuffered *usb; #endif -void get_distance(uint8_t* message); +void get_distance(char message[]); extern bool _useDprintf; extern void InitSerial(int timeout, DigitalOut *led); extern void dump(const char *title, const void *data, int len, bool dwords = false);
