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: driver_mbed_TH02
Revision 56:39847849d219, committed 2019-08-21
- Comitter:
- mbed_official
- Date:
- Wed Aug 21 07:01:49 2019 +0100
- Parent:
- 55:6f2e16ebde99
- Child:
- 57:36e87c44c920
- Commit message:
- Merge pull request #159 from hugueskamba/master
Remove floating point usage in application
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-lorawan
Changed in this revision
| DummySensor.h | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/DummySensor.h Tue Aug 20 15:01:49 2019 +0100
+++ b/DummySensor.h Wed Aug 21 07:01:49 2019 +0100
@@ -25,21 +25,21 @@
public:
DS1820(uint32_t)
{
- value = 1.0f;
+ value = 1;
};
bool begin()
{
return true;
};
void startConversion() {};
- float read()
+ int32_t read()
{
- value += 1.1f;
+ value += 2;
return value;
}
private:
- float value;
+ int32_t value;
};
--- a/main.cpp Tue Aug 20 15:01:49 2019 +0100
+++ b/main.cpp Wed Aug 21 07:01:49 2019 +0100
@@ -152,19 +152,19 @@
{
uint16_t packet_len;
int16_t retcode;
- float sensor_value;
+ int32_t sensor_value;
if (ds1820.begin()) {
ds1820.startConversion();
sensor_value = ds1820.read();
- printf("\r\n Dummy Sensor Value = %3.1f \r\n", sensor_value);
+ printf("\r\n Dummy Sensor Value = %d \r\n", sensor_value);
ds1820.startConversion();
} else {
printf("\r\n No sensor found \r\n");
return;
}
- packet_len = sprintf((char *) tx_buffer, "Dummy Sensor Value is %3.1f",
+ packet_len = sprintf((char *) tx_buffer, "Dummy Sensor Value is %d",
sensor_value);
retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, tx_buffer, packet_len,