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
Fork of RT2_P3_students_G4 by
LinearCharacteristics.cpp@2:769ce5f06d3e, 2018-04-09 (annotated)
- Committer:
- altb
- Date:
- Mon Apr 09 08:01:29 2018 +0000
- Revision:
- 2:769ce5f06d3e
- Parent:
- 0:78ca29b4c49e
- Child:
- 4:2cc56521aa16
Changes from pmic
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| altb | 0:78ca29b4c49e | 1 | #include "LinearCharacteristics.h" |
| altb | 0:78ca29b4c49e | 2 | |
| altb | 0:78ca29b4c49e | 3 | using namespace std; |
| altb | 0:78ca29b4c49e | 4 | |
| altb | 2:769ce5f06d3e | 5 | LinearCharacteristics::LinearCharacteristics(float g, float o){ // standard lin characteristics |
| altb | 2:769ce5f06d3e | 6 | this->gain = g; |
| altb | 2:769ce5f06d3e | 7 | this->offset = o; |
| altb | 0:78ca29b4c49e | 8 | // ... |
| altb | 0:78ca29b4c49e | 9 | } |
| altb | 2:769ce5f06d3e | 10 | LinearCharacteristics::LinearCharacteristics(float x_min, float x_max, float y_min, float y_max){ // standard lin characteristics |
| altb | 2:769ce5f06d3e | 11 | this->gain = (y_max-y_min)/(x_max-x_min); |
| altb | 2:769ce5f06d3e | 12 | this->offset = x_max - y_max/this->gain; |
| altb | 2:769ce5f06d3e | 13 | |
| altb | 2:769ce5f06d3e | 14 | |
| altb | 2:769ce5f06d3e | 15 | } |
| altb | 2:769ce5f06d3e | 16 | |
| altb | 2:769ce5f06d3e | 17 | LinearCharacteristics::~LinearCharacteristics() {} |
| altb | 2:769ce5f06d3e | 18 | |
| altb | 2:769ce5f06d3e | 19 | |
| altb | 2:769ce5f06d3e | 20 | float LinearCharacteristics::eval(float x){ |
| altb | 2:769ce5f06d3e | 21 | |
| altb | 2:769ce5f06d3e | 22 | return (gain * (x-offset)); |
| altb | 2:769ce5f06d3e | 23 | |
| altb | 2:769ce5f06d3e | 24 | } |
