avr-firmwares/pingpong.c

37 lines
436 B
C

#include <util/delay.h>
#include "drivers/framebuffer.h"
int main(void) {
int8_t px, py, mx, my;
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;
}
FB_SET(px,py,0);
px += mx;
py += my;
FB_SET(px,py,1);
_delay_ms(50);
}
}