From b9d04daa2696b35e8fe0a8b15d3cbc7b92a171e8 Mon Sep 17 00:00:00 2001 From: kraus Date: Sat, 17 Dec 2022 11:32:08 +0100 Subject: [PATCH] issue #2053 --- csrc/u8g2_line.c | 2 +- sys/sdl/issue2053/Makefile | 12 ++++++++ sys/sdl/issue2053/main.c | 61 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 sys/sdl/issue2053/Makefile create mode 100644 sys/sdl/issue2053/main.c diff --git a/csrc/u8g2_line.c b/csrc/u8g2_line.c index 727f1db3..550e9cf4 100644 --- a/csrc/u8g2_line.c +++ b/csrc/u8g2_line.c @@ -81,7 +81,7 @@ void u8g2_DrawLine(u8g2_t *u8g2, u8g2_uint_t x1, u8g2_uint_t y1, u8g2_uint_t x2, u8g2_DrawPixel(u8g2, x, y); else u8g2_DrawPixel(u8g2, y, x); - err -= (uint8_t)dy; + err -= (u8g2_uint_t)dy; if ( err < 0 ) { y += (u8g2_uint_t)ystep; diff --git a/sys/sdl/issue2053/Makefile b/sys/sdl/issue2053/Makefile new file mode 100644 index 00000000..2dc1ad96 --- /dev/null +++ b/sys/sdl/issue2053/Makefile @@ -0,0 +1,12 @@ +CFLAGS = -g -Wall -I../../../csrc/. `sdl2-config --cflags` + +SRC = $(shell ls ../../../csrc/*.c) $(shell ls ../common/*.c ) main.c + +OBJ = $(SRC:.c=.o) + +helloworld: $(OBJ) + $(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) `sdl2-config --libs` -o u8g2_sdl + +clean: + -rm $(OBJ) u8g2_sdl + diff --git a/sys/sdl/issue2053/main.c b/sys/sdl/issue2053/main.c new file mode 100644 index 00000000..8577c114 --- /dev/null +++ b/sys/sdl/issue2053/main.c @@ -0,0 +1,61 @@ + +#include "u8g2.h" +#include +#include + + +char str1[100]; +char str2[100]; + +u8g2_t u8g2; + +int main(void) +{ + int x, y; + int k; + char s[10] = "123"; + + s[0] += 115; + s[1] += 115; + + + u8g2_SetupBuffer_SDL_128x64_4(&u8g2, &u8g2_cb_r0); + u8x8_InitDisplay(u8g2_GetU8x8(&u8g2)); + u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0); + + + x = 4; // use as height for the box + y = 0; + + for(;;) + { + u8g2_FirstPage(&u8g2); + do + { + u8g2_DrawLine(&u8g2, 0, 0, 255, 255); + u8g2_DrawLine(&u8g2, 0, 2, 256, 256+2); + } while( u8g2_NextPage(&u8g2) ); + + do + { + k = u8g_sdl_get_key(); + } while( k < 0 ); + + if ( k == 273 ) y -= 1; + if ( k == 274 ) y += 1; + if ( k == 276 ) x -= 1; + if ( k == 275 ) x += 1; + + if ( k == 'e' ) y -= 1; + if ( k == 'x' ) y += 1; + if ( k == 's' ) x -= 1; + if ( k == 'd' ) x += 1; + if ( k == 'q' ) break; + + if ( x < 0 ) + x = 0; + + } + return 0; +} +