-data logging revision

Dependencies:   FastPWM

Committer:
altb2
Date:
Sun May 02 19:32:30 2021 +0000
Revision:
0:d2e117716219
1st commit;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
altb2 0:d2e117716219 1 #include "LinearCharacteristics.h"
altb2 0:d2e117716219 2
altb2 0:d2e117716219 3 using namespace std;
altb2 0:d2e117716219 4
altb2 0:d2e117716219 5 LinearCharacteristics::LinearCharacteristics(float gain,float offset){ // standard lin characteristics
altb2 0:d2e117716219 6 this->gain = gain;
altb2 0:d2e117716219 7 this->offset = offset;
altb2 0:d2e117716219 8 this->ulim = 999999.0;
altb2 0:d2e117716219 9 this->llim = -999999.0;
altb2 0:d2e117716219 10 }
altb2 0:d2e117716219 11
altb2 0:d2e117716219 12 LinearCharacteristics::LinearCharacteristics(float xmin,float xmax, float ymin, float ymax){ // standard lin characteristics
altb2 0:d2e117716219 13 this->gain = (ymax - ymin)/(xmax - xmin);
altb2 0:d2e117716219 14 this->offset = xmax - ymax/this->gain;
altb2 0:d2e117716219 15 this->ulim = 999999.0;
altb2 0:d2e117716219 16 this->llim = -999999.0;
altb2 0:d2e117716219 17
altb2 0:d2e117716219 18 }
altb2 0:d2e117716219 19 LinearCharacteristics::LinearCharacteristics(float xmin,float xmax, float ymin, float ymax,float ll, float ul){ // standard lin characteristics
altb2 0:d2e117716219 20 this->gain = (ymax - ymin)/(xmax - xmin);
altb2 0:d2e117716219 21 this->offset = xmax - ymax/this->gain;
altb2 0:d2e117716219 22 this->llim = ll;
altb2 0:d2e117716219 23 this->ulim = ul;
altb2 0:d2e117716219 24
altb2 0:d2e117716219 25 }
altb2 0:d2e117716219 26
altb2 0:d2e117716219 27 LinearCharacteristics::~LinearCharacteristics() {}
altb2 0:d2e117716219 28
altb2 0:d2e117716219 29
altb2 0:d2e117716219 30 float LinearCharacteristics::evaluate(float x)
altb2 0:d2e117716219 31 {
altb2 0:d2e117716219 32 float dum = this->gain*(x - this->offset);
altb2 0:d2e117716219 33 if(dum > this->ulim)
altb2 0:d2e117716219 34 dum = this->ulim;
altb2 0:d2e117716219 35 if(dum < this->llim)
altb2 0:d2e117716219 36 dum = this->llim;
altb2 0:d2e117716219 37 return dum;
altb2 0:d2e117716219 38 }
altb2 0:d2e117716219 39
altb2 0:d2e117716219 40 void LinearCharacteristics::setup(float xmin,float xmax, float ymin, float ymax){ // standard lin characteristics
altb2 0:d2e117716219 41 this->gain = (ymax - ymin)/(xmax - xmin);
altb2 0:d2e117716219 42 this->offset = xmax - ymax/this->gain;
altb2 0:d2e117716219 43 this->ulim = 999999.0;
altb2 0:d2e117716219 44 this->llim = -999999.0;
altb2 0:d2e117716219 45 }
altb2 0:d2e117716219 46 void LinearCharacteristics::setup(float xmin,float xmax, float ymin, float ymax,float ll, float ul){ // standard lin characteristics
altb2 0:d2e117716219 47 this->gain = (ymax - ymin)/(xmax - xmin);
altb2 0:d2e117716219 48 this->offset = xmax - ymax/this->gain;
altb2 0:d2e117716219 49 this->llim = ll;
altb2 0:d2e117716219 50 this->ulim = ul;
altb2 0:d2e117716219 51 }
altb2 0:d2e117716219 52