From bc11730b9fc6a242617625a65d71511a26171227 Mon Sep 17 00:00:00 2001 From: Ain <41307858+nero@users.noreply.github.com> Date: Wed, 3 Oct 2018 07:56:30 +0000 Subject: [PATCH] Put fb animations into driver directory --- drivers/fbani_recorder.c | 42 ++++++++++++++++++++++++++++++++++++++++ drivers/fbani_recorder.h | 1 + pingpong.c | 41 ++------------------------------------- 3 files changed, 45 insertions(+), 39 deletions(-) create mode 100644 drivers/fbani_recorder.c create mode 100644 drivers/fbani_recorder.h 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);