fixed str line handling

This commit is contained in:
olikraus 2016-05-22 14:30:05 +02:00
parent 0b7285a5ff
commit 4cabe1d305
2 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,14 @@
CC = gcc
CFLAGS = -g -Wall -I../../../csrc/.
SRC = $(shell ls ../../../csrc/*.c) $(shell ls ../common/*.c ) main.c
OBJ = $(SRC:.c=.o)
u8g2_utf8: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) -o u8g2_utf8
clean:
-rm $(OBJ) u8g2_utf8

View File

@ -0,0 +1,45 @@
#include "u8g2.h"
#include <stdio.h>
u8g2_t u8g2;
const char *str = "abc\ndef";
int main(void)
{
uint8_t i, cnt;
u8g2_SetupBuffer_Utf8(&u8g2, &u8g2_cb_r0);
u8x8_InitDisplay(u8g2_GetU8x8(&u8g2));
u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0);
u8g2_SetFont(&u8g2, u8g2_font_helvB10_tr);
#ifdef U8G2_WITH_HVLINE_COUNT
u8g2.hv_cnt = 0UL;
#endif /* U8G2_WITH_HVLINE_COUNT */
u8g2_FirstPage(&u8g2);
i = 0;
cnt = u8x8_GetStringLineCnt(str);
do
{
for( i = 0; i < cnt; i++ )
{
u8g2_DrawStr(&u8g2, 0, i*12+11, u8x8_GetStringLine(i, str));
}
} while( u8g2_NextPage(&u8g2) );
#ifdef U8G2_WITH_HVLINE_COUNT
printf("hv cnt: %ld\n", u8g2.hv_cnt);
#endif /* U8G2_WITH_HVLINE_COUNT */
utf8_show();
return 0;
}