back up of work during May 2019
Dependencies: microbit
Diff: main.cpp
- Revision:
- 2:333ac2ff5045
- Child:
- 4:984eac8e4ccb
diff -r c840c2b6f490 -r 333ac2ff5045 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Jun 01 17:01:10 2019 +0000 @@ -0,0 +1,55 @@ +#include "bit_board.h" + +InterruptIn button1(BUTTON_A); +InterruptIn button2(BUTTON_B); + + + +int main(){ +//create_fiber(JoystickControl); +// create_fiber(BLE_fiber); + Ticker heartbeat; + + button1.rise(send_one); + button2.rise(send_zero); + + HID_DEBUG("initialising ticker\r\n"); + + heartbeat.attach(waiting, 1); + + HID_DEBUG("initialising ble\r\n"); + ble.init(); + + ble.gap().onDisconnection(onDisconnect); + ble.gap().onConnection(onConnect); + + initializeSecurity(ble); + + HID_DEBUG("adding hid service\r\n"); + KeyboardService kbdService(ble); + kbdServicePtr = &kbdService; + + HID_DEBUG("adding device info and battery service\r\n"); + initializeHOGP(ble); + + HID_DEBUG("setting up gap\r\n"); + ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::KEYBOARD); + ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, + (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME)); + ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::SHORTENED_LOCAL_NAME, + (uint8_t *)SHORT_DEVICE_NAME, sizeof(SHORT_DEVICE_NAME)); + ble.gap().setDeviceName((const uint8_t *)DEVICE_NAME); + + HID_DEBUG("advertising\r\n"); + ble.gap().startAdvertising(); + + float x,y; + + while (true) { + ble.waitForEvent(); + + JoystickControl(); + touch_control(); + } + // release_fiber(); + } \ No newline at end of file