fixes for partly off-screen bitmap, remove temporary debug changes

calib-gui
Ondřej Hruška 2 years ago
parent 0d9565dbb7
commit edd003a541
  1. 5
      Core/Src/app_gui.c
  2. 16
      Lib/ufb/Src/framebuffer.c

@ -228,8 +228,6 @@ static void input_sound_effect()
static const char* main_menu_opts[] = { static const char* main_menu_opts[] = {
"Manual mode", "Manual mode",
"Calibration", "Calibration",
"Moderately long text",
"Very very long text that slides",
NULL NULL
}; };
@ -337,7 +335,7 @@ static void screen_manual_menu(GuiEvent event)
static void screen_menu(GuiEvent event, const char **options, menu_callback_t cb) { static void screen_menu(GuiEvent event, const char **options, menu_callback_t cb) {
bool menu_changed = false; bool menu_changed = false;
uint32_t tickNow = xTaskGetTickCount(); const uint32_t tickNow = xTaskGetTickCount();
struct menu_state *menu = &s_app.page.menu; struct menu_state *menu = &s_app.page.menu;
@ -352,7 +350,6 @@ static void screen_menu(GuiEvent event, const char **options, menu_callback_t cb
menu->len++; menu->len++;
opt++; opt++;
} }
menu->pos = menu->len - 1; // FIXME temporary, for debug
break; break;
case GUI_EVENT_SCREEN_TICK: case GUI_EVENT_SCREEN_TICK:

@ -232,19 +232,19 @@ void fb_circle(fbpos_t x0, fbpos_t y0, fbpos_t radius, uint8_t thickness, fbcolo
#if IS_AVR #if IS_AVR
void fb_bitmap_ex_P(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, const uint8_t *map, fbcolor_t color) void fb_bitmap_ex_P(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, const uint8_t *map, fbcolor_t color)
#else #else
void fb_bitmap_ex(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, const uint8_t *map, fbcolor_t color) void fb_bitmap_ex(const fbpos_t x, const fbpos_t y, const fbpos_t w0, const fbpos_t h0, const uint8_t *map, fbcolor_t color)
#endif #endif
{ {
if (x >= FBW || y >= FBH || x < -w || h < -h) { return; } if (x >= FBW || y >= FBH || x < -w0 || y < -h0) { return; }
const fbpos_t w0 = w; const fbpos_t w = MIN(FBW - x, w0);
w = MIN(FBW - x - 1, w); fbpos_t h = MIN(FBH - y - 1, h0); // h is used as counter for rows
h = MIN(FBH - y - 1, h);
const fbpos_t row = y / 8; const fbpos_t row = y / 8;
const fbpos_t rowrem = y % 8; const fbpos_t rowrem = y % 8;
fbsize_t cell = (fbsize_t) x + (fbsize_t) row * FBW; fbsize_t cell = (fbsize_t) x + (fbsize_t) row * FBW;
const fbpos_t xskip = (x >= 0) ? 0 : (-x);
if (rowrem + h <= 8) { if (rowrem + h <= 8) {
for (fbpos_t i = 0; i < w; i++) { for (fbpos_t i = xskip; i < w; i++) {
// all within one cell // all within one cell
const uint8_t mask = (pgm_read_byte(&map[i]) & (0xFF >> (8 - h))) << rowrem; const uint8_t mask = (pgm_read_byte(&map[i]) & (0xFF >> (8 - h))) << rowrem;
draw_mask(cell + i, mask, color); draw_mask(cell + i, mask, color);
@ -256,7 +256,7 @@ void fb_bitmap_ex(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, const uint8_t *map
// Draw the bitmap slice-by-slice based on how rows of the bitmap intersect with rows of the canvas. // Draw the bitmap slice-by-slice based on how rows of the bitmap intersect with rows of the canvas.
// This could be optimized to walk each row of the canvas only once, but the code would get bigger. // This could be optimized to walk each row of the canvas only once, but the code would get bigger.
while (h > 0) { while (h > 0) {
for (fbpos_t i = 0; i < w; i++) { for (fbpos_t i = xskip; i < w; i++) {
const uint8_t mask = (pgm_read_byte(&map[i + mapc0]) & (0xFF >> rowrem)) << rowrem; const uint8_t mask = (pgm_read_byte(&map[i + mapc0]) & (0xFF >> rowrem)) << rowrem;
draw_mask(cell + i, mask, color); draw_mask(cell + i, mask, color);
} }
@ -264,7 +264,7 @@ void fb_bitmap_ex(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, const uint8_t *map
cell += FBW; cell += FBW;
if (rowrem != 0) { if (rowrem != 0) {
for (fbpos_t i = 0; i < w; i++) { for (fbpos_t i = xskip; i < w; i++) {
const uint8_t mask = (pgm_read_byte(&map[i + mapc0]) & (0xFF << (8 - rowrem))) >> (8 - rowrem); const uint8_t mask = (pgm_read_byte(&map[i + mapc0]) & (0xFF << (8 - rowrem))) >> (8 - rowrem);
draw_mask(cell + i, mask, color); draw_mask(cell + i, mask, color);
} }

Loading…
Cancel
Save