Implement a SD card into HW6

Dependencies:   SDFileSystem mbed

Fork of shomberg_hw_6 by Russell Shomberg

main.cpp

Committer:
rshomberg
Date:
2018-10-31
Revision:
18:699b41309be7
Parent:
12:ea407dcaff78
Child:
19:1f4dd59bbe6b

File content as of revision 18:699b41309be7:

/**
    Temperature Sensor for hw6
    main.cpp

    Purpose:    Read signal from TMP36 connected to pin20
                Toggle switch connected to pin07 activates SD logging
                Log: Time Elasped, Current Voltage, Current Temp, Delta Temp
                Finish log -> save file and send to USB serial port

    @author  Russell Shomberg
    @created 2018-10-31
    @revised 2018-10-31
    @version 0.0

    Issues:

*/

// INCLUDES
#include "mbed.h"
#include "OCE360Input.h"
#include "SDFileSystem.h"

// OUTPUTS
Serial pc(USBTX, USBRX);        // for debugging

// VARIABLES
int outputT= 0;
float starting_voltage;
float starting_temp;

float current_time;
float current_voltage;
float current_temp;



int main()
{

    while(1) {
        while(read_switch()) {  // skip everything if switch is off
            // Take initial readings
            starting_voltage = read_sensor();
            starting_temp = onvert_mV_to_temp(starting_voltage);

            // Initialize a file

            // Write header to file
            //"Time (s), Voltage (mv), Temperature (C), Delta T (C)\n\r"

            // start a loop that logging
            // exiting this loop will initialize data save procedures
            while(read_switch()) { // Main loop for logging

                // Get data for logging
                current_time = check_time();
                current_voltage = read_sensor();
                current_temp = convert_mV_to_temp(current_voltage);

                //"%1.2f, %1.2f, %1.2f, %1.2f \n\r", current_time, current_voltage, current_temp, current_temp-starting_temp
                
                wait(1);
            }
            // This code runs when the switch is toggled off
            // Close out file
            
            // Print to USB serial

        }
        // Re-enter main while loop
        //continuously check for switch to turn on again
    }
}