Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
Revision 12:5141f85e0be6, committed 2020-11-24
- Comitter:
- kblake9
- Date:
- Tue Nov 24 22:36:04 2020 +0000
- Parent:
- 11:20e5a1b9b1af
- Child:
- 13:bd2e05cebd5d
- Commit message:
- fixed hardware
Changed in this revision
| hardware.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- 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;
}