![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
project for 2035
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
Diff: hardware.cpp
- Revision:
- 8:2e18a96e0c77
- Parent:
- 7:1912b4a2e4fe
- Child:
- 9:c9d6eda597b0
--- a/hardware.cpp Tue Nov 24 11:21:33 2020 +0000 +++ b/hardware.cpp Tue Nov 24 12:35:16 2020 +0000 @@ -18,7 +18,7 @@ uLCD_4DGL uLCD(p9,p10,p11); // LCD Screen (tx, rx, reset) //SDFileSystem sd(p5, p6, p7, p8, "sd"); // SD Card(mosi, miso, sck, cs) Serial pc(USBTX,USBRX); // USB Console (tx, rx) -MMA8452 acc(p28, p27, 100000); // Accelerometer (sda, sdc, rate) +MMA8452 acc(p28, p27, 100000); // Accelerometer (sda, sdc, rate) DigitalIn button1(p21); // Pushbuttons (pin) DigitalIn button2(p22); DigitalIn button3(p23); @@ -31,8 +31,10 @@ // properly. Do that here. int hardware_init() { - // Crank up the speed + // Crank up the speed and init LCD uLCD.baudrate(3000000); + uLCD.background_color(BLACK); + uLCD.cls(); pc.baud(115200); //Initialize pushbuttons @@ -40,6 +42,9 @@ button2.mode(PullUp); button3.mode(PullUp); + //Initialize accelerometer + acc.init(); + return ERROR_NONE; } @@ -49,5 +54,11 @@ GameInputs read_inputs() { GameInputs in; + in->ax = acc.readX(); + in->ay = acc.readY(); + in->az = acc.readZ(); + in->b1 = button1.read(); + in->b2 = button2.read(); + in->b3 = button3.read(); return in; }