Johan Kritzinger / Mbed 2 deprecated FRDMKL25Z-ShiftBrite

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers movie.h Source File

movie.h

00001 #ifndef MOVIE_H
00002 #define MOVIE_H
00003 #include "mbed.h"
00004 #include "sbDriver.h"
00005 
00006 /**movie class
00007 * Used to send multiple frames of data to the Shiftbrite display.
00008 *
00009 * It does not inherit anything but does use a reference to a shiftBriteDisplay object.
00010 * Example:
00011 *   @code
00012 *        #include "mbed.h"
00013 *        #include "sbDriver.h"
00014 *        #include "movie.h"
00015 *
00016 *        //6 leds example. Format it suitably for easy reading
00017 *        unsigned short int aMovie[] = {
00018 *
00019 *        // LED1      LED2      LED3      LED4      LED5      LED6 
00020 *        1023,0,0,    0,0,0,    0,0,0,    0,0,0,    0,0,0,    0,0,0,     //Frame 0
00021 *            0,0,0, 1023,0,0,    0,0,0,    0,0,0,    0,0,0,    0,0,0,     //Frame 1
00022 *            0,0,0,    0,0,0,    1023,0,0, 0,0,0,    0,0,0,    0,0,0,     //Frame 2
00023 *            0,0,0,    0,0,0,    0,0,0,    1023,0,0, 0,0,0,    0,0,0,     //Frame 3
00024 *            0,0,0,    0,0,0,    0,0,0,    0,0,0,    1023,0,0, 0,0,0,     //Frame 4
00025 *            0,0,0,    0,0,0,    0,0,0,    0,0,0,    0,0,0,    1023,0,0,  //Frame 5
00026 *            0,0,0,    0,0,0,    0,0,0,    0,0,0,    1023,0,0, 0,0,0,     //Frame 6
00027 *            0,0,0,    0,0,0,    0,0,0,    1023,0,0, 0,0,0,    0,0,0,     //Frame 7
00028 *            0,0,0,    0,0,0,    1023,0,0, 0,0,0,    0,0,0,    0,0,0,     //Frame 8
00029 *            0,0,0, 1023,0,0,    0,0,0,    0,0,0,    0,0,0,    0,0,0      //Frame 9
00030 *        //A simple 'cylon' scanner 'movie'    
00031 *        };
00032 *    
00033 *        Serial PC(PTA2, PTA1);//
00034 *
00035 *        //Instanced of DigitalOut for control SB signals
00036 *        DigitalOut latch(PTC16);//010=latch
00037 *        DigitalOut enable(PTA13);//0= enabled
00038 *        DigitalOut reset(PTC12);
00039 *        //Instance of the SPI contoller for SB data
00040 *        SPI spi(PTD2,NC,PTD1);//PDT2 = MOSI=DATA. PDT1=CLK
00041 *
00042 *
00043 *        int main() {
00044 *    
00045 *            //Instanciate a ticker object to handle framerate updates for the SB display    
00046 *            Ticker t;
00047 *
00048 *            //Instanciate a string of 6 sb modules and tell the driver object where the control/data pins are
00049 *            shiftBriteDisplay sbDisplay(&PC,latch, enable, reset, spi,6);
00050 *
00051 *            movie myMovie(aMovie,sbDisplay,sizeof(aMovie));
00052 *            myMovie.setRepeat(1);
00053 *            t.attach(&myMovie,&movie::play,0.05);//Call movie() every 0.05 seconds.Beware, if you go too fast here the FRDM will crash
00054 *
00055 *            while(1){
00056 *            }
00057 *        }
00058 *        @endcode
00059 */
00060 class movie{
00061     unsigned long int movieSize; //how many BYTES are in the movie array
00062     //NB, this is NOT the number of frames. frame Tot = ((movieSize/sizeof(unsigned short int))/frameSize)/3
00063     unsigned short int frameSize; //how many leds are in a display
00064     unsigned long int currentFrame; // which frame are we displaying now
00065     unsigned char f_repeat; // repeat when end is reached
00066     unsigned short int * movie_p;//This is where the movie data is stored
00067     shiftBriteDisplay r_display;//reference to the display
00068 public:
00069     //movie(unsigned short int * movie_p, shiftBriteDisplay &display); // constructor - frameCount=how many frames in the movie
00070 /**constructor.
00071 */
00072     movie(unsigned short int * movie_p, shiftBriteDisplay &display, unsigned int movieSize);
00073     //This must dynamically allocte 
00074     void play();//cycles through all known frames, one frame each time it is called
00075     void setRepeat(unsigned char r){f_repeat = r;};//repeat from the start or keep on showing the final frame of the movie
00076 };
00077 #endif