project for 2035
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
Diff: hardware.cpp
- Revision:
- 12:5141f85e0be6
- Parent:
- 9:c9d6eda597b0
- Child:
- 13:bd2e05cebd5d
--- a/hardware.cpp Tue Nov 24 22:28:28 2020 +0000 +++ b/hardware.cpp Tue Nov 24 22:36:04 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.activate(); + return ERROR_NONE; } @@ -49,5 +54,11 @@ GameInputs read_inputs() { GameInputs in; + in->ax = acc.readXRaw(); + in->ay = acc.readYRaw(); + in->az = acc.readZRaw(); + in->b1 = button1.read(); + in->b2 = button2.read(); + in->b3 = button3.read(); return in; }