Implement a SD card into HW6

Dependencies:   SDFileSystem mbed

Fork of shomberg_hw_6 by Russell Shomberg

Revision:
9:da0b72918880
Parent:
8:d6560caeda9a
Child:
10:c9a438114fbd
diff -r d6560caeda9a -r da0b72918880 main.cpp
--- a/main.cpp	Tue Oct 23 14:04:01 2018 +0000
+++ b/main.cpp	Thu Oct 25 18:12:33 2018 +0000
@@ -10,7 +10,7 @@
     
     @author  Russell Shomberg
     @created 2018-10-23
-    @revised 2018-10-23
+    @revised 2018-10-25
     @version 0.0
     
     Issues: No Decimal point for temperature    
@@ -19,27 +19,17 @@
 
 // INCLUDES
 #include "mbed.h"
+#include "OCE360Input.h"
+#include "SegDisplay.h"
 
-// INPUTS
-DigitalIn switchPosition(p7);   // wire p7 to middle connection of 2 position switch between Vref and GND
-AnalogIn Ain(p20);              // wire p20 to a variable resister connected from Vref and GND
 
 // OUTPUTS
 Serial pc(USBTX, USBRX);        // for debugging
 
-//// Pin Map for 7-Seg starts bottom left, goes CCW
-BusOut Seg1(p12,p13,p14,p15,p16,p17,p18,p19); //01 02 03 04 05 06 07 08 09 10
-BusOut Seg2(p21,p22,p23,p24,p25,p26,p27,p28); //E  D  CC C  DP B  A  CC F  G
-
-// FUNCTIONS
-char SegConvert(int SegValue);
-
 // VARIABLES
 int outputT= 0;
 float v0;
 float deltav;
-float temp0;
-float deltatemp;
 float val;
 int ones;
 int tens;
@@ -47,26 +37,23 @@
 
 int main() {
     // read starting voltage from temperature sensor
-    v0 = Ain*3.5*1000;
+    v0 = read_sensor();
     
     while(1) {
         // Read Switch if on output temp else output mV
-        outputT = switchPosition;
-        
-        // Read temperature sensor
-        deltav = Ain*3.5*1000-v0;
+        outputT = read_switch();
+        deltav = read_sensor()-v0;
         
         // Output to terminal
         if (outputT) {
             // Convert to temp
-            deltatemp = deltav/10;
-            printf("Temperature Difference = %1.2f degC\n\r", deltatemp);
-            val = deltatemp;
+            val = convert_mV_to_temp(deltav);
+            //printf("Temperature Difference = %1.2f degC\n\r", val);
         }
 
         else {
-            printf("Voltage Difference = %1.2f mV\n\r", deltav);
             val = deltav;
+            //printf("Voltage Difference = %1.2f mV\n\r", val);
         }
         
         // Convert val to ones and tens char
@@ -74,8 +61,8 @@
         tens = fmod(rint(val) / 10, 10);
         
 
-        Seg1 = ~SegConvert(ones);
-        Seg2 = ~SegConvert(tens);
+        Seg1 = SegConvert(ones);
+        Seg2 = SegConvert(tens);
         
         
         wait(1);
@@ -84,25 +71,3 @@
     
 }
 
-
-//ones: 12 13 14 15 16 17 18 19
-//      A  B  C  D  E  F  G  P 
-//tens: 21 22 23 24 25 26 27 28
-//
-
-char SegConvert(int SegValue) {         // function 'SegConvert'
-    char SegByte=0x00;
-    switch (abs(SegValue)) {           // ABCDEFGP
-        case 0 : SegByte= 0x3F;break;  // 11111100 binary
-        case 1 : SegByte= 0x06;break;  // 01100000 binary
-        case 2 : SegByte= 0x5B;break;  // 11110110 binary
-        case 3 : SegByte= 0x4F;break;  // 10011110 binary
-        case 4 : SegByte= 0x66;break;  // 11001100 binary
-        case 5 : SegByte= 0x6D;break;  // 11011010 binary
-        case 6 : SegByte= 0x7D;break;  // 11111010 binary
-        case 7 : SegByte= 0x07;break;  // 00001110 binary
-        case 8 : SegByte= 0x7F;break;  // 11111110 binary
-        case 9 : SegByte= 0x6F;break;  // 11011110 binary
-    }
-    return SegByte;
-}
\ No newline at end of file