Johan Kritzinger
/
FRDMKL25Z-ShiftBrite
A few classes to interface one or more ShiftBrite module to the FRDM KL25Z.
Diff: movie.cpp
- Revision:
- 3:9376bf1f1bbd
- Parent:
- 2:3935d2ed40cd
--- a/movie.cpp Wed Aug 20 05:24:38 2014 +0000 +++ b/movie.cpp Wed Aug 20 08:11:28 2014 +0000 @@ -13,42 +13,30 @@ this->movieSize = movieSize; // in BYTES. Need to (((movieSize/sizeof(unsigned short int))/frameSize)/3) to get actual frames } +/** +* Used to play through a data 'movie' array, one frame each time this member function is called. +*/ void movie::play(){ - /**Advance therough the movie one frame whenever this member method is called +/*Advance therough the movie one frame whenever this member method is called Display is referenced with r_display - */ +*/ unsigned int dot = 0; -// unsigned int dotCol = 0; unsigned short int rTemp, gTemp, bTemp; + //moduleCount is how many LEDS, assume 4, called frameSize //currentFrame is how many frames we've loaded //currentDot is which module in the frame, i.e. 0-3 in this example - //starts at 0 - //So, first value is at *(movie_p + (currentFrame*moduleCount*currentDot)) - // i.e. *(movie_p + 0*4*0) which is *(movie_p + 0), i.e. the very first byte - // so, colours are are *(movie_p + 0 + 0,1,2) - // Increment current Dot - // *(movie_p + (0*4*1) + 0,1,2) = 4+0, 4+1, 4+2) - // Iterate through all Dots - //then, increment the currentFrame and store for next time - //remember to check that we do not exceed the bounds of the data - //serial_p->printf("movie pointer l=%p r=%u v=%u",&movie_p,movie_p,*movie_p); for(dot = 0; dot != frameSize; dot++){ - // movie_p+=(unsigned short int*)((currentFrame*frameSize*dot)+0); - /* rTemp = *(movie_p + ((currentFrame*frameSize*dot)+0)); - gTemp = *(movie_p + ((currentFrame*frameSize*dot)+1)); - bTemp = *(movie_p + ((currentFrame*frameSize*dot)+2)); */ rTemp = *(movie_p + ((currentFrame*frameSize*3)+(dot*3)+0)); gTemp = *(movie_p + ((currentFrame*frameSize*3)+(dot*3)+1)); bTemp = *(movie_p + ((currentFrame*frameSize*3)+(dot*3)+2)); - //serial_p->printf("Frame: %d Module: %d r:%d g:%d b:%d\r\n",currentFrame,dot,rTemp,gTemp,bTemp); r_display.setLed(dot,rTemp,gTemp,bTemp); } r_display.displayFrame();//update the display - MAKE IT HAPPEN - currentFrame++; + currentFrame++;//Advance to the next frame //Check bounds if((currentFrame)>=((movieSize/sizeof(unsigned short int))/frameSize)/3){ if(f_repeat == 1) currentFrame = 0;//start from first frame