This commit is contained in:
kraus 2018-12-22 13:04:20 +01:00
parent 94cd8850ce
commit abb901a8c6
6 changed files with 147 additions and 1 deletions

View File

@ -1203,6 +1203,7 @@ uint8_t u8g2_UserInterfaceInputValue(u8g2_t *u8g2, const char *title, const char
/* u8x8_d_sdl_128x64.c */
void u8g2_SetupBuffer_SDL_128x64(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb);
void u8g2_SetupBuffer_SDL_128x64_4(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb);
void u8g2_SetupBuffer_SDL_128x64_1(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb);
/*==========================================*/
/* u8x8_d_tga.c */

View File

@ -158,7 +158,7 @@
//U8G2_ST7920_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0
//U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE);
//U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8);
U8G2_ST7920_128X64_1_2ND_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8);
//U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8);
//U8G2_ST7565_EA_DOGM128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
//U8G2_ST7565_EA_DOGM128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
//U8G2_ST7565_64128N_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);

View File

@ -390,6 +390,15 @@ void u8g2_SetupBuffer_SDL_128x64_4(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
u8g2_SetupBuffer(u8g2, buf, 3, u8g2_ll_hvline_vertical_top_lsb, u8g2_cb);
}
void u8g2_SetupBuffer_SDL_128x64_1(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
{
static uint8_t buf[128];
u8x8_Setup_SDL_128x64(u8g2_GetU8x8(u8g2));
u8g2_SetupBuffer(u8g2, buf, 1, u8g2_ll_hvline_vertical_top_lsb, u8g2_cb);
}
void u8x8_Setup_SDL_240x160(u8x8_t *u8x8)
{

12
sys/sdl/tile_row/Makefile Normal file
View File

@ -0,0 +1,12 @@
CFLAGS = -g -Wall -I../../../csrc/. `sdl2-config --cflags` -fsanitize=address -fsanitize=undefined -fsanitize=bounds-strict -fsanitize=object-size
SRC = $(shell ls ../../../csrc/*.c) ../../bitmap/common/u8x8_d_bitmap.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

80
sys/sdl/tile_row/main.c Normal file
View File

@ -0,0 +1,80 @@
#include "u8g2.h"
#include <stdio.h>
u8g2_t u8g2;
int main(void)
{
int x, y;
int k;
int i;
u8g2_SetupBuffer_SDL_128x64_1(&u8g2, &u8g2_cb_r0);
u8x8_InitDisplay(u8g2_GetU8x8(&u8g2));
u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0);
x = 2;
y = 8;
for(;;)
{
/*
u8g2_ClearBuffer(&u8g2);
u8g2_SetFontDirection(&u8g2, 0);
u8g2_DrawStr(&u8g2, x, y, "ABC");
u8g2_SetFontDirection(&u8g2, 1);
u8g2_DrawStr(&u8g2, x, y, "abc");
u8g2_SetFontDirection(&u8g2, 2);
u8g2_DrawStr(&u8g2, x, y, "abc");
u8g2_SetFontDirection(&u8g2, 3);
u8g2_DrawStr(&u8g2, x, y, "abc");
u8g2_SendBuffer(&u8g2);
*/
u8g2_SetBufferCurrTileRow(&u8g2, 0);
u8g2_ClearBuffer(&u8g2);
u8g2_SetFont(&u8g2, u8g2_font_helvB08_tr);
u8g2_DrawStr(&u8g2, x, y, "ABC def");
u8g2_SendBuffer(&u8g2);
u8g2_SetBufferCurrTileRow(&u8g2, 4);
u8g2_SendBuffer(&u8g2);
do
{
k = u8g_sdl_get_key();
} while( k < 0 );
if ( k == 273 ) y -= 7;
if ( k == 274 ) y += 7;
if ( k == 276 ) x -= 7;
if ( k == 275 ) x += 7;
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 ( k == 't' )
u8x8_SaveBitmapTGA(u8g2_GetU8x8(&u8g2), "screenshot.tga");
}
//u8x8_Set8x8Font(u8g2_GetU8x8(&u8g2), bdf_font);
//u8x8_Draw8x8String(u8g2_GetU8x8(&u8g2), 0, 0, "Hello World!");
return 0;
}

View File

@ -1006,9 +1006,53 @@ int main(void)
tga_is_transparent = 0;
u8g2_SetFontPosBaseline(&u8g2);
u8g2_SetFontDirection(&u8g2, 0);
u8g2_SetMaxClipWindow(&u8g2);
tga_save_png("u8g2_clip_window.png");
/*=========================================*/
/* u8g2_tile_row.png */
u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
u8g2_FirstPage(&u8g2);
do
{
} while( u8g2_NextPage(&u8g2) );
u8g2_SetFontPosBaseline(&u8g2);
u8g2_SetDrawColor(&u8g2, 1);
u8g2_SetBufferCurrTileRow(&u8g2, 0);
u8g2_SetFont(&u8g2, u8g2_font_helvB08_tr);
u8g2_DrawStr(&u8g2, 2, 8, "abcdefg");
u8g2_SetBufferCurrTileRow(&u8g2, 2);
u8g2_SendBuffer(&u8g2);
u8g2_SetBufferCurrTileRow(&u8g2, 4);
u8g2_SendBuffer(&u8g2);
tga_is_transparent = 1;
u8g2_FirstPage(&desc);
do
{
u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
ra(2,8, "(2, 8)");
ra(2,24, "(2, 24)");
ra(2,40, "(2, 40)");
//hm(10, 35, 75);
//vm(88, 29, 20);
//vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
} while( u8g2_NextPage(&desc) );
tga_is_transparent = 0;
u8g2_SetFontPosBaseline(&u8g2);
u8g2_SetFontDirection(&u8g2, 0);
tga_save_png("u8g2_tile_row.png");
/*=========================================*/
u8x8_ClearDisplay(u8g2_GetU8x8(&desc));