Change in osmocom-bb[master]: firmware/fb: Implemtented fb_bw8_line and fb_set_p(uint16_t x, uint16_...

2020-08-06 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/19483 )

Change subject: firmware/fb: Implemtented fb_bw8_line and fb_set_p(uint16_t 
x,uint16_t y)
..

firmware/fb: Implemtented fb_bw8_line and fb_set_p(uint16_t x,uint16_t y)

Change-Id: Id8856ace2a31ba4ebcd04746e0c96c23a679cc40
---
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, 60 insertions(+), 19 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/src/target/firmware/fb/fb_bw8.c b/src/target/firmware/fb/fb_bw8.c
index ffb59d8..0fc12ee 100644
--- a/src/target/firmware/fb/fb_bw8.c
+++ b/src/target/firmware/fb/fb_bw8.c
@@ -22,6 +22,7 @@
  *
  */

+#include 
 #include 
 #include 

@@ -51,7 +52,7 @@
uint16_t x2,uint16_t y2  /* right lower corner (inclusive) */
 ){
fb_sanitize_box(,,,);
-
+
x2++; /* see definition of fb_bw8->damage_x2/y2 */
y2++;

@@ -86,17 +87,6 @@
 #endif
 }

-static void fb_bw8_line(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2){
-   fb_sanitize_box(,,,);
-   /* FIXME : this is currently unimplemented! */
-}
-
-void fb_bw8_lineto(uint16_t x,uint16_t y){
-   fb_bw8_line(framebuffer->cursor_x,framebuffer->cursor_y,x,y);
-   framebuffer->cursor_x = x;
-   framebuffer->cursor_y = y;
-}
-
 /* depending on color set (add to or_mask) or clear
(remove from and_mask) bit number bitnum */
 static void set_pixel(uint8_t *and_mask,
@@ -166,13 +156,56 @@
framebuffer->cursor_y = 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(_mask, _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(, );
+   fb_limit_fb_range(, );
+   fb_bw8_update_damage(x1,y1,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 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){
+   fb_bw8_line(framebuffer->cursor_x,framebuffer->cursor_y,x,y);
+   framebuffer->cursor_x = x;
+   framebuffer->cursor_y = y;
+}
+
+
 /* this is the most ridiculous function ever, because it has to
fiddle with two braindead bitmaps at once, both being
organized differently */

 /* draw text at current position, with current font and colours up
to a width of maxwidth pixels, return pixelwidth consumed */
-
 int
 fb_bw8_putstr(char *str,int maxwidth){
const struct fb_font *font = fb_fonts[framebuffer->font];
@@ -187,7 +220,7 @@
int bitmap_offs,bitmap_bit; // offset inside bitmap, bit number of 
pixel
int fb8_offs;   // offset to current pixel in 
framebuffer
uint8_t and_mask,or_mask;   // to draw on framebuffer
-   uint8_t *p; // pointer into framebuffer memorya
+   uint8_t *p; // pointer into framebuffer memory
int total_w;// total width

/* center, if maxwidth < 0 */
@@ -251,7 +284,7 @@
bitmap_y = fchr->bbox_h -
(char_y - fchr->bbox_y) - 1;

-   fb8_offs = framebuffer->cursor_x +
+   fb8_offs = framebuffer->cursor_x +
char_x + (y/8)*framebuffer->width;

and_mask = 0xff;
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
--- 

Change in osmocom-bb[master]: firmware/fb: Implemtented fb_bw8_line and fb_set_p(uint16_t x, uint16_...

2020-08-06 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/19483 )

Change subject: firmware/fb: Implemtented fb_bw8_line and fb_set_p(uint16_t 
x,uint16_t y)
..


Patch Set 3: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/19483
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: Id8856ace2a31ba4ebcd04746e0c96c23a679cc40
Gerrit-Change-Number: 19483
Gerrit-PatchSet: 3
Gerrit-Owner: roox 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Thu, 06 Aug 2020 16:38:08 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmocom-bb[master]: firmware/fb: Implemtented fb_bw8_line and fb_set_p(uint16_t x, uint16_...

2020-08-04 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/19483 )

Change subject: firmware/fb: Implemtented fb_bw8_line and fb_set_p(uint16_t 
x,uint16_t y)
..


Patch Set 3: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/19483
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: Id8856ace2a31ba4ebcd04746e0c96c23a679cc40
Gerrit-Change-Number: 19483
Gerrit-PatchSet: 3
Gerrit-Owner: roox 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Tue, 04 Aug 2020 21:02:40 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmocom-bb[master]: firmware/fb: Implemtented fb_bw8_line and fb_set_p(uint16_t x, uint16_...

2020-08-04 Thread roox
Hello laforge, Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/osmocom-bb/+/19483

to look at the new patch set (#3).

Change subject: firmware/fb: Implemtented fb_bw8_line and fb_set_p(uint16_t 
x,uint16_t y)
..

firmware/fb: Implemtented fb_bw8_line and fb_set_p(uint16_t x,uint16_t y)

Change-Id: Id8856ace2a31ba4ebcd04746e0c96c23a679cc40
---
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, 60 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/83/19483/3
--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/19483
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: Id8856ace2a31ba4ebcd04746e0c96c23a679cc40
Gerrit-Change-Number: 19483
Gerrit-PatchSet: 3
Gerrit-Owner: roox 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: newpatchset