For Hepta-Sat Lite
HeptaTemp.cpp@8:3cb7f1ea12bf, 2021-08-17 (annotated)
- Committer:
- heptasat2021
- Date:
- Tue Aug 17 10:51:03 2021 +0000
- Revision:
- 8:3cb7f1ea12bf
- Parent:
- 6:9a367d5cf53d
For Hepta-Sat Lite
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hepta2ume | 0:f74735cb01bc | 1 | #include"HeptaTemp.h" |
hepta2ume | 0:f74735cb01bc | 2 | #include"mbed.h" |
hepta2ume | 0:f74735cb01bc | 3 | |
hepta2ume | 0:f74735cb01bc | 4 | HeptaTemp::HeptaTemp(PinName pin) : _pin(pin) |
hepta2ume | 0:f74735cb01bc | 5 | { |
hepta2ume | 0:f74735cb01bc | 6 | |
hepta2ume | 0:f74735cb01bc | 7 | } |
hepta2ume | 0:f74735cb01bc | 8 | |
hepta2ume | 0:f74735cb01bc | 9 | void HeptaTemp::temp_sense(float* temp) |
hepta2ume | 0:f74735cb01bc | 10 | { |
heptasat2021 | 8:3cb7f1ea12bf | 11 | //temperature coefficient |
heptasat2021 | 8:3cb7f1ea12bf | 12 | *temp = ((_pin.read())*3.3-0.6)*100; |
hepta2ume | 0:f74735cb01bc | 13 | } |
hepta2ume | 0:f74735cb01bc | 14 | |
HEPTA | 3:96c3dd85be15 | 15 | void HeptaTemp::temp_sense_u16(char* temp_u16) |
hepta2ume | 0:f74735cb01bc | 16 | { |
hepta2ume | 0:f74735cb01bc | 17 | unsigned short temp_datas; |
hepta2ume | 0:f74735cb01bc | 18 | char temp1[8]= {0x00},temp2[8]= {0x00}; |
hepta2ume | 0:f74735cb01bc | 19 | temp_datas=_pin.read_u16()>>4; |
hepta2ume | 0:f74735cb01bc | 20 | sprintf( temp1, "%02X", (temp_datas >> 8) & 0x0F); |
hepta2ume | 0:f74735cb01bc | 21 | sprintf( temp2, "%02X", (temp_datas) & 0xFF); |
hepta2ume | 0:f74735cb01bc | 22 | temp_u16[0]=temp1[0]; |
hepta2ume | 0:f74735cb01bc | 23 | temp_u16[1]=temp1[1]; |
hepta2ume | 0:f74735cb01bc | 24 | temp_u16[2]=temp2[0]; |
hepta2ume | 0:f74735cb01bc | 25 | temp_u16[3]=temp2[1]; |
HEPTA | 3:96c3dd85be15 | 26 | //*dsize = 4; |
hepta2ume | 1:a23c2cd65379 | 27 | } |
hepta2ume | 1:a23c2cd65379 | 28 | |
hepta2ume | 1:a23c2cd65379 | 29 | void HeptaTemp::temp_sensing_vol(float* voltage) |
hepta2ume | 1:a23c2cd65379 | 30 | { |
heptasat2021 | 8:3cb7f1ea12bf | 31 | *voltage = (_pin.read())*3.3; |
hepta2ume | 0:f74735cb01bc | 32 | } |