project for 2035

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Committer:
kblake9
Date:
Tue Nov 24 12:35:16 2020 +0000
Revision:
8:2e18a96e0c77
Parent:
7:1912b4a2e4fe
Child:
9:c9d6eda597b0
fixed for now

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DCchico 2:4947d6a82971 1 // Copyright 2020 Georgia Tech. All rights reserved.
DCchico 2:4947d6a82971 2 // The materials provided by the instructor in this course are for
DCchico 2:4947d6a82971 3 // the use of the students currently enrolled in the course.
DCchico 2:4947d6a82971 4 // Copyrighted course materials may not be further disseminated.
DCchico 2:4947d6a82971 5 // This file must not be made publicly available anywhere.
DCchico 2:4947d6a82971 6
DCchico 1:10330bce85cb 7 // This header has all the (extern) declarations of the globals.
DCchico 1:10330bce85cb 8 // "extern" means "this is instantiated somewhere, but here's what the name
DCchico 1:10330bce85cb 9 // means.
DCchico 1:10330bce85cb 10 #include "globals.h"
DCchico 1:10330bce85cb 11
DCchico 1:10330bce85cb 12 #include "hardware.h"
DCchico 1:10330bce85cb 13
DCchico 1:10330bce85cb 14 // We need to actually instantiate all of the globals (i.e. declare them once
DCchico 1:10330bce85cb 15 // without the extern keyword). That's what this file does!
DCchico 1:10330bce85cb 16
DCchico 1:10330bce85cb 17 // Hardware initialization: Instantiate all the things!
DCchico 1:10330bce85cb 18 uLCD_4DGL uLCD(p9,p10,p11); // LCD Screen (tx, rx, reset)
kblake9 5:cd2bdbfedd21 19 //SDFileSystem sd(p5, p6, p7, p8, "sd"); // SD Card(mosi, miso, sck, cs)
DCchico 1:10330bce85cb 20 Serial pc(USBTX,USBRX); // USB Console (tx, rx)
kblake9 8:2e18a96e0c77 21 MMA8452 acc(p28, p27, 100000); // Accelerometer (sda, sdc, rate)
DCchico 1:10330bce85cb 22 DigitalIn button1(p21); // Pushbuttons (pin)
DCchico 1:10330bce85cb 23 DigitalIn button2(p22);
DCchico 1:10330bce85cb 24 DigitalIn button3(p23);
DCchico 1:10330bce85cb 25 AnalogOut DACout(p18); // Speaker (pin)
DCchico 1:10330bce85cb 26 PwmOut speaker(p26);
DCchico 1:10330bce85cb 27 wave_player waver(&DACout);
DCchico 1:10330bce85cb 28
DCchico 1:10330bce85cb 29
DCchico 1:10330bce85cb 30 // Some hardware also needs to have functions called before it will set up
DCchico 1:10330bce85cb 31 // properly. Do that here.
DCchico 1:10330bce85cb 32 int hardware_init()
DCchico 1:10330bce85cb 33 {
kblake9 8:2e18a96e0c77 34 // Crank up the speed and init LCD
DCchico 1:10330bce85cb 35 uLCD.baudrate(3000000);
kblake9 8:2e18a96e0c77 36 uLCD.background_color(BLACK);
kblake9 8:2e18a96e0c77 37 uLCD.cls();
DCchico 1:10330bce85cb 38 pc.baud(115200);
DCchico 1:10330bce85cb 39
DCchico 1:10330bce85cb 40 //Initialize pushbuttons
DCchico 1:10330bce85cb 41 button1.mode(PullUp);
DCchico 1:10330bce85cb 42 button2.mode(PullUp);
DCchico 1:10330bce85cb 43 button3.mode(PullUp);
DCchico 1:10330bce85cb 44
kblake9 8:2e18a96e0c77 45 //Initialize accelerometer
kblake9 8:2e18a96e0c77 46 acc.init();
kblake9 8:2e18a96e0c77 47
DCchico 1:10330bce85cb 48 return ERROR_NONE;
DCchico 1:10330bce85cb 49 }
DCchico 1:10330bce85cb 50
DCchico 2:4947d6a82971 51 // Implement this function.
DCchico 2:4947d6a82971 52 // HINT: lookup your accelerometer under mbed site > Hardware> Components
DCchico 2:4947d6a82971 53 // and look at demo code
DCchico 1:10330bce85cb 54 GameInputs read_inputs()
DCchico 1:10330bce85cb 55 {
DCchico 1:10330bce85cb 56 GameInputs in;
kblake9 8:2e18a96e0c77 57 in->ax = acc.readX();
kblake9 8:2e18a96e0c77 58 in->ay = acc.readY();
kblake9 8:2e18a96e0c77 59 in->az = acc.readZ();
kblake9 8:2e18a96e0c77 60 in->b1 = button1.read();
kblake9 8:2e18a96e0c77 61 in->b2 = button2.read();
kblake9 8:2e18a96e0c77 62 in->b3 = button3.read();
DCchico 1:10330bce85cb 63 return in;
DCchico 1:10330bce85cb 64 }