This repository will be used for Bluetooth World 2018.

Dependencies:   microbit

Fork of BluetoothAsia2018Peripheral by Kai Ren

Committer:
krenbluetoothsig
Date:
Mon Aug 06 08:26:38 2018 +0000
Revision:
14:fcab3952e945
Parent:
9:eb3730b39608
1. NEW: just update "microbit" and folked it.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bluetooth_mdw 0:b821de9e1c1f 1 /*
bluetooth_mdw 0:b821de9e1c1f 2 The MIT License (MIT)
bluetooth_mdw 0:b821de9e1c1f 3
bluetooth_mdw 0:b821de9e1c1f 4 Copyright (c) 2016 British Broadcasting Corporation.
bluetooth_mdw 0:b821de9e1c1f 5 This software is provided by Lancaster University by arrangement with the BBC.
bluetooth_mdw 0:b821de9e1c1f 6
bluetooth_mdw 0:b821de9e1c1f 7 Permission is hereby granted, free of charge, to any person obtaining a
bluetooth_mdw 0:b821de9e1c1f 8 copy of this software and associated documentation files (the "Software"),
bluetooth_mdw 0:b821de9e1c1f 9 to deal in the Software without restriction, including without limitation
bluetooth_mdw 0:b821de9e1c1f 10 the rights to use, copy, modify, merge, publish, distribute, sublicense,
bluetooth_mdw 0:b821de9e1c1f 11 and/or sell copies of the Software, and to permit persons to whom the
bluetooth_mdw 0:b821de9e1c1f 12 Software is furnished to do so, subject to the following conditions:
bluetooth_mdw 0:b821de9e1c1f 13
bluetooth_mdw 0:b821de9e1c1f 14 The above copyright notice and this permission notice shall be included in
bluetooth_mdw 0:b821de9e1c1f 15 all copies or substantial portions of the Software.
bluetooth_mdw 0:b821de9e1c1f 16
bluetooth_mdw 0:b821de9e1c1f 17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
bluetooth_mdw 0:b821de9e1c1f 18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
bluetooth_mdw 0:b821de9e1c1f 19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO Animation SHALL
bluetooth_mdw 0:b821de9e1c1f 20 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
bluetooth_mdw 0:b821de9e1c1f 21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
bluetooth_mdw 0:b821de9e1c1f 22 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
bluetooth_mdw 0:b821de9e1c1f 23 DEALINGS IN THE SOFTWARE.
bluetooth_mdw 0:b821de9e1c1f 24 */
bluetooth_mdw 0:b821de9e1c1f 25
bluetooth_mdw 0:b821de9e1c1f 26 #ifndef ANIMATOR_H
bluetooth_mdw 0:b821de9e1c1f 27 #define ANIMATOR_H
bluetooth_mdw 0:b821de9e1c1f 28
bluetooth_mdw 0:b821de9e1c1f 29 /*
bluetooth_mdw 0:b821de9e1c1f 30 * Class definition for an Animator
bluetooth_mdw 0:b821de9e1c1f 31 */
bluetooth_mdw 0:b821de9e1c1f 32
bluetooth_mdw 0:b821de9e1c1f 33 #include "MicroBitDisplay.h"
bluetooth_mdw 0:b821de9e1c1f 34
bluetooth_mdw 0:b821de9e1c1f 35 #define NUMBER_OF_ANIMATIONS 0x03
bluetooth_mdw 0:b821de9e1c1f 36 #define ANIMATION_SPEED_DELTA 50
bluetooth_mdw 0:b821de9e1c1f 37
krenbluetoothsig 9:eb3730b39608 38 //Animation Control Event
bluetooth_mdw 0:b821de9e1c1f 39 #define ANIMATION_CONTROL_EVENT 9100
krenbluetoothsig 8:d3d0c0ac4ce9 40 #define ANIMATION_CONTROL_STOP 0x00
bluetooth_mdw 0:b821de9e1c1f 41 #define ANIMATION_CONTROL_START 0x01
krenbluetoothsig 8:d3d0c0ac4ce9 42 #define ANIMATION_CONTROL_SLOWER 0x10
krenbluetoothsig 8:d3d0c0ac4ce9 43 #define ANIMATION_CONTROL_FASTER 0x11
bluetooth_mdw 0:b821de9e1c1f 44
krenbluetoothsig 9:eb3730b39608 45 //Animation Type Event
bluetooth_mdw 0:b821de9e1c1f 46 #define ANIMATION_TYPE_EVENT 9101
bluetooth_mdw 0:b821de9e1c1f 47 #define ANIMATION_TYPE_FLASH 0x01
bluetooth_mdw 0:b821de9e1c1f 48 #define ANIMATION_TYPE_RIPPLE 0x02
bluetooth_mdw 0:b821de9e1c1f 49 #define ANIMATION_TYPE_SPIRAL 0x03
bluetooth_mdw 0:b821de9e1c1f 50
bluetooth_mdw 0:b821de9e1c1f 51 #define ANIMATION_STATUS_EVENT 9102
bluetooth_mdw 0:b821de9e1c1f 52 #define ANIMATION_STATUS_FREE 0x00
bluetooth_mdw 0:b821de9e1c1f 53 #define ANIMATION_STATUS_BUSY 0x01
bluetooth_mdw 0:b821de9e1c1f 54
bluetooth_mdw 0:b821de9e1c1f 55 class Animator
bluetooth_mdw 0:b821de9e1c1f 56 {
bluetooth_mdw 0:b821de9e1c1f 57
bluetooth_mdw 0:b821de9e1c1f 58 public:
bluetooth_mdw 0:b821de9e1c1f 59
bluetooth_mdw 0:b821de9e1c1f 60 int playing;
bluetooth_mdw 0:b821de9e1c1f 61 int current_animation;
bluetooth_mdw 0:b821de9e1c1f 62 int sleep_time;
bluetooth_mdw 0:b821de9e1c1f 63
bluetooth_mdw 0:b821de9e1c1f 64 Animator(MicroBitDisplay &_display);
bluetooth_mdw 0:b821de9e1c1f 65
bluetooth_mdw 0:b821de9e1c1f 66 void setAnimationType(uint16_t animation);
bluetooth_mdw 0:b821de9e1c1f 67
bluetooth_mdw 0:b821de9e1c1f 68 void start();
bluetooth_mdw 0:b821de9e1c1f 69
bluetooth_mdw 0:b821de9e1c1f 70 void stop();
bluetooth_mdw 0:b821de9e1c1f 71
bluetooth_mdw 0:b821de9e1c1f 72 void faster();
bluetooth_mdw 0:b821de9e1c1f 73
bluetooth_mdw 0:b821de9e1c1f 74 void slower();
bluetooth_mdw 0:b821de9e1c1f 75
bluetooth_mdw 0:b821de9e1c1f 76 void ripple();
bluetooth_mdw 0:b821de9e1c1f 77
bluetooth_mdw 0:b821de9e1c1f 78 void spiral();
bluetooth_mdw 0:b821de9e1c1f 79
bluetooth_mdw 0:b821de9e1c1f 80 void flash();
bluetooth_mdw 0:b821de9e1c1f 81
bluetooth_mdw 0:b821de9e1c1f 82 void animationLoop();
bluetooth_mdw 0:b821de9e1c1f 83
bluetooth_mdw 0:b821de9e1c1f 84 private:
bluetooth_mdw 0:b821de9e1c1f 85
bluetooth_mdw 0:b821de9e1c1f 86 MicroBitDisplay &display;
bluetooth_mdw 0:b821de9e1c1f 87
bluetooth_mdw 0:b821de9e1c1f 88 };
bluetooth_mdw 0:b821de9e1c1f 89
bluetooth_mdw 0:b821de9e1c1f 90 #endif