Solution to the Bluetooth animation service exercise

Dependencies:   microbit

Fork of microbit-animator by Martin Woolley

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Animator.h Source File

Animator.h

00001 /*
00002 The MIT License (MIT)
00003 
00004 Copyright (c) 2016 British Broadcasting Corporation.
00005 This software is provided by Lancaster University by arrangement with the BBC.
00006 
00007 Permission is hereby granted, free of charge, to any person obtaining a
00008 copy of this software and associated documentation files (the "Software"),
00009 to deal in the Software without restriction, including without limitation
00010 the rights to use, copy, modify, merge, publish, distribute, sublicense,
00011 and/or sell copies of the Software, and to permit persons to whom the
00012 Software is furnished to do so, subject to the following conditions:
00013 
00014 The above copyright notice and this permission notice shall be included in
00015 all copies or substantial portions of the Software.
00016 
00017 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO Animation SHALL
00020 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00021 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00022 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00023 DEALINGS IN THE SOFTWARE.
00024 */
00025 
00026 #ifndef ANIMATOR_H
00027 #define ANIMATOR_H
00028 
00029 /*
00030  * Class definition for an Animator
00031  */
00032  
00033 #include "MicroBitDisplay.h"
00034 
00035 #define NUMBER_OF_ANIMATIONS 0x03
00036 
00037 #define ANIMATION_CONTROL_EVENT 9100
00038 #define ANIMATION_CONTROL_START 0x01
00039 #define ANIMATION_CONTROL_STOP  0x02
00040 
00041 #define ANIMATION_TYPE_EVENT    9101
00042 #define ANIMATION_TYPE_FLASH    0x01
00043 #define ANIMATION_TYPE_RIPPLE   0x02
00044 #define ANIMATION_TYPE_SPIRAL   0x03
00045 
00046 #define ANIMATION_STATUS_EVENT  9101
00047 #define ANIMATION_STATUS_FREE   0x00
00048 #define ANIMATION_STATUS_BUSY   0x01
00049 
00050 class Animator
00051 {
00052 
00053     public:
00054         
00055     int playing;
00056     int current_animation;
00057     int sleep_time;
00058 
00059     Animator(MicroBitDisplay &_display);
00060 
00061     void setAnimationType(uint16_t animation);
00062 
00063     void start();
00064     
00065     void stop();
00066     
00067     void faster();
00068     
00069     void slower();
00070     
00071     void ripple();
00072     
00073     void spiral();
00074     
00075     void flash();
00076     
00077     void animationLoop();
00078     
00079     private:
00080     
00081     MicroBitDisplay     &display;
00082        
00083 };
00084 
00085 #endif