avr-firmwares/pingpong.c

52 lines
664 B
C

#include <util/delay.h>
#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);
}
}
int main() {
uint16_t i = 0;
while(1) {
ani_recorder(4);
for (i = 0; i < 256; i++) {
_delay_ms(50);
fb_shift(i);
}
}
}