Ondřej Hruška 2 years ago
parent d90cfa0e20
commit 79232c5d2c
  1. 78
      src/graphic_loading.c

@ -110,7 +110,7 @@ void fb_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t color) {
if (rowrem + h < 8) {
// all within one cell
uint8_t mask = (0xFF << rowrem) & (0xFF >> (h-rowrem));
uint8_t mask = (0xFF << rowrem) & (0xFF >> (8 - (h - rowrem)));
for(uint8_t i = 0; i < w; i++) {
if (color) {
@ -130,7 +130,7 @@ void fb_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t color) {
fb[cell + i] &= ~mask;
}
}
h -= rowrem;
h -= 8 - rowrem;
uint8_t whole_cells = h / 8;
h -= whole_cells * 8;
@ -145,6 +145,8 @@ void fb_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t color) {
}
}
cell += FBW;
// last
mask = (0xFF >> (8-h));
for(uint8_t i = 0; i < w; i++) {
@ -157,40 +159,68 @@ void fb_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t color) {
}
}
void fb_bitmap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, uint8_t color) {
// TODO
}
void fb_blit() {
ssd1306_drawBuffer(0, 0, FBW, FBH, fb);
}
void show_loading_screen(uint8_t progress_percent, bool clear)
{
// HACKS - GUI dev here
fb_clear();
fb_blit();
//
// fb_hline(3, 3, 30, 1);
// fb_hline(3, 15, 35, 1);
// fb_hline(3, 30, 40, 1);
//
// fb_vline(5, 0, 15, 1);
// fb_vline(6, 0, 32, 0);
fb_rect(10, 10, 30, 3, 1);
fb_rect(40, 13, 3, 10, 1);
//
// fb_rect(0, 0, 10, 10, 1);
//
// fb_rect(7, 20, 20, 1, 1);
// fb_rect(7, 23, 20, 3, 1);
//fb_rect(15, 0, 5, 20, 0);
fb_blit();
#if 0
int a = 0, b = 0, ai = 1, bi = 1;
int c = 50, d = 5, ci = -1, di = 1;
int e = 70, f = 10, ei = 1, fi = -1;
int w=15;
int W=20;
for(;;){
fb_clear();
fb_rect(a, b, w, w, 1);
fb_rect(c, d, w, w, 1);
fb_rect(e, f, W, W, 1);
fb_rect(a+1, b+1, w-2, w-2, 0);
fb_rect(c+1, d+1, w-2, w-2, 0);
fb_rect(e+1, f+1, W-2, W-2, 0);
a += ai;
if (a == FBW-1-w) ai = -1;
if (a == 0) ai = 1;
b += bi;
if (b == FBH-1-w) bi = -1;
if (b == 0) bi = 1;
c += ci;
if (c == FBW-1-w) ci = -1;
if (c == 0) ci = 1;
d += di;
if (d == FBH-1-w) di = -1;
if (d == 0) di = 1;
e += ei;
if (e == FBW-1-W) ei = -1;
if (e == 0) ei = 1;
f += fi;
if (f == FBH-1-W) fi = -1;
if (f == 0) fi = 1;
fb_blit();
_delay_ms(5);
}
#endif
for(;;){}
for(;;) {}
if (clear) {

Loading…
Cancel
Save