This repository is for Bluetooth Asia 2018 developer training, peripheral session.

Dependencies:   microbit

Fork of BluetoothAsiaPeripheral by Kaiser Ren

Committer:
krenbluetoothsig
Date:
Wed Mar 14 09:20:50 2018 +0000
Revision:
5:e778ea479b18
Parent:
0:b821de9e1c1f
Child:
8:d3d0c0ac4ce9
1. NEW: add peripheral_src.txt which includes peripheral session code snippet and guide.

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
bluetooth_mdw 0:b821de9e1c1f 38 #define ANIMATION_CONTROL_EVENT 9100
bluetooth_mdw 0:b821de9e1c1f 39 #define ANIMATION_CONTROL_START 0x01
bluetooth_mdw 0:b821de9e1c1f 40 #define ANIMATION_CONTROL_STOP 0x02
bluetooth_mdw 0:b821de9e1c1f 41 #define ANIMATION_CONTROL_FASTER 0x03
bluetooth_mdw 0:b821de9e1c1f 42 #define ANIMATION_CONTROL_SLOWER 0x04
bluetooth_mdw 0:b821de9e1c1f 43
bluetooth_mdw 0:b821de9e1c1f 44 #define ANIMATION_TYPE_EVENT 9101
bluetooth_mdw 0:b821de9e1c1f 45 #define ANIMATION_TYPE_FLASH 0x01
bluetooth_mdw 0:b821de9e1c1f 46 #define ANIMATION_TYPE_RIPPLE 0x02
bluetooth_mdw 0:b821de9e1c1f 47 #define ANIMATION_TYPE_SPIRAL 0x03
bluetooth_mdw 0:b821de9e1c1f 48
bluetooth_mdw 0:b821de9e1c1f 49 #define ANIMATION_STATUS_EVENT 9102
bluetooth_mdw 0:b821de9e1c1f 50 #define ANIMATION_STATUS_FREE 0x00
bluetooth_mdw 0:b821de9e1c1f 51 #define ANIMATION_STATUS_BUSY 0x01
bluetooth_mdw 0:b821de9e1c1f 52
bluetooth_mdw 0:b821de9e1c1f 53 class Animator
bluetooth_mdw 0:b821de9e1c1f 54 {
bluetooth_mdw 0:b821de9e1c1f 55
bluetooth_mdw 0:b821de9e1c1f 56 public:
bluetooth_mdw 0:b821de9e1c1f 57
bluetooth_mdw 0:b821de9e1c1f 58 int playing;
bluetooth_mdw 0:b821de9e1c1f 59 int current_animation;
bluetooth_mdw 0:b821de9e1c1f 60 int sleep_time;
bluetooth_mdw 0:b821de9e1c1f 61
bluetooth_mdw 0:b821de9e1c1f 62 Animator(MicroBitDisplay &_display);
bluetooth_mdw 0:b821de9e1c1f 63
bluetooth_mdw 0:b821de9e1c1f 64 void setAnimationType(uint16_t animation);
bluetooth_mdw 0:b821de9e1c1f 65
bluetooth_mdw 0:b821de9e1c1f 66 void start();
bluetooth_mdw 0:b821de9e1c1f 67
bluetooth_mdw 0:b821de9e1c1f 68 void stop();
bluetooth_mdw 0:b821de9e1c1f 69
bluetooth_mdw 0:b821de9e1c1f 70 void faster();
bluetooth_mdw 0:b821de9e1c1f 71
bluetooth_mdw 0:b821de9e1c1f 72 void slower();
bluetooth_mdw 0:b821de9e1c1f 73
bluetooth_mdw 0:b821de9e1c1f 74 void ripple();
bluetooth_mdw 0:b821de9e1c1f 75
bluetooth_mdw 0:b821de9e1c1f 76 void spiral();
bluetooth_mdw 0:b821de9e1c1f 77
bluetooth_mdw 0:b821de9e1c1f 78 void flash();
bluetooth_mdw 0:b821de9e1c1f 79
bluetooth_mdw 0:b821de9e1c1f 80 void animationLoop();
bluetooth_mdw 0:b821de9e1c1f 81
bluetooth_mdw 0:b821de9e1c1f 82 private:
bluetooth_mdw 0:b821de9e1c1f 83
bluetooth_mdw 0:b821de9e1c1f 84 MicroBitDisplay &display;
bluetooth_mdw 0:b821de9e1c1f 85
bluetooth_mdw 0:b821de9e1c1f 86 };
bluetooth_mdw 0:b821de9e1c1f 87
bluetooth_mdw 0:b821de9e1c1f 88 #endif