qwertzu
main.cpp@0:8b09aa9a3968, 2018-03-02 (annotated)
- Committer:
- uBitAxel
- Date:
- Fri Mar 02 16:52:08 2018 +0000
- Revision:
- 0:8b09aa9a3968
qwertz
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
uBitAxel | 0:8b09aa9a3968 | 1 | /* |
uBitAxel | 0:8b09aa9a3968 | 2 | The MIT License (MIT) |
uBitAxel | 0:8b09aa9a3968 | 3 | |
uBitAxel | 0:8b09aa9a3968 | 4 | Copyright (c) 2016 British Broadcasting Corporation. |
uBitAxel | 0:8b09aa9a3968 | 5 | This software is provided by Lancaster University by arrangement with the BBC. |
uBitAxel | 0:8b09aa9a3968 | 6 | |
uBitAxel | 0:8b09aa9a3968 | 7 | Permission is hereby granted, free of charge, to any person obtaining a |
uBitAxel | 0:8b09aa9a3968 | 8 | copy of this software and associated documentation files (the "Software"), |
uBitAxel | 0:8b09aa9a3968 | 9 | to deal in the Software without restriction, including without limitation |
uBitAxel | 0:8b09aa9a3968 | 10 | the rights to use, copy, modify, merge, publish, distribute, sublicense, |
uBitAxel | 0:8b09aa9a3968 | 11 | and/or sell copies of the Software, and to permit persons to whom the |
uBitAxel | 0:8b09aa9a3968 | 12 | Software is furnished to do so, subject to the following conditions: |
uBitAxel | 0:8b09aa9a3968 | 13 | |
uBitAxel | 0:8b09aa9a3968 | 14 | The above copyright notice and this permission notice shall be included in |
uBitAxel | 0:8b09aa9a3968 | 15 | all copies or substantial portions of the Software. |
uBitAxel | 0:8b09aa9a3968 | 16 | |
uBitAxel | 0:8b09aa9a3968 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
uBitAxel | 0:8b09aa9a3968 | 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
uBitAxel | 0:8b09aa9a3968 | 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
uBitAxel | 0:8b09aa9a3968 | 20 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
uBitAxel | 0:8b09aa9a3968 | 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
uBitAxel | 0:8b09aa9a3968 | 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
uBitAxel | 0:8b09aa9a3968 | 23 | DEALINGS IN THE SOFTWARE. |
uBitAxel | 0:8b09aa9a3968 | 24 | */ |
uBitAxel | 0:8b09aa9a3968 | 25 | |
uBitAxel | 0:8b09aa9a3968 | 26 | #include "MicroBit.h" |
uBitAxel | 0:8b09aa9a3968 | 27 | |
uBitAxel | 0:8b09aa9a3968 | 28 | MicroBit uBit; |
uBitAxel | 0:8b09aa9a3968 | 29 | |
uBitAxel | 0:8b09aa9a3968 | 30 | |
uBitAxel | 0:8b09aa9a3968 | 31 | void onPulseEdge(MicroBitEvent evt) |
uBitAxel | 0:8b09aa9a3968 | 32 | { |
uBitAxel | 0:8b09aa9a3968 | 33 | |
uBitAxel | 0:8b09aa9a3968 | 34 | } |
uBitAxel | 0:8b09aa9a3968 | 35 | |
uBitAxel | 0:8b09aa9a3968 | 36 | int main() |
uBitAxel | 0:8b09aa9a3968 | 37 | { |
uBitAxel | 0:8b09aa9a3968 | 38 | // Initialise the micro:bit runtime. |
uBitAxel | 0:8b09aa9a3968 | 39 | uBit.init(); |
uBitAxel | 0:8b09aa9a3968 | 40 | |
uBitAxel | 0:8b09aa9a3968 | 41 | // Insert your code here! |
uBitAxel | 0:8b09aa9a3968 | 42 | uBit.display.scroll("HELLO WORLD! :)"); |
uBitAxel | 0:8b09aa9a3968 | 43 | |
uBitAxel | 0:8b09aa9a3968 | 44 | // Application code will go here and in functions outside of main() |
uBitAxel | 0:8b09aa9a3968 | 45 | uBit.messageBus.listen(MICROBIT_ID_BUTTON_A, MICROBIT_BUTTON_EVT_CLICK, onButton); |
uBitAxel | 0:8b09aa9a3968 | 46 | uBit.messageBus.listen(MICROBIT_ID_BUTTON_B, MICROBIT_BUTTON_EVT_CLICK, onButton); |
uBitAxel | 0:8b09aa9a3968 | 47 | uBit.messageBus.listen(MICROBIT_ID_BUTTON_AB, MICROBIT_BUTTON_EVT_CLICK, onButton); |
uBitAxel | 0:8b09aa9a3968 | 48 | uBit.messageBus.listen(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_CONNECTED, onConnected); |
uBitAxel | 0:8b09aa9a3968 | 49 | uBit.messageBus.listen(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_DISCONNECTED, onDisconnected); |
uBitAxel | 0:8b09aa9a3968 | 50 | |
uBitAxel | 0:8b09aa9a3968 | 51 | // If main exits, there may still be other fibers running or registered event handlers etc. |
uBitAxel | 0:8b09aa9a3968 | 52 | // Simply release this fiber, which will mean we enter the scheduler. Worse case, we then |
uBitAxel | 0:8b09aa9a3968 | 53 | // sit in the idle task forever, in a power efficient sleep. |
uBitAxel | 0:8b09aa9a3968 | 54 | release_fiber(); |
uBitAxel | 0:8b09aa9a3968 | 55 | } |
uBitAxel | 0:8b09aa9a3968 | 56 |