Implement a SD card into HW6

Dependencies:   SDFileSystem mbed

Fork of shomberg_hw_6 by Russell Shomberg

OCE360Input.cpp

Committer:
rshomberg
Date:
2018-10-30
Revision:
13:fa74bf0c3b8d
Parent:
12:ea407dcaff78
Child:
20:fc1690076f87

File content as of revision 13:fa74bf0c3b8d:

/**
    Temperature Sensor and Switch Read
    OCE360Input.cpp

    Purpose: Read a switch connected at p7
             Read a temperature sensor connected at p20
        
    @author  Russell Shomberg
    @created 2018-10-25
    @revised 2018-10-25
    @version 0.0
    
    Issues:    
    
*/ 
// INCLUDES
#include "mbed.h"
#include "OCE360Input.h"

// DEFINES
#define VREF 3.5
#define TEMP_CALIBRATION_A 0.1
#define TEMP_CALIBRATION_B 0

DigitalIn myswitch(p7);
AnalogIn Ain(p20);

int switchPosition;
int sensorVoltage;
int sensorTemp; 

int read_switch(void) {
    return myswitch;    
}

float read_sensor(void){
    return Ain*VREF*1000;  // voltage in mV
}

float convert_mV_to_temp(float sensorVoltage) {
    return sensorVoltage*TEMP_CALIBRATION_A+TEMP_CALIBRATION_B; //temp in deg C
}