Russell Shomberg
/
shomberg_hw_6
HW6 for OCE560
Fork of shomberg_hw_5 by
OCE360Input.cpp@12:ea407dcaff78, 2018-10-25 (annotated)
- Committer:
- rshomberg
- Date:
- Thu Oct 25 22:43:36 2018 +0000
- Revision:
- 12:ea407dcaff78
- Parent:
- 11:42914083ac70
- Child:
- 13:fa74bf0c3b8d
made SegWrite function and moved pin assignments to header files. This does not work.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rshomberg | 9:da0b72918880 | 1 | /** |
rshomberg | 9:da0b72918880 | 2 | Temperature Sensor and Switch Read |
rshomberg | 9:da0b72918880 | 3 | OCE360Input.cpp |
rshomberg | 9:da0b72918880 | 4 | |
rshomberg | 9:da0b72918880 | 5 | Purpose: Read a switch connected at p7 |
rshomberg | 9:da0b72918880 | 6 | Read a temperature sensor connected at p20 |
rshomberg | 9:da0b72918880 | 7 | |
rshomberg | 9:da0b72918880 | 8 | @author Russell Shomberg |
rshomberg | 9:da0b72918880 | 9 | @created 2018-10-25 |
rshomberg | 9:da0b72918880 | 10 | @revised 2018-10-25 |
rshomberg | 9:da0b72918880 | 11 | @version 0.0 |
rshomberg | 9:da0b72918880 | 12 | |
rshomberg | 9:da0b72918880 | 13 | Issues: |
rshomberg | 9:da0b72918880 | 14 | |
rshomberg | 9:da0b72918880 | 15 | */ |
rshomberg | 9:da0b72918880 | 16 | // INCLUDES |
rshomberg | 9:da0b72918880 | 17 | #include "mbed.h" |
rshomberg | 9:da0b72918880 | 18 | #include "OCE360Input.h" |
rshomberg | 9:da0b72918880 | 19 | |
rshomberg | 9:da0b72918880 | 20 | // DEFINES |
rshomberg | 9:da0b72918880 | 21 | #define VREF 3.5 |
rshomberg | 12:ea407dcaff78 | 22 | #define TEMP_CALIBRATION_A 0.1 |
rshomberg | 9:da0b72918880 | 23 | #define TEMP_CALIBRATION_B 0 |
rshomberg | 9:da0b72918880 | 24 | |
rshomberg | 12:ea407dcaff78 | 25 | |
rshomberg | 11:42914083ac70 | 26 | |
rshomberg | 11:42914083ac70 | 27 | int switchPosition; |
rshomberg | 11:42914083ac70 | 28 | int sensorVoltage; |
rshomberg | 11:42914083ac70 | 29 | int sensorTemp; |
rshomberg | 11:42914083ac70 | 30 | |
rshomberg | 9:da0b72918880 | 31 | int read_switch(void) { |
rshomberg | 9:da0b72918880 | 32 | return myswitch; |
rshomberg | 9:da0b72918880 | 33 | } |
rshomberg | 9:da0b72918880 | 34 | |
rshomberg | 9:da0b72918880 | 35 | float read_sensor(void){ |
rshomberg | 9:da0b72918880 | 36 | return Ain*VREF*1000; |
rshomberg | 9:da0b72918880 | 37 | } |
rshomberg | 9:da0b72918880 | 38 | |
rshomberg | 11:42914083ac70 | 39 | float convert_mV_to_temp(float sensorVoltage) { |
rshomberg | 9:da0b72918880 | 40 | return sensorVoltage*TEMP_CALIBRATION_A+TEMP_CALIBRATION_B; |
rshomberg | 9:da0b72918880 | 41 | } |