Jason Schilling / Mbed 2 deprecated miniProject7

Dependencies:   mbed TextLCD

Committer:
nthompson22
Date:
Thu Jan 17 00:12:40 2019 +0000
Revision:
4:19878f73f3e3
Parent:
3:7d5e3b2ed878
Child:
5:8582a28cf944
Worked on Temperature.cpp

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nthompson22 3:7d5e3b2ed878 1 #include "Temperature.h"
nthompson22 3:7d5e3b2ed878 2 I2C i2cTemp(p9, p10);
nthompson22 3:7d5e3b2ed878 3
nthompson22 3:7d5e3b2ed878 4 float tempFar(float temp) {
nthompson22 3:7d5e3b2ed878 5 float far;
nthompson22 3:7d5e3b2ed878 6 far = (temp*9/5)+32;
nthompson22 3:7d5e3b2ed878 7 return far;
nthompson22 3:7d5e3b2ed878 8 }
nthompson22 3:7d5e3b2ed878 9
nthompson22 3:7d5e3b2ed878 10 float tempRan(float temp) {
nthompson22 3:7d5e3b2ed878 11 float ran;
nthompson22 3:7d5e3b2ed878 12 ran = (temp*9/5)+491.67;
nthompson22 3:7d5e3b2ed878 13 return ran;
nthompson22 3:7d5e3b2ed878 14 }
nthompson22 3:7d5e3b2ed878 15
nthompson22 3:7d5e3b2ed878 16 float tempKel(float temp){
nthompson22 3:7d5e3b2ed878 17 float kel;
nthompson22 3:7d5e3b2ed878 18 kel = temp+273;
nthompson22 3:7d5e3b2ed878 19 return kel;
nthompson22 3:7d5e3b2ed878 20 }
nthompson22 3:7d5e3b2ed878 21
nthompson22 3:7d5e3b2ed878 22 void tempConfig(void) {
nthompson22 3:7d5e3b2ed878 23
nthompson22 3:7d5e3b2ed878 24 }
nthompson22 3:7d5e3b2ed878 25
nthompson22 3:7d5e3b2ed878 26 float readTemp(rawTemp) {
nthompson22 4:19878f73f3e3 27 short rawTemp;
nthompson22 4:19878f73f3e3 28 float temp;
nthompson22 4:19878f73f3e3 29 char buff[2];
nthompson22 4:19878f73f3e3 30 const int tempAddr = 0x90;
nthompson22 4:19878f73f3e3 31 tempSensor.read(tempAddr, buff, 2);
nthompson22 4:19878f73f3e3 32 rawTemp = (buff[0] <<8) + buff[1];
nthompson22 4:19878f73f3e3 33 rawTemp = rawTemp >> 4;
nthompson22 4:19878f73f3e3 34 temp = 0.0625 * rawTemp;
nthompson22 3:7d5e3b2ed878 35 }