Core51822 module helloworld. BLE disable version.
Dependencies: microbit_ble_disable
Fork of microbit-samples by
Core51822モジュールでmicro:bitのDAL(Device Abstraction Layer)を使います。
注意
BLE(Bluetooth Low Energy)は無効にしています。
source/Greyscale.cpp@8:781a3570993b, 2016-05-08 (annotated)
- Committer:
- va009039
- Date:
- Sun May 08 09:57:04 2016 +0000
- Revision:
- 8:781a3570993b
- Parent:
- 2:5b2cd31ac474
use BLE disabled microbit library.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
LancasterUniversity | 2:5b2cd31ac474 | 1 | /* |
LancasterUniversity | 2:5b2cd31ac474 | 2 | The MIT License (MIT) |
LancasterUniversity | 2:5b2cd31ac474 | 3 | |
LancasterUniversity | 2:5b2cd31ac474 | 4 | Copyright (c) 2016 British Broadcasting Corporation. |
LancasterUniversity | 2:5b2cd31ac474 | 5 | This software is provided by Lancaster University by arrangement with the BBC. |
LancasterUniversity | 2:5b2cd31ac474 | 6 | |
LancasterUniversity | 2:5b2cd31ac474 | 7 | Permission is hereby granted, free of charge, to any person obtaining a |
LancasterUniversity | 2:5b2cd31ac474 | 8 | copy of this software and associated documentation files (the "Software"), |
LancasterUniversity | 2:5b2cd31ac474 | 9 | to deal in the Software without restriction, including without limitation |
LancasterUniversity | 2:5b2cd31ac474 | 10 | the rights to use, copy, modify, merge, publish, distribute, sublicense, |
LancasterUniversity | 2:5b2cd31ac474 | 11 | and/or sell copies of the Software, and to permit persons to whom the |
LancasterUniversity | 2:5b2cd31ac474 | 12 | Software is furnished to do so, subject to the following conditions: |
LancasterUniversity | 2:5b2cd31ac474 | 13 | |
LancasterUniversity | 2:5b2cd31ac474 | 14 | The above copyright notice and this permission notice shall be included in |
LancasterUniversity | 2:5b2cd31ac474 | 15 | all copies or substantial portions of the Software. |
LancasterUniversity | 2:5b2cd31ac474 | 16 | |
LancasterUniversity | 2:5b2cd31ac474 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
LancasterUniversity | 2:5b2cd31ac474 | 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
LancasterUniversity | 2:5b2cd31ac474 | 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
LancasterUniversity | 2:5b2cd31ac474 | 20 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
LancasterUniversity | 2:5b2cd31ac474 | 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
LancasterUniversity | 2:5b2cd31ac474 | 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
LancasterUniversity | 2:5b2cd31ac474 | 23 | DEALINGS IN THE SOFTWARE. |
LancasterUniversity | 2:5b2cd31ac474 | 24 | */ |
LancasterUniversity | 2:5b2cd31ac474 | 25 | |
LancasterUniversity | 2:5b2cd31ac474 | 26 | #include "MicroBit.h" |
LancasterUniversity | 2:5b2cd31ac474 | 27 | #include "MicroBitSamples.h" |
LancasterUniversity | 2:5b2cd31ac474 | 28 | |
LancasterUniversity | 2:5b2cd31ac474 | 29 | #ifdef MICROBIT_SAMPLE_GREYSCALE |
LancasterUniversity | 2:5b2cd31ac474 | 30 | |
LancasterUniversity | 2:5b2cd31ac474 | 31 | MicroBit uBit; |
LancasterUniversity | 2:5b2cd31ac474 | 32 | |
LancasterUniversity | 2:5b2cd31ac474 | 33 | int main() |
LancasterUniversity | 2:5b2cd31ac474 | 34 | { |
LancasterUniversity | 2:5b2cd31ac474 | 35 | // Initialise the micro:bit runtime. |
LancasterUniversity | 2:5b2cd31ac474 | 36 | uBit.init(); |
LancasterUniversity | 2:5b2cd31ac474 | 37 | |
LancasterUniversity | 2:5b2cd31ac474 | 38 | // Enable per pixel rendering, with 256 level of brightness per pixel. |
LancasterUniversity | 2:5b2cd31ac474 | 39 | uBit.display.setDisplayMode(DISPLAY_MODE_GREYSCALE); |
LancasterUniversity | 2:5b2cd31ac474 | 40 | |
LancasterUniversity | 2:5b2cd31ac474 | 41 | // Draw a rainbow brightness effect across the display |
LancasterUniversity | 2:5b2cd31ac474 | 42 | int value = 1; |
LancasterUniversity | 2:5b2cd31ac474 | 43 | |
LancasterUniversity | 2:5b2cd31ac474 | 44 | for(int j = 0; j < 5; j++) |
LancasterUniversity | 2:5b2cd31ac474 | 45 | { |
LancasterUniversity | 2:5b2cd31ac474 | 46 | for(int i = 0; i < 5; i++) |
LancasterUniversity | 2:5b2cd31ac474 | 47 | { |
LancasterUniversity | 2:5b2cd31ac474 | 48 | uBit.display.image.setPixelValue(i,j,value); |
LancasterUniversity | 2:5b2cd31ac474 | 49 | value += 10; |
LancasterUniversity | 2:5b2cd31ac474 | 50 | } |
LancasterUniversity | 2:5b2cd31ac474 | 51 | } |
LancasterUniversity | 2:5b2cd31ac474 | 52 | |
LancasterUniversity | 2:5b2cd31ac474 | 53 | // Nothing else to do, so enter a power efficient sleep. |
LancasterUniversity | 2:5b2cd31ac474 | 54 | while(1) |
LancasterUniversity | 2:5b2cd31ac474 | 55 | uBit.sleep(10000); |
LancasterUniversity | 2:5b2cd31ac474 | 56 | } |
LancasterUniversity | 2:5b2cd31ac474 | 57 | |
LancasterUniversity | 2:5b2cd31ac474 | 58 | #endif |