From d93e1fa654dc388d0e0fbc00e74f879c4a01c0ea Mon Sep 17 00:00:00 2001 From: 10andwil <48197978+10andwil@users.noreply.github.com> Date: Mon, 8 Apr 2019 11:36:06 -0600 Subject: [PATCH 1/2] display additional digits with cm reading --- .vscode/ipch/62a4c2bf7d3da721/mmap_address.bin | Bin 0 -> 8 bytes SharpRangerReader.ino | 8 ++++---- 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 .vscode/ipch/62a4c2bf7d3da721/mmap_address.bin diff --git a/.vscode/ipch/62a4c2bf7d3da721/mmap_address.bin b/.vscode/ipch/62a4c2bf7d3da721/mmap_address.bin new file mode 100644 index 0000000000000000000000000000000000000000..862b8428b9e068428b1a4e8a38f94019008d8940 GIT binary patch literal 8 NcmZQzU~Ksh1ON<}1cCqn literal 0 HcmV?d00001 diff --git a/SharpRangerReader.ino b/SharpRangerReader.ino index fdd3059..b897edc 100644 --- a/SharpRangerReader.ino +++ b/SharpRangerReader.ino @@ -13,9 +13,9 @@ Author: Marcus Ahlberg (marcus[at]aahlborg.se) #define LEFT_EDGE_ADDR 0xF9 // A #define PEAK_EDGE_ADDR 0xFA // B -uint8_t distance_raw[2] = {0}; +float distance_raw[2] = {0}; uint8_t shift = 0; -uint8_t distance_cm = 0; +float distance_cm = 0; char buf[100]; void setup() @@ -57,8 +57,8 @@ void loop() // Print distance in cm distance_cm = (distance_raw[0] * 16 + distance_raw[1]) / 16 / (int)pow(2, shift); - sprintf(buf, "Distance %u cm", distance_cm); - Serial.println(buf); + dtostrf(distance_cm, 10, 2, buf); + Serial.print("Distance: "); Serial.print(buf); Serial.println(" cm"); } else { From 597eae14d3d2b633de8c852faa0c78d44acec7f3 Mon Sep 17 00:00:00 2001 From: 10andwil <48197978+10andwil@users.noreply.github.com> Date: Mon, 8 Apr 2019 11:37:51 -0600 Subject: [PATCH 2/2] Delete mmap_address.bin --- .vscode/ipch/62a4c2bf7d3da721/mmap_address.bin | Bin 8 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .vscode/ipch/62a4c2bf7d3da721/mmap_address.bin diff --git a/.vscode/ipch/62a4c2bf7d3da721/mmap_address.bin b/.vscode/ipch/62a4c2bf7d3da721/mmap_address.bin deleted file mode 100644 index 862b8428b9e068428b1a4e8a38f94019008d8940..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8 NcmZQzU~Ksh1ON<}1cCqn