assignment 6 360- part 1 is complete-freeze balls on lcd screen with a hardware interrupt/button
Dependencies: 4DGL-uLCD-SE MMA8452Q_withfreefall bouncing_ball mbed
Fork of Assignment6 by
Revision 5:62b2d643b132, committed 2017-12-07
- Comitter:
- jakebonney10
- Date:
- Thu Dec 07 14:51:51 2017 +0000
- Parent:
- 4:8118b752dea6
- Commit message:
- Freezes balls on lcd screen with a button (p17)
Changed in this revision
MMA8452Q.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 8118b752dea6 -r 62b2d643b132 MMA8452Q.lib --- a/MMA8452Q.lib Tue Nov 07 13:24:50 2017 +0000 +++ b/MMA8452Q.lib Thu Dec 07 14:51:51 2017 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/slicht/code/MMA8452Q/#b3305e3c9e73 +https://os.mbed.com/users/jakebonney10/code/MMA8452Q_withfreefall/#2b812ae875eb
diff -r 8118b752dea6 -r 62b2d643b132 main.cpp --- a/main.cpp Tue Nov 07 13:24:50 2017 +0000 +++ b/main.cpp Thu Dec 07 14:51:51 2017 +0000 @@ -1,8 +1,3 @@ -// A solution to OCE360 Homework #4. -// Objective: Use object oriented programming to create a system that displays -// multiple balls bouncing around the LCD screen. -// Stephen Licht, 11/7/2017 - #include "mbed.h" #include "MMA8452Q.h" //acceleromater library #include "uLCD_4DGL.h" //LCD library @@ -30,8 +25,27 @@ physics_ball ball1; //initialize two balls for bouncing physics_ball ball2; //the default states from the library will be used initially +// External Interrupts +InterruptIn button(p18); +InterruptIn freefall_acc(p17); +Timer debounce; + + +// Response to the hardware interrupt(button being pressed), set speed of balls = 0 +void Freeze_button(){ + ball1.set_state(ball1.posx, ball1.posy,0,0); + ball2.set_state(ball2.posx, ball2.posy,0,0); + wait(2); + debounce.reset(); + } +//void Freeze_ff(){ + //if + int main() { + button.mode(PullUp); // use internal resistors in button in order to keep output reading "high", then when button switched it will fall + button.fall(&Freeze_button); //freeze accelerometer for 2 sec when button is pressed + // Initialize uLCD uLCD.baudrate(115200); uLCD.background_color(BLACK);