Jeffery Hurley
/
Asteroids
Simple starter skeleton for asteroids video game.
main.cpp
- Committer:
- jhurley31
- Date:
- 2019-02-23
- Revision:
- 1:a6872783beca
- Parent:
- 0:0c450cb95a1e
- Child:
- 2:30020ddfccf6
File content as of revision 1:a6872783beca:
#include "mbed.h" #include "Speaker.h" #include "PinDetect.h" #include "BuzzyGraphics.h" #include "uLCD_4DGL.h" //////////////////////////////////////// // Setup instance of LCD display uLCD_4DGL uLCD(p28, p27, p29); // serial tx, serial rx, reset pin; //////////////////////////////////////// // Setup instances of push button pins PinDetect pb_left(p16); PinDetect pb_right(p17); PinDetect pb_up(p18); PinDetect pb_down(p19); Speaker SpeakerOut(p21); ////////////////////////////////////////////////////////////////////// // Interrupt routine // used to output next analog sample whenever a timer interrupt occurs void Sample_timer_interrupt(void) { // send next analog sample out to D to A SpeakerOut.PlayNextValue(); } //--------------------------------------------------------------------------------------------------- // Callback routine is interrupt activated by a debounced pb_left hit void pb_left_hit_callback (void) { // Tell Buzzy to go left //************* // Fill in needed Code here //************* } //--------------------------------------------------------------------------------------------------- // Callback routine is interrupt activated by a debounced pb_right hit void pb_right_hit_callback (void) { // Tell Buzzy to go right //************* // Fill in needed Code here //************* } //--------------------------------------------------------------------------------------------------- // Callback routine is interrupt activated by a debounced pb_up hit void pb_up_hit_callback (void) { // Tell Buzzy to go up //************* // Fill in needed Code here //************* } //--------------------------------------------------------------------------------------------------- // Callback routine is interrupt activated by a debounced pb_down hit void pb_down_hit_callback (void) { // Tell Buzzy to go down //************* // Fill in needed Code here //************* } //--------------------------------------------------------------------------------------------------- int main() { //setup push buttons pb_left.mode(PullUp); pb_right.mode(PullUp); pb_up.mode(PullUp); pb_down.mode(PullUp); // Delay for initial pullup to take effect wait(.01); // Setup Interrupt callback functions for a pb hit pb_left.attach_deasserted(&pb_left_hit_callback); pb_right.attach_deasserted(&pb_right_hit_callback); pb_up.attach_deasserted(&pb_up_hit_callback); pb_down.attach_deasserted(&pb_down_hit_callback); // Setup speaker SpeakerOut.period(1.0/200000.0); //Setup LCD display uLCD.display_control(PORTRAIT); uLCD.background_color(BLACK); uLCD.cls(); uLCD.baudrate(BAUD_3000000); //jack up baud rate to max for fast display wait(1.0); // DrawMaze(); // Start sampling pb inputs using interrupts pb_left.setSampleFrequency(); pb_right.setSampleFrequency(); pb_up.setSampleFrequency(); pb_down.setSampleFrequency(); // pushbuttons now setup and running while(1) { } } //end main