skoro funkcni bitmapa

gui-dev
Ondřej Hruška 2 years ago
parent fb7002e68b
commit 24b9a7359b
  1. 75
      src/framebuffer.c
  2. 28
      src/graphic_loading.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; return;
} else if (rowrem == 0) { } else if (rowrem == 0) {
// Optimization // Optimization
uint8_t mapc0 = 0;
// First // First
for(uint8_t i = 0; i < w; i++) { 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; h -= whole_cells * 8;
for(uint8_t j = 0; j < whole_cells; j++) { for(uint8_t j = 0; j < whole_cells; j++) {
cell += FBW; cell += FBW;
mapc0 += w0;
for(uint8_t i = 0; i < w; i++) { for(uint8_t i = 0; i < w; i++) {
uint8_t mask = map[i + (j+1)*w0]; uint8_t mask = map[i + mapc0];
if (color) { if (color) {
fb[cell + i] |= mask; fb[cell + i] |= mask;
} else { } 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 // last
mapc0 += w0;
cell += FBW; cell += FBW;
// last // last
for(uint8_t i = 0; i < w; i++) { 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) { if (color) {
fb[cell + i] |= mask; fb[cell + i] |= mask;
} else { } 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 { } 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
} }
} }

@ -14,7 +14,7 @@ void show_loading_screen(uint8_t progress_percent, bool clear) {
fb_clear(); fb_clear();
fb_blit(); fb_blit();
const uint8_t icon[14] = { const uint8_t ryba[14] = {
0b11000011, 0b11000011,
0b01100110, 0b01100110,
0b01111110, 0b01111110,
@ -31,6 +31,7 @@ void show_loading_screen(uint8_t progress_percent, bool clear) {
0b00011000, 0b00011000,
}; };
#define ZIR_W 12 #define ZIR_W 12
#define ZIR_H 3 #define ZIR_H 3
const uint8_t zirafa[ZIR_H * ZIR_W] = { const uint8_t zirafa[ZIR_H * ZIR_W] = {
@ -73,14 +74,31 @@ void show_loading_screen(uint8_t progress_percent, bool clear) {
0b00011111, 0b00011111,
0b11111000, 0b11111000,
0b00000000, 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 a = 10;
int b = 40; int b = 40;
for (;;) { for (;;) {
fb_bitmap(a, 0, ZIR_W, ZIR_H*8, zirafa, 0); 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++; a++;
b++; b++;
if(a>127) { if(a>127) {
@ -91,10 +109,10 @@ void show_loading_screen(uint8_t progress_percent, bool clear) {
b = 0; b = 0;
} }
fb_bitmap(a, 0, ZIR_W, ZIR_H*8, zirafa, 1); 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(); fb_blit();
_delay_ms(100); _delay_ms(5);
} }

Loading…
Cancel
Save