roox has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/19485 )
Change subject: Implemtented fb_set_p(uint16_t x,uint16_t y). ...................................................................... Implemtented fb_set_p(uint16_t x,uint16_t y). Change-Id: I21e8da1cbf4654b786626b94b197438facef902a --- M src/target/firmware/fb/fb_bw8.c M src/target/firmware/fb/fb_st7558.c M src/target/firmware/include/fb/fb_bw8.h M src/target/firmware/include/fb/framebuffer.h 4 files changed, 38 insertions(+), 22 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/85/19485/1 diff --git a/src/target/firmware/fb/fb_bw8.c b/src/target/firmware/fb/fb_bw8.c index d4ffd21..0fc12ee 100644 --- a/src/target/firmware/fb/fb_bw8.c +++ b/src/target/firmware/fb/fb_bw8.c @@ -156,33 +156,41 @@ framebuffer->cursor_y = y; } -/* just set this pixel to the current front ground color */ -void set_pixel_r(uint16_t x,uint16_t y){ +/* Just set the given pixel to the current front ground color. + * This function does not update the damage rectangle! */ +void fb_bw8_set_pixel(uint16_t x,uint16_t y){ uint8_t *p = fb_bw8->mem + (y/8)*framebuffer->width + x; uint8_t and_mask = 0xff, or_mask = 0x00; - set_fg_pixel(&and_mask, &or_mask, y % 8); - *p = (*p & and_mask)|or_mask; - /* printf("fb_bw8.c: Set: (%u|%u)\n", x, y); */ + set_fg_pixel(&and_mask, &or_mask, y % 8); + *p = (*p & and_mask)|or_mask; + /* printf("fb_bw8_set_pixel: set: (%u|%u)\n", x, y); */ } /* Copy Paste from * http://de.wikipedia.org/wiki/Bresenham-Algorithmus#Kompakte_Variante */ static void fb_bw8_line(int16_t x1,int16_t y1,int16_t x2,int16_t y2){ + fb_limit_fb_range(&x1, &y1); + fb_limit_fb_range(&x2, &y2); fb_bw8_update_damage(x1,y1,x2,y2); - fb_limit_fb_range(&x1, &y1); - fb_limit_fb_range(&x2, &y2); - /* printf("fb_bw8_line from (%u|%u) -> (%u|%u)\n", x1, y1, x2, y2); */ - int16_t dx = abs(x2-x1), dy = -abs(y2-y1); - int16_t sx = x1<x2 ? 1 : -1, sy = y1<y2 ? 1 : -1; - int16_t err = dx+dy, e2; /* error value e_xy */ + /* printf("fb_bw8_line from (%u|%u) -> (%u|%u)\n", x1, y1, x2, y2); */ + int16_t dx = abs(x2-x1), dy = -abs(y2-y1); + int16_t sx = x1<x2 ? 1 : -1, sy = y1<y2 ? 1 : -1; + int16_t err = dx+dy, e2; /* error value e_xy */ - for(;;){ /* loop */ - set_pixel_r(x1,y1); - if (x1==x2 && y1==y2) break; - e2 = 2*err; - if (e2 > dy) { err += dy; x1 += sx; } /* e_xy+e_x > 0 */ - if (e2 < dx) { err += dx; y1 += sy; } /* e_xy+e_y < 0 */ - } + while (1) { + fb_bw8_set_pixel(x1,y1); + if (x1==x2 && y1==y2) break; + e2 = 2*err; + if (e2 > dy) { err += dy; x1 += sx; } /* e_xy+e_x > 0 */ + if (e2 < dx) { err += dx; y1 += sy; } /* e_xy+e_y < 0 */ + } +} + +/* Set the given pixel to the current front ground color and update the damage + * rectangle. */ +void fb_bw8_set_p(uint16_t x,uint16_t y){ + fb_bw8_update_damage(x,y,x+1,y+1); + fb_bw8_set_pixel(x,y); } void fb_bw8_lineto(uint16_t x,uint16_t y){ diff --git a/src/target/firmware/fb/fb_st7558.c b/src/target/firmware/fb/fb_st7558.c index fdcd38f..f09b12b 100644 --- a/src/target/firmware/fb/fb_st7558.c +++ b/src/target/firmware/fb/fb_st7558.c @@ -118,6 +118,7 @@ .clear = fb_bw8_clear, .boxto = fb_bw8_boxto, .lineto = fb_bw8_lineto, + .set_p = fb_bw8_set_p, .putstr = fb_bw8_putstr, .flush = fb_st7558_flush, .width = ST7558_WIDTH, diff --git a/src/target/firmware/include/fb/fb_bw8.h b/src/target/firmware/include/fb/fb_bw8.h index d84f91a..db0b31a 100644 --- a/src/target/firmware/include/fb/fb_bw8.h +++ b/src/target/firmware/include/fb/fb_bw8.h @@ -6,9 +6,9 @@ are common to similar organized displays. */ /* - Sketch of Memory Layout + Sketch of Memory Layout Left Upper Corner of Display - + col0 col2 col1 +------------- @@ -22,7 +22,7 @@ ... Backing store (and internal display memory?) looks like... - + uint8_t mem[] = { A, B, C, .... Q, R, S, ... } We work on a in-memory copy of the framebuffer and only @@ -45,6 +45,7 @@ extern void fb_bw8_clear(); extern void fb_bw8_boxto(uint16_t x,uint16_t y); /* draw a box from cursor to x,y */ extern void fb_bw8_lineto(uint16_t x,uint16_t y); /* draw a line from cursor to x,y */ +extern void fb_bw8_set_p(uint16_t x,uint16_t y); extern int fb_bw8_putstr(char *str,int maxwidth); diff --git a/src/target/firmware/include/fb/framebuffer.h b/src/target/firmware/include/fb/framebuffer.h index e765b36..8a56565 100644 --- a/src/target/firmware/include/fb/framebuffer.h +++ b/src/target/firmware/include/fb/framebuffer.h @@ -8,7 +8,7 @@ /* if a color is "special", then the RGB components most likely don't make sense. Use "special" colours when you have to mask out bits with transparency or you have to encode - colours in a fixed color palette... */ + colours in a fixed color palette ... */ #define FB_COLOR_WHITE 0x00ffffffU #define FB_COLOR_BLACK 0x00000000U @@ -31,6 +31,7 @@ char name[8]; // keep it short! void (*init)(); // (re)initialize void (*clear)(); // clear display + void (*set_p)(uint16_t x,uint16_t y); // set pixel to fg color void (*boxto)(uint16_t x,uint16_t y); // draw box to xy void (*lineto)(uint16_t x,uint16_t y); // draw line to xy int (*putstr)(char *c,int maxwidth); // put text in current font to fb @@ -66,6 +67,11 @@ framebuffer->lineto(x,y); } +static inline void +fb_set_p(uint16_t x,uint16_t y){ + framebuffer->set_p(x,y); +} + static inline int fb_putstr(char *str,int maxwidth){ return framebuffer->putstr(str,maxwidth); -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/19485 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I21e8da1cbf4654b786626b94b197438facef902a Gerrit-Change-Number: 19485 Gerrit-PatchSet: 1 Gerrit-Owner: roox <mar...@gmx.de> Gerrit-MessageType: newchange