This commit is contained in:
kraus 2022-12-17 11:32:08 +01:00
parent f0087e3db1
commit b9d04daa26
3 changed files with 74 additions and 1 deletions

View File

@ -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;

View File

@ -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

61
sys/sdl/issue2053/main.c Normal file
View File

@ -0,0 +1,61 @@
#include "u8g2.h"
#include <stdio.h>
#include <string.h>
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;
}