back up of work during May 2019

Dependencies:   microbit

Committer:
tht216
Date:
Wed Jun 05 15:21:14 2019 +0000
Branch:
class_implmentation
Revision:
6:f372773ad32f
Parent:
4:984eac8e4ccb
TODO:; 1. multi keypresses; 2. integration

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tht216 6:f372773ad32f 1 #include "bitboard.h"
tht216 6:f372773ad32f 2
tht216 2:333ac2ff5045 3 InterruptIn button1(BUTTON_A);
tht216 2:333ac2ff5045 4 InterruptIn button2(BUTTON_B);
tht216 6:f372773ad32f 5
tht216 6:f372773ad32f 6
tht216 6:f372773ad32f 7 //MicroBit uBit;
tht216 6:f372773ad32f 8 //MicroBit* uBitPtr = &uBit;
tht216 4:984eac8e4ccb 9 BLE ble;
tht216 6:f372773ad32f 10 //BLE* blePtr = &ble;
tht216 6:f372773ad32f 11 KeyboardService* kbdServicePtr;
tht216 6:f372773ad32f 12
tht216 6:f372773ad32f 13 //void onButtonA(MicroBitEvent e)
tht216 6:f372773ad32f 14 //{
tht216 6:f372773ad32f 15 // uBit.display.print("A");
tht216 6:f372773ad32f 16 // uBit.serial.send("Button A pressed");
tht216 6:f372773ad32f 17 // uBit.serial.send(e.value);
tht216 6:f372773ad32f 18 //}
tht216 6:f372773ad32f 19 const char* DEVICE_NAME = "THOMAS MICROBIT";
tht216 6:f372773ad32f 20 const char* SHORT_DEVICE_NAME = "UBIT";
tht216 6:f372773ad32f 21
tht216 6:f372773ad32f 22 int main()
tht216 4:984eac8e4ccb 23 {
tht216 6:f372773ad32f 24
tht216 6:f372773ad32f 25 bitboard btboard(/**uBit,**/ ble,kbdServicePtr, DEVICE_NAME, SHORT_DEVICE_NAME);
tht216 6:f372773ad32f 26
tht216 6:f372773ad32f 27 bitboard* btboardPtr;
tht216 6:f372773ad32f 28 btboardPtr = &btboard;
tht216 6:f372773ad32f 29 btboard.init();
tht216 6:f372773ad32f 30
tht216 6:f372773ad32f 31 button1.rise(btboardPtr, &bitboard::send_keypress);
tht216 6:f372773ad32f 32 // button2.rise(btboardPtr, &bitboard::switchkey);
tht216 6:f372773ad32f 33 //btboard.uBit.messageBus.listen(MICROBIT_ID_BUTTON_A, MICROBIT_BUTTON_EVT_CLICK, btboard->onButtonA());
tht216 6:f372773ad32f 34 // btboard.uBit.messageBus.listen(MICROBIT_ID_IO_P0, MICROBIT_EVT_ANY, onButtonA);
tht216 6:f372773ad32f 35 // We don't want to drop out of main!
tht216 6:f372773ad32f 36 while(1){
tht216 6:f372773ad32f 37 ble.waitForEvent();
tht216 6:f372773ad32f 38 wait(1);
tht216 6:f372773ad32f 39 // btboard.send();
tht216 6:f372773ad32f 40 // btboard.uBit.sleep(500);
tht216 6:f372773ad32f 41 // btboard.uBit.serial.send("waiting for ble event...\r\n");
tht216 4:984eac8e4ccb 42 }
tht216 4:984eac8e4ccb 43 }