3rd Repo, trying to figure this out.

Dependencies:   LPS25H hts221

Fork of SOFT253_Template_Weather_OS_54 by Stage-1 Students SoCEM

Committer:
aburch1
Date:
Thu May 11 19:23:55 2017 +0000
Revision:
83:0d3572a8a851
Parent:
50:c07e968b9582
Child:
85:422d0a1b95cf
Comments cleaned and improved throughout classes. Main header class comment complete, other class comments still need to be written.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Netaphous 50:c07e968b9582 1 #include "FakeSensor.h"
Netaphous 50:c07e968b9582 2 #include "mbed.h"
Netaphous 50:c07e968b9582 3
aburch1 83:0d3572a8a851 4 /**
Netaphous 50:c07e968b9582 5 Constructor
Netaphous 50:c07e968b9582 6 Takes in minimum and maximum values for fake pressure readings
aburch1 83:0d3572a8a851 7
aburch1 83:0d3572a8a851 8 @param pressMin : Minimum value for pressure.
aburch1 83:0d3572a8a851 9 @param pressMax : Maximum value for pressure.
Netaphous 50:c07e968b9582 10 */
Netaphous 50:c07e968b9582 11 FakeBarometer::FakeBarometer(float pressMin, float pressMax)
Netaphous 50:c07e968b9582 12 {
Netaphous 50:c07e968b9582 13 pressureMin = pressMin;
Netaphous 50:c07e968b9582 14 pressureMax = pressMax;
Netaphous 50:c07e968b9582 15 }
Netaphous 50:c07e968b9582 16
aburch1 83:0d3572a8a851 17 /**
aburch1 83:0d3572a8a851 18 Fakes a get call to the sensor by doing nothing.
Netaphous 50:c07e968b9582 19 */
Netaphous 50:c07e968b9582 20 void FakeBarometer::get() {}
Netaphous 50:c07e968b9582 21
aburch1 83:0d3572a8a851 22 /**
Netaphous 50:c07e968b9582 23 Generates a random number for pressure using the range given in the constructor
aburch1 83:0d3572a8a851 24
aburch1 83:0d3572a8a851 25 @return actual : The random number generated, simulating pressure.
Netaphous 50:c07e968b9582 26 */
Netaphous 50:c07e968b9582 27 float FakeBarometer::pressure()
Netaphous 50:c07e968b9582 28 {
Netaphous 50:c07e968b9582 29 int rangeMax = 1000;
Netaphous 50:c07e968b9582 30 float targetRange = pressureMax - pressureMin;
Netaphous 50:c07e968b9582 31 srand(time(NULL));
Netaphous 50:c07e968b9582 32 int randNum = (rand()%rangeMax);
Netaphous 50:c07e968b9582 33 float perc = (float)randNum / rangeMax;
Netaphous 50:c07e968b9582 34 float percRange = perc * targetRange;
Netaphous 50:c07e968b9582 35 float actual = percRange + pressureMin;
Netaphous 50:c07e968b9582 36 return actual;
Netaphous 50:c07e968b9582 37 }
Netaphous 50:c07e968b9582 38