Put fb animations into driver directory

This commit is contained in:
Nero 2018-10-03 07:56:30 +00:00
parent 9c912ffb85
commit bc11730b9f
3 changed files with 45 additions and 39 deletions

42
drivers/fbani_recorder.c Normal file
View File

@ -0,0 +1,42 @@
#include "fbani_recorder.h"
#include "framebuffer.h"
#include <util/delay.h>
void fbani_recorder(unsigned int count) {
int8_t px, py, mx, my;
fb_fill(0);
px = 0;
py = 0;
mx = 1;
my = 1;
while(1) {
if (px <= 0) {
mx = 1;
}
if (py <= 0) {
my = 1;
}
if (px >= FB_WIDTH - 1) {
mx = -1;
}
if (py >= FB_HEIGHT - 1) {
my = -1;
count --;
}
FB_SET(px,py,0);
if (!count) return;
px += mx;
py += my;
FB_SET(px,py,1);
_delay_ms(50);
}
}

1
drivers/fbani_recorder.h Normal file
View File

@ -0,0 +1 @@
void fbani_recorder(unsigned int count);

View File

@ -1,48 +1,11 @@
#include <util/delay.h> #include <util/delay.h>
#include "drivers/framebuffer.h" #include "drivers/framebuffer.h"
#include "drivers/fbani_recorder.h"
void ani_recorder(unsigned int count) {
int8_t px, py, mx, my;
fb_fill(0);
px = 0;
py = 0;
mx = 1;
my = 1;
while(1) {
if (px <= 0) {
mx = 1;
}
if (py <= 0) {
my = 1;
}
if (px >= FB_WIDTH - 1) {
mx = -1;
}
if (py >= FB_HEIGHT - 1) {
my = -1;
count --;
}
FB_SET(px,py,0);
if (!count) return;
px += mx;
py += my;
FB_SET(px,py,1);
_delay_ms(50);
}
}
int main() { int main() {
uint16_t i = 0; uint16_t i = 0;
while(1) { while(1) {
ani_recorder(4); fbani_recorder(4);
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
_delay_ms(50); _delay_ms(50);
fb_shift(i); fb_shift(i);