BLE mouse with uBit ( still some issues to resolve )
Dependencies: BLE_API microbit_ble_mouse mbed nRF51822
Fork of microbit_mouse_BLE by
Diff: main.cpp
- Revision:
- 4:b58633511f96
- Parent:
- 3:7036de769c32
- Child:
- 5:c1e87a1869cd
--- a/main.cpp Sun May 27 13:57:09 2018 +0000 +++ b/main.cpp Sun May 27 14:27:20 2018 +0000 @@ -19,6 +19,7 @@ //#include "KeyboardService.h" #include "MouseService.h" #include "examples_common.h" +#include "MMA8652.h" // accelerometer /** * This program implements a complete HID-over-Gatt Profile: @@ -33,11 +34,16 @@ */ //The micro:bit has a matrixed display, this is a simple way to use some LEDs on it +// turn off LED saves 1mA current + //DigitalOut col9(P0_12, 0); - //DigitalOut waiting_led(P0_13); //DigitalOut connected_led(P0_15); +MMA8652 accelerometer( P0_19, P0_20); // i2c pin assign +float accelerometer_data[3]; +float x,y,z; + InterruptIn button1(BUTTON_A); InterruptIn button2(BUTTON_B); @@ -125,6 +131,13 @@ while (true) { ble.waitForEvent(); + + /// make the following a separate periodic ticker + accelerometer.ReadXYZ(accelerometer_data); + x = accelerometer_data[0]; + y = accelerometer_data[1]; + z = accelerometer_data[2]; + } }