Complex figures are tough to build programmatic-ally(dynamic creation), so such figures are converted from an image to equivalent header files, and then called after a certain time delay(creating frame rate) so to it seem as animated.
CLick to view swf.
This is the gif i choose.
Horse Running GIF. |
Frame by Frame Image. |
So obviously the next step is to separate each image by cropping. Using any image editor. As shown below.
Cropping Individual Image. |
Now separated image needs to be converted to monochrome. To see how to do view this post. Converting Bitmap Image to Equivalent Header File.
Difference Grayscale and Monochrome Image |
Individual Header Files. |
The LoadBitmap Function that was used to show bitmap images is used here to show the frame by frame animation.
void LoadBitmap(unsigned char *bitmap)
{
uint16_t i, j,by;
for(i=0; i<64; i+=8)
for(j=0;
j<128; j++)
{
by=pgm_read_byte(bitmap++);
ks0108GotoXY(j,
i);
ks0108WriteData(by);
}
}
|
void main() { for(volatile uint16_t i=0; i<15000; i++); ks0108Init(0); ks0108ClearScreen(); while(1) { LoadBitmap(horse001); for(volatile uint16_t i=0; i<15000; i++); LoadBitmap(horse002); for(volatile uint16_t i=0; i<15000; i++); LoadBitmap(horse003); for(volatile uint16_t i=0; i<15000; i++); LoadBitmap(horse004); for(volatile uint16_t i=0; i<15000; i++); LoadBitmap(horse005); for(volatile uint16_t i=0; i<15000; i++); LoadBitmap(horse006); for(volatile uint16_t i=0; i<15000; i++); LoadBitmap(horse007); for(volatile uint16_t i=0; i<15000; i++); LoadBitmap(horse008); for(volatile uint16_t i=0; i<15000; i++); LoadBitmap(horse009); for(volatile uint16_t i=0; i<15000; i++); LoadBitmap(horse010); for(volatile uint16_t i=0; i<15000; i++); LoadBitmap(horse011); for(volatile uint16_t i=0; i<15000; i++); }//end of while loop } |
Currently the frame rate is 15frames per second one can vary and change the speed of display by varying the value of i. To make a more precise frame rate stay connect for future post.
This is the final output.
No comments:
Post a Comment