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: mbed ros_lib_kinetic
utilities.cpp@7:e165f5119950, 2019-10-14 (annotated)
- Committer:
- clarakeng
- Date:
- Mon Oct 14 23:53:05 2019 +0000
- Revision:
- 7:e165f5119950
- Parent:
- 5:864709d3eb76
Test comment
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Knillinux | 0:dd126a1080d3 | 1 | |
Knillinux | 0:dd126a1080d3 | 2 | #include "utilities.h" |
Knillinux | 0:dd126a1080d3 | 3 | #include "mbed.h" |
Knillinux | 0:dd126a1080d3 | 4 | |
Knillinux | 0:dd126a1080d3 | 5 | namespace utils { |
Knillinux | 0:dd126a1080d3 | 6 | |
Knillinux | 0:dd126a1080d3 | 7 | float smooth(float data, float filterVal, float smoothedVal) { |
Knillinux | 0:dd126a1080d3 | 8 | |
Knillinux | 0:dd126a1080d3 | 9 | if (filterVal > 1) { // check to make sure param's are within range |
Knillinux | 0:dd126a1080d3 | 10 | filterVal = .99; |
Knillinux | 0:dd126a1080d3 | 11 | } else if (filterVal <= 0) { |
Knillinux | 0:dd126a1080d3 | 12 | filterVal = 0; |
Knillinux | 0:dd126a1080d3 | 13 | } |
Knillinux | 0:dd126a1080d3 | 14 | |
Knillinux | 0:dd126a1080d3 | 15 | smoothedVal = (data * (1 - filterVal)) + (smoothedVal * filterVal); |
Knillinux | 0:dd126a1080d3 | 16 | |
Knillinux | 0:dd126a1080d3 | 17 | return (float)smoothedVal; |
Knillinux | 0:dd126a1080d3 | 18 | } |
Knillinux | 1:40bdbe1a93b7 | 19 | |
Knillinux | 1:40bdbe1a93b7 | 20 | float min(float a, float b) { |
Knillinux | 1:40bdbe1a93b7 | 21 | if (a < b) |
Knillinux | 1:40bdbe1a93b7 | 22 | return a; |
Knillinux | 1:40bdbe1a93b7 | 23 | else |
Knillinux | 1:40bdbe1a93b7 | 24 | return b; |
Knillinux | 1:40bdbe1a93b7 | 25 | } |
ambyld | 5:864709d3eb76 | 26 | |
ambyld | 5:864709d3eb76 | 27 | void printBits(char myByte, Serial &pc) { |
ambyld | 5:864709d3eb76 | 28 | for (char mask = 0x80; mask; mask >>= 1) { |
ambyld | 5:864709d3eb76 | 29 | if(mask & myByte) |
ambyld | 5:864709d3eb76 | 30 | pc.putc('1'); |
ambyld | 5:864709d3eb76 | 31 | else |
ambyld | 5:864709d3eb76 | 32 | pc.putc('0'); |
ambyld | 5:864709d3eb76 | 33 | } |
ambyld | 5:864709d3eb76 | 34 | } |
Knillinux | 0:dd126a1080d3 | 35 | |
Knillinux | 0:dd126a1080d3 | 36 | } // end utils namespace |