diff --git a/drivers/fbani_recorder.c b/drivers/fbani_recorder.c new file mode 100644 index 0000000..3a93d94 --- /dev/null +++ b/drivers/fbani_recorder.c @@ -0,0 +1,42 @@ +#include "fbani_recorder.h" +#include "framebuffer.h" +#include + +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); + } +} + diff --git a/drivers/fbani_recorder.h b/drivers/fbani_recorder.h new file mode 100644 index 0000000..6b2354f --- /dev/null +++ b/drivers/fbani_recorder.h @@ -0,0 +1 @@ +void fbani_recorder(unsigned int count); diff --git a/pingpong.c b/pingpong.c index f03ba1c..3259648 100644 --- a/pingpong.c +++ b/pingpong.c @@ -1,48 +1,11 @@ #include #include "drivers/framebuffer.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); - } -} +#include "drivers/fbani_recorder.h" int main() { uint16_t i = 0; while(1) { - ani_recorder(4); + fbani_recorder(4); for (i = 0; i < 256; i++) { _delay_ms(50); fb_shift(i);