First step in making the code to be more independent on each board. This version is just for TinyBLE, the next will be a bit more generic
Dependencies: BLE_API mbed nRF51822
Fork of EddystoneBeaconSwitchLed by
Diff: main.cpp
- Revision:
- 3:2340e6920afe
- Parent:
- 2:fc105f4c854e
diff -r fc105f4c854e -r 2340e6920afe main.cpp --- a/main.cpp Sat Sep 26 00:08:25 2015 +0000 +++ b/main.cpp Tue Sep 29 00:22:55 2015 +0000 @@ -2,49 +2,42 @@ #include "BLEDevice.h" #include "DeviceInformationService.h" +int ledOn = 0; +int ledOff = 1; InterruptIn button1(P0_17); InterruptIn mysw1(P0_18); -DigitalOut myled1(P0_12); -DigitalOut myled2(P0_15); -DigitalOut myled3(P0_16); +DigitalOut myled1(P0_21); +DigitalOut myled2(P0_22); +DigitalOut myled3(P0_23); // Serial pc(USBTX,USBRX); -int count = 0; int flag = false; -// Callback for button1 -void handle_sensor() { - count++; - myled2 = !myled2; -} - -void handle_sw1() { +void handle_button1() { flag = !flag; } void ledflasher() { - myled1 = 1; + myled1 = ledOn; wait(0.3); - myled1 = 0; - myled2 = 1; + myled1 = ledOff; + myled2 = ledOn; wait(0.3); - myled2 = 0; - myled3 = 1; + myled2 = ledOff; + myled3 = ledOn; wait(0.4); - myled3 = 0; + myled3 = ledOff; } int main() { // Initialize button1 and pull up // set interrupt callback for button1 - button1.fall(&handle_sensor); - mysw1.fall(&handle_sw1); + button1.fall(&handle_button1); button1.mode(PullUp); - mysw1.mode(PullUp); - myled1 = 0; - myled2 = 0; - myled3 = 0; + myled1 = ledOff; + myled2 = ledOff; + myled3 = ledOff; while(1) { if (flag) {