4180 lab 1

Dependencies:   mbed MCP23S17 PinDetect USBDevice

main.cpp

Committer:
emilywilson
Date:
2020-01-22
Revision:
12:cc5bda248946
Parent:
11:2cfdab516b21

File content as of revision 12:cc5bda248946:

#include "mbed.h"
#include "RGBLed.h"
#include "PinDetect.h"
//#include "part4.h"
//#include "part6.h"
//#include "part7.h"
//#include "part8.h"
//#include "part9.h"
//#include "watchdog_ec.h"
//#include "powermanagement_ec.h"
#include "mouse_ec.h"

//DigitalOut myled(p26);
//PwmOut builtinLED(LED1);
//DigitalIn pb(p22);
//DigitalIn pb2(p21);

// p20 is most significant bit
//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.1f;
    }
}

void pb2_hit_callback() {
    if (p < 1) {
        p += 0.1f;
    }
}

//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;
    
    while(1) {
        // Part 1
//        myled = !pb;
        
        // Part 2
//        builtinLED = p;
//        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);
        
        // Part 4
//        run_part4();
        
        // Part 5 in separate project
        
        // Part 6 in separate project
        
        // Part 7
//        run_part7();

        // Part 8
//        run_part8();

        // Part 9
//        run_part9();

        // Part 10 in separate project
        
        // Watchdog Extra Credit
//        run_watchdogEC();

        // Power Management Extra Credit
//        run_powermanagementEC();
        
        // USB Mouse Extra Credit
        run_mouseEC();
        
    }
}