test code for issue #1217

This commit is contained in:
kraus 2020-06-11 19:13:21 +02:00
parent 04f7c64dc9
commit 99b63a38a3
2 changed files with 73 additions and 0 deletions

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/issue1217/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_DrawBox(&u8g2, 10, 10+y, 20, x);
u8g2_DrawFrame(&u8g2, 34, 10+y, 20, x);
} 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;
}