From 24b9a7359ba618ae7a0cb778437fd5e0ab856695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sun, 13 Nov 2022 14:53:17 +0100 Subject: [PATCH] skoro funkcni bitmapa --- src/framebuffer.c | 75 +++++++++++++++++++++++++++++++++++++++++-- src/graphic_loading.c | 28 +++++++++++++--- 2 files changed, 95 insertions(+), 8 deletions(-) diff --git a/src/framebuffer.c b/src/framebuffer.c index 5edbb17..1e27eb0 100644 --- a/src/framebuffer.c +++ b/src/framebuffer.c @@ -181,6 +181,7 @@ void fb_bitmap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, u return; } else if (rowrem == 0) { // Optimization + uint8_t mapc0 = 0; // First for(uint8_t i = 0; i < w; i++) { @@ -198,8 +199,9 @@ void fb_bitmap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, u h -= whole_cells * 8; for(uint8_t j = 0; j < whole_cells; j++) { cell += FBW; + mapc0 += w0; for(uint8_t i = 0; i < w; i++) { - uint8_t mask = map[i + (j+1)*w0]; + uint8_t mask = map[i + mapc0]; if (color) { fb[cell + i] |= mask; } else { @@ -209,11 +211,12 @@ void fb_bitmap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, u } // last + mapc0 += w0; cell += FBW; // last for(uint8_t i = 0; i < w; i++) { - uint8_t mask = map[i + (whole_cells+1)*w0] & (0xFF >> (8-h)); + uint8_t mask = map[i + mapc0] & (0xFF >> (8-h)); if (color) { fb[cell + i] |= mask; } else { @@ -222,7 +225,73 @@ void fb_bitmap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, u } } else { - // TODO wild combination, unaligned multi-row + uint8_t mapc0 = 0; + + while (h > 0) { + // First + for (uint8_t i = 0; i < w; i++) { + uint8_t mask = (map[i + mapc0] & (0xFF >> (rowrem))) << rowrem; + if (color) { + fb[cell + i] |= mask; + } else { + fb[cell + i] &= ~mask; + } + } + + //mapc0 += w0; + cell += FBW; + + // leftover of the first row in map + + // last + for (uint8_t i = 0; i < w; i++) { + uint8_t mask = map[i + mapc0] >> (8 - rowrem); + if (color) { + fb[cell + i] |= mask; + } else { + fb[cell + i] &= ~mask; + } + } + + if (h > 8) { + h -= 8; + } else { + break; + } + mapc0 += w0; + } + +#if 0 + // Middle + uint8_t whole_cells = h / 8; + h -= whole_cells * 8; + for(uint8_t j = 0; j < whole_cells; j++) { + cell += FBW; + mapc0 += w0; + for(uint8_t i = 0; i < w; i++) { + uint8_t mask = map[i + mapc0]; + if (color) { + fb[cell + i] |= mask; + } else { + fb[cell + i] &= ~mask; + } + } + } + + // last + mapc0 += w0; + cell += FBW; + + // last + for(uint8_t i = 0; i < w; i++) { + uint8_t mask = map[i + mapc0] & (0xFF >> (8-h)); + if (color) { + fb[cell + i] |= mask; + } else { + fb[cell + i] &= ~mask; + } + } +#endif } } diff --git a/src/graphic_loading.c b/src/graphic_loading.c index bb7d17e..62a09a0 100644 --- a/src/graphic_loading.c +++ b/src/graphic_loading.c @@ -14,7 +14,7 @@ void show_loading_screen(uint8_t progress_percent, bool clear) { fb_clear(); fb_blit(); - const uint8_t icon[14] = { + const uint8_t ryba[14] = { 0b11000011, 0b01100110, 0b01111110, @@ -31,6 +31,7 @@ void show_loading_screen(uint8_t progress_percent, bool clear) { 0b00011000, }; + #define ZIR_W 12 #define ZIR_H 3 const uint8_t zirafa[ZIR_H * ZIR_W] = { @@ -73,14 +74,31 @@ void show_loading_screen(uint8_t progress_percent, bool clear) { 0b00011111, 0b11111000, 0b00000000, - }; + +#if 1 + + + int pos=0; + for(;;) { + fb_clear(); + //fb_bitmap(0, pos, 14, 8, ryba, 1); + fb_bitmap(0, pos, ZIR_W, ZIR_H, zirafa, 1); + fb_blit(); + _delay_ms(500); + pos++; + if (pos>31) { + pos = 0; + } + } +#endif + int a = 10; int b = 40; for (;;) { fb_bitmap(a, 0, ZIR_W, ZIR_H*8, zirafa, 0); - fb_bitmap(b, 16, 14, 8, icon, 0); + fb_bitmap(b, 16, 14, 8, ryba, 0); a++; b++; if(a>127) { @@ -91,10 +109,10 @@ void show_loading_screen(uint8_t progress_percent, bool clear) { b = 0; } fb_bitmap(a, 0, ZIR_W, ZIR_H*8, zirafa, 1); - fb_bitmap(b, 16, 14, 8, icon, 1); + fb_bitmap(b, 16, 14, 8, ryba, 1); fb_blit(); - _delay_ms(100); + _delay_ms(5); }