An example of how to us the micro:bit DAL's abstraction. This is a one-way translation of the microbit-samples repository on GitHub. Please don't try to push changes here, instead push them to the source repo at https://github.com/lancaster-university/microbit-samples
Dependencies: microbit
main.cpp@0:247fd21c2246, 2016-07-13 (annotated)
- Committer:
- LancasterUniversity
- Date:
- Wed Jul 13 16:05:42 2016 +0100
- Revision:
- 0:247fd21c2246
Update to git: v2.0.0-rc4-5-g115d5a8
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
LancasterUniversity | 0:247fd21c2246 | 1 | /* |
LancasterUniversity | 0:247fd21c2246 | 2 | The MIT License (MIT) |
LancasterUniversity | 0:247fd21c2246 | 3 | |
LancasterUniversity | 0:247fd21c2246 | 4 | Copyright (c) 2016 British Broadcasting Corporation. |
LancasterUniversity | 0:247fd21c2246 | 5 | This software is provided by Lancaster University by arrangement with the BBC. |
LancasterUniversity | 0:247fd21c2246 | 6 | |
LancasterUniversity | 0:247fd21c2246 | 7 | Permission is hereby granted, free of charge, to any person obtaining a |
LancasterUniversity | 0:247fd21c2246 | 8 | copy of this software and associated documentation files (the "Software"), |
LancasterUniversity | 0:247fd21c2246 | 9 | to deal in the Software without restriction, including without limitation |
LancasterUniversity | 0:247fd21c2246 | 10 | the rights to use, copy, modify, merge, publish, distribute, sublicense, |
LancasterUniversity | 0:247fd21c2246 | 11 | and/or sell copies of the Software, and to permit persons to whom the |
LancasterUniversity | 0:247fd21c2246 | 12 | Software is furnished to do so, subject to the following conditions: |
LancasterUniversity | 0:247fd21c2246 | 13 | |
LancasterUniversity | 0:247fd21c2246 | 14 | The above copyright notice and this permission notice shall be included in |
LancasterUniversity | 0:247fd21c2246 | 15 | all copies or substantial portions of the Software. |
LancasterUniversity | 0:247fd21c2246 | 16 | |
LancasterUniversity | 0:247fd21c2246 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
LancasterUniversity | 0:247fd21c2246 | 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
LancasterUniversity | 0:247fd21c2246 | 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
LancasterUniversity | 0:247fd21c2246 | 20 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
LancasterUniversity | 0:247fd21c2246 | 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
LancasterUniversity | 0:247fd21c2246 | 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
LancasterUniversity | 0:247fd21c2246 | 23 | DEALINGS IN THE SOFTWARE. |
LancasterUniversity | 0:247fd21c2246 | 24 | */ |
LancasterUniversity | 0:247fd21c2246 | 25 | |
LancasterUniversity | 0:247fd21c2246 | 26 | #include "MicroBit.h" |
LancasterUniversity | 0:247fd21c2246 | 27 | |
LancasterUniversity | 0:247fd21c2246 | 28 | MicroBit uBit; |
LancasterUniversity | 0:247fd21c2246 | 29 | |
LancasterUniversity | 0:247fd21c2246 | 30 | int main() |
LancasterUniversity | 0:247fd21c2246 | 31 | { |
LancasterUniversity | 0:247fd21c2246 | 32 | // Initialise the micro:bit runtime. |
LancasterUniversity | 0:247fd21c2246 | 33 | uBit.init(); |
LancasterUniversity | 0:247fd21c2246 | 34 | |
LancasterUniversity | 0:247fd21c2246 | 35 | // Setup a simple triangular waveform. |
LancasterUniversity | 0:247fd21c2246 | 36 | MicroBitImage img("1 0 0 0 0 0 0 0 0 1\n0 1 0 0 0 0 0 0 1 0\n0 0 1 0 0 0 0 1 0 0\n0 0 0 1 0 0 1 0 0 0\n0 0 0 0 1 1 0 0 0 0\n"); |
LancasterUniversity | 0:247fd21c2246 | 37 | |
LancasterUniversity | 0:247fd21c2246 | 38 | while(1) |
LancasterUniversity | 0:247fd21c2246 | 39 | uBit.display.scroll(img, 80, -1); |
LancasterUniversity | 0:247fd21c2246 | 40 | } |
LancasterUniversity | 0:247fd21c2246 | 41 |