4180 lab 1

Dependencies:   mbed MCP23S17 PinDetect USBDevice

Revision:
7:b7720a8623b5
Parent:
6:e346d2a3010f
Child:
10:0886afdfb170
--- a/main.cpp	Wed Jan 15 20:06:00 2020 +0000
+++ b/main.cpp	Tue Jan 21 20:02:09 2020 +0000
@@ -1,58 +1,63 @@
 #include "mbed.h"
 #include "RGBLed.h"
 #include "PinDetect.h"
-#include "part4.h"
+//#include "part4.h"
+//#include "part6.h"
+#include "part7.h"
+//#include "part8.h"
+//#include "part9.h"
+//#include "watchdog_ec.h"
 
-DigitalOut myled(p26);
-PwmOut builtinLED(LED1);
-DigitalIn pb(p22);
+//DigitalOut myled(p26);
+//PwmOut builtinLED(LED1);
+//DigitalIn pb(p22);
 //DigitalIn pb2(p21);
 
 // p20 is most significant bit
-PinDetect redSelect(p18);
-PinDetect blueSelect(p18);
-PinDetect greenSelect(p20);
-
-PinName redPin = p24;
-PinName greenPin = p25;
-PinName bluePin = p23;
-
-PinDetect pb1(p21);
-PinDetect pb2(p22);
+//PinDetect redSelect(p18);
+//PinDetect blueSelect(p19);
+//PinDetect greenSelect(p20);
+//
+//PinName redPin = p24;
+//PinName greenPin = p25;
+//PinName bluePin = p23;
+//
+//PinDetect pb1(p21);
+//PinDetect pb2(p22);
 
 float volatile p = 1.0f;
 
 void pb1_hit_callback() {
     if (p > 0) {
-        p -= 0.1;
+        p -= 0.1f;
     }
 }
 
 void pb2_hit_callback() {
     if (p < 1) {
-        p += 0.1;
+        p += 0.1f;
     }
 }
 
-RGBLed myRGBLed = RGBLed(redPin, greenPin, bluePin);
+//RGBLed myRGBLed = RGBLed(redPin, greenPin, bluePin);
 
 int main() {
     
-    pb1.mode(PullUp);
-    pb2.mode(PullUp);
-    redSelect.mode(PullUp);
-    greenSelect.mode(PullUp);
-    blueSelect.mode(PullUp);
-    wait(0.1);
-    
-    pb1.attach_asserted(&pb1_hit_callback);
-    pb2.attach_asserted(&pb2_hit_callback);
-    pb1.setSampleFrequency();
-    pb2.setSampleFrequency();
-    
-    float redVal = 0.0f;
-    float greenVal = 0.0f;
-    float blueVal = 0.0f;
+//    pb1.mode(PullUp);
+//    pb2.mode(PullUp);
+//    redSelect.mode(PullUp);
+//    greenSelect.mode(PullUp);
+//    blueSelect.mode(PullUp);
+//    wait(0.1);
+//    
+//    pb1.attach_asserted(&pb1_hit_callback);
+//    pb2.attach_asserted(&pb2_hit_callback);
+//    pb1.setSampleFrequency();
+//    pb2.setSampleFrequency();
+//    
+//    float redVal = 0.0f;
+//    float greenVal = 0.0f;
+//    float blueVal = 0.0f;
     
     while(1) {
         // Part 1
@@ -63,26 +68,43 @@
 //        wait(0.5);
         
         // Part 3
+//        if (!redSelect) {
+//            redVal = 1.0f * p;
+//        } else {
+//            redVal = 0.0f;
+//        }
+//        if (!greenSelect) {
+//            greenVal = 1.0f * p;
+//        } else {
+//            greenVal = 0.0f;
+//        }
+//        if (!blueSelect) {
+//            blueVal = 1.0f * p;
+//        } else {
+//            blueVal = 0.0f;
+//        }
+//        myRGBLed.write(redVal, greenVal, blueVal);
+//        wait(0.5);
         
-        if (!redSelect) {
-            redVal = 1.0 * p;
-        } else {
-            redVal = 0.0f;
-        }
-        if (!greenSelect) {
-            greenVal = 1.0 * p;
-        } else {
-            greenVal = 0.0f;
-        }
-        if (!blueSelect) {
-            blueVal = 1.0 * p;
-        } else {
-            blueVal = 0.0f;
-        }
-        myRGBLed.write(redVal, greenVal, blueVal);
-        wait(0.5);
+        // Part 4
+//        run_part4();
+        
+        // Part 5 in separate project
+        
+        // Part 6 in separate project
         
-        run();
+        // Part 7
+        run_part7();
+
+        // Part 8
+//        run_part8();
 
+        // Part 9
+//        run_part9();
+
+        // Part 10 in separate project
+        
+        // Watchdog Extra Credit
+        
     }
 }