Progress with animations

This commit is contained in:
Nero 2018-10-03 20:20:35 +00:00
parent bc11730b9f
commit de0ac733c0
6 changed files with 121 additions and 7 deletions

View File

@ -0,0 +1,21 @@
#include <util/delay.h>
#include "framebuffer.h"
#define HALFW (FB_WIDTH/2)
#define HALFH (FB_HEIGHT/2)
void fbani_starhopper_print_rectangles(uint8_t v) {
fb_area(0 ,0 ,HALFW ,HALFH , (v >> 3) & 1);
fb_area(HALFW,0 ,2*HALFW,HALFH , (v >> 2) & 1);
fb_area(0 ,HALFH,HALFW ,2*HALFH, (v >> 1) & 1);
fb_area(HALFW,HALFH,2*HALFW,2*HALFH, (v ) & 1);
}
void fbani_starhopper(uint16_t count) {
while(count--) {
fbani_starhopper_print_rectangles(0x0e);
_delay_ms(600);
fbani_starhopper_print_rectangles(0x0b);
_delay_ms(150);
};
}

View File

@ -0,0 +1 @@
void fbani_starhopper(uint16_t count);

51
drivers/fbticker.c Normal file
View File

@ -0,0 +1,51 @@
#include "framebuffer.h"
#include <util/delay.h>
void fbticker_pushcol(uint8_t col) {
fb_shift(col << 1);
_delay_ms(60);
}
void fbticker_putc(unsigned char c) {
switch(c) {
case 'A':
fbticker_pushcol(0x7e);
fbticker_pushcol(0x09);
fbticker_pushcol(0x09);
fbticker_pushcol(0x09);
fbticker_pushcol(0x7e);
break;
case 'B':
fbticker_pushcol(0x7f);
fbticker_pushcol(0x49);
fbticker_pushcol(0x49);
fbticker_pushcol(0x36);
break;
case 'C':
fbticker_pushcol(0x3e);
fbticker_pushcol(0x41);
fbticker_pushcol(0x41);
fbticker_pushcol(0x22);
break;
case 'D':
fbticker_pushcol(0x7f);
fbticker_pushcol(0x41);
fbticker_pushcol(0x41);
fbticker_pushcol(0x3e);
break;
case 'E':
fbticker_pushcol(0x7f);
fbticker_pushcol(0x49);
fbticker_pushcol(0x49);
fbticker_pushcol(0x49);
break;
case 'F':
fbticker_pushcol(0x7f);
fbticker_pushcol(0x09);
fbticker_pushcol(0x09);
fbticker_pushcol(0x09);
break;
}
fbticker_pushcol(0);
}

1
drivers/fbticker.h Normal file
View File

@ -0,0 +1 @@
void fbticker_putc(unsigned char c);

View File

@ -31,3 +31,32 @@ void fb_fill(uint8_t c) {
}
#endif
void fb_hline(uint8_t y, uint8_t x1, uint8_t x2, uint8_t c) {
uint8_t i;
for (i = x1; i <= x2; i++) {
FB_SET(i, y, c);
}
}
void fb_vline(uint8_t x, uint8_t y1, uint8_t y2, uint8_t c) {
uint8_t i;
for (i = y1; i <= y2; i++) {
FB_SET(x, i, c);
}
}
void fb_box(uint8_t ax, uint8_t ay, uint8_t bx, uint8_t by, uint8_t c) {
fb_hline(ay, ax, bx, c);
fb_hline(by, ax, bx, c);
fb_vline(ax, ay, by, c);
fb_vline(bx, ay, by, c);
}
void fb_area(uint8_t ax, uint8_t ay, uint8_t bx, uint8_t by, uint8_t c) {
uint8_t i;
for (i = ay; i <= by; i++) {
fb_hline(i, ax, bx, c);
}
}

View File

@ -1,14 +1,25 @@
#include <util/delay.h>
#include "drivers/framebuffer.h"
#include "drivers/fbticker.h"
#include "drivers/fbani_starhopper.h"
#include "drivers/fbani_recorder.h"
int main() {
void fbani_binary(uint16_t max) {
uint16_t i = 0;
while(1) {
fbani_recorder(4);
for (i = 0; i < 256; i++) {
_delay_ms(50);
fb_shift(i);
}
for (i = 0; i < max; i++) {
_delay_ms(50);
fb_shift(i);
}
}
int main() {
unsigned char c;
while(1) {
fbani_starhopper(40);
fbani_binary(256);
fbani_recorder(50);
for (c = 'A'; c <= 'Z'; c++) {
fbticker_putc(c);
}
};
}