Initial release
Diff: main.cpp
- Revision:
- 4:4fe5674bf409
- Parent:
- 3:b6e9850d3e76
- Child:
- 5:80cb8f9db01e
--- a/main.cpp Sat Sep 22 00:31:39 2018 +0000 +++ b/main.cpp Sun Nov 25 04:41:15 2018 +0000 @@ -1,7 +1,7 @@ //================================= // microbit_switch_if_3sw //================================= -// BLE switch interface with 3 tact switches for micro:bit +// BLE switch interface with 3 tact switches or 3 touch sensors for micro:bit // It is intended for use with ios devices. // // The MIT License (MIT) Copyright (c) 2018 Masatomo Kojima @@ -15,25 +15,12 @@ // E Error at sending data by ble // e Error at writting data to flash memory // I Error by Incorrect cording -// -// Please refer to the following site. (Japanese only) -// http://mahoro-ba.net/e2036.html -// http://mahoro-ba.net/e2038.html -// -// I refer to information written on the following sites. -// (1)https://os.mbed.com/teams/microbit/code/microbit_presenter/ -// Licensed under the Apache License, Version 2.0 -// -// (2)https://lancaster-university.github.io/microbit-docs/ -// The MIT License (MIT) -// Copyright (c) 2016 British Broadcasting Corporation. -// //--------------------------------- -#define VERSION "3SW-180922" +#define VERSION "3SW-181125" //#define NO_DEBUG -#include "microbit_switch_if.h" +#include "microbit_switch_if_3sw.h" #include "KeyValueInt.h" //--------------------------------- @@ -298,9 +285,13 @@ MicroBitMessageBus bus; MicroBitButton buttonA(MICROBIT_PIN_BUTTON_A, MICROBIT_ID_BUTTON_A); MicroBitButton buttonB(MICROBIT_PIN_BUTTON_B, MICROBIT_ID_BUTTON_B); -MicroBitButton button0(MICROBIT_PIN_P0, MICROBIT_ID_IO_P0, MICROBIT_BUTTON_ALL_EVENTS, PullUp); -MicroBitButton button1(MICROBIT_PIN_P1, MICROBIT_ID_IO_P1, MICROBIT_BUTTON_ALL_EVENTS, PullUp); -MicroBitButton button2(MICROBIT_PIN_P2, MICROBIT_ID_IO_P2, MICROBIT_BUTTON_ALL_EVENTS, PullUp); +MicroBitPin P0(MICROBIT_ID_IO_P0, MICROBIT_PIN_P0, PIN_CAPABILITY_ALL); +MicroBitPin P1(MICROBIT_ID_IO_P1, MICROBIT_PIN_P1, PIN_CAPABILITY_ALL); +MicroBitPin P2(MICROBIT_ID_IO_P2, MICROBIT_PIN_P2, PIN_CAPABILITY_ALL); + +//MicroBitButton button0(MICROBIT_PIN_P0, MICROBIT_ID_IO_P0, MICROBIT_BUTTON_ALL_EVENTS, PullUp); +//MicroBitButton button1(MICROBIT_PIN_P1, MICROBIT_ID_IO_P1, MICROBIT_BUTTON_ALL_EVENTS, PullUp); +//MicroBitButton button2(MICROBIT_PIN_P2, MICROBIT_ID_IO_P2, MICROBIT_BUTTON_ALL_EVENTS, PullUp); /** ---------- * @brief キーコードを送信する @@ -343,7 +334,7 @@ */ static void onButtonDown(MicroBitEvent e) { -// DEBUG(" Button Down %d state=%d\r\n", e.source, state); +// DEBUG(" Button Down %d state=%d\r\n", e.source, state); switch (state) { case STATE_SETTING : @@ -435,6 +426,11 @@ bus.listen(MICROBIT_ID_ANY, MICROBIT_BUTTON_EVT_UP, onButtonUp); bus.listen(MICROBIT_ID_ANY, MICROBIT_BUTTON_EVT_HOLD, onButtonHold); + // Put the P0, P1 and P2 pins into touch sense mode. + P0.isTouched(); + P1.isTouched(); + P2.isTouched(); + //----- Setting if (paraSetting(state == STATE_SETTING)) dispChar =0; else dispChar ='e';