ref update

This commit is contained in:
olikraus 2016-04-17 11:06:42 +02:00
parent 3e6e6764da
commit 5e17478209
7 changed files with 142 additions and 3 deletions

View File

@ -104,6 +104,10 @@ class U8G2 : public Print
void setFontMode(uint8_t is_transparent) {u8g2_SetFontMode(&u8g2, is_transparent); }
void setFontDirection(uint8_t dir) {u8g2_SetFontDirection(&u8g2, dir); }
void setFontPosBaseline(u8g2_t *u8g2) { u8g2_SetFontPosBaseline(&u8g2); }
void setFontPosBottom(u8g2_t *u8g2) { u8g2_SetFontPosBottom(&u8g2); }
void setFontPosTop(u8g2_t *u8g2) { u8g2_SetFontPosTop(&u8g2); }
void setFontPosCenter(u8g2_t *u8g2) { u8g2_SetFontPosCenter(&u8g2); }
/*
uint8_t u8g2_IsGlyph(u8g2_t *u8g2, uint16_t requested_encoding);

View File

@ -435,6 +435,11 @@ u8g2_uint_t u8g2_DrawUTF8(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, const char
u8g2_uint_t u8g2_GetStrWidth(u8g2_t *u8g2, const char *s);
u8g2_uint_t u8g2_GetUTF8Width(u8g2_t *u8g2, const char *str);
void u8g2_SetFontPosBaseline(u8g2_t *u8g2);
void u8g2_SetFontPosBottom(u8g2_t *u8g2);
void u8g2_SetFontPosTop(u8g2_t *u8g2);
void u8g2_SetFontPosCenter(u8g2_t *u8g2);
/*==========================================*/
/* u8x8_d_sdl_128x64.c */
@ -446,6 +451,10 @@ void u8g2_SetupBuffer_SDL_128x64_4(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb);
void u8g2_SetupBuffer_TGA_DESC(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb);
void u8g2_SetupBuffer_TGA_LCD(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb);
/*==========================================*/
/* u8x8_d_utf8.c */
/* 96x32 stdout */
void u8g2_SetupBuffer_Utf8(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb);

View File

@ -289,7 +289,7 @@ void u8g2_SetupBuffer_TGA_DESC(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
static uint8_t buf[(XOFFSET+DEFAULT_WIDTH)*8];
u8x8_Setup_TGA_DESC(u8g2_GetU8x8(u8g2));
u8g2_SetupBuffer(u8g2, buf, 1, u8g2_cb);
u8g2_SetupBuffer(u8g2, buf, 1, u8g2_ll_hvline_vertical_top_lsb, u8g2_cb);
}
/*==========================================*/
@ -398,7 +398,7 @@ void u8g2_SetupBuffer_TGA_LCD(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
static uint8_t buf[(DEFAULT_WIDTH/FACTOR)*8];
u8x8_Setup_TGA_LCD(u8g2_GetU8x8(u8g2));
u8g2_SetupBuffer(u8g2, buf, 1, u8g2_cb);
u8g2_SetupBuffer(u8g2, buf, 1, u8g2_ll_hvline_vertical_top_lsb, u8g2_cb);
}

View File

@ -174,6 +174,7 @@ int main(void)
tga_save_png("u8g2_hello_world.png");
/*=========================================*/
/* u8g2_ascent_descent.png */
u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
@ -200,6 +201,37 @@ int main(void)
tga_save_png("u8g2_ascent_descent.png");
/*=========================================*/
/* u8g2_pos_center.png */
u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
u8g2_SetFontPosCenter(&u8g2);
u8g2_FirstPage(&u8g2);
do
{
u8g2_SetFont(&u8g2, u8g2_font_ncenB18_tf);
u8g2_DrawStr(&u8g2, 5, 20, "Agi");
} while( u8g2_NextPage(&u8g2) );
tga_is_transparent = 1;
u8g2_FirstPage(&desc);
do
{
u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
ra(5,20, "x=5, y=20");
u8g2_SetFont(&u8g2, u8g2_font_ncenB18_tf);
/* descent usually is negative */
vm(48,19+u8g2.font_calc_vref(&u8g2)-u8g2_GetDescent(&u8g2), u8g2_GetAscent(&u8g2)-u8g2_GetDescent(&u8g2));
//vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
} while( u8g2_NextPage(&desc) );
tga_is_transparent = 0;
u8g2_SetFontPosBaseline(&u8g2);
tga_save_png("u8g2_pos_center.png");
/*=========================================*/
u8x8_ClearDisplay(u8g2_GetU8x8(&desc));

View File

@ -220,7 +220,11 @@ void u8g2_SetupBuffer_Utf8(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
static uint8_t buf[CHGR_WIDTH*8];
u8x8_Setup_Utf8(u8g2_GetU8x8(u8g2));
u8g2_SetupBuffer(u8g2, buf, 1, u8g2_ll_hvline_horizontal_right_lsb, u8g2_cb);
// u8g2_ll_hvline_vertical_top_lsb
// u8g2_ll_hvline_horizontal_right_lsb
u8g2_SetupBuffer(u8g2, buf, 1, u8g2_ll_hvline_vertical_top_lsb, u8g2_cb);
}
void utf8_show(void)

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,76 @@
#include "u8g2.h"
#include <stdio.h>
u8g2_t u8g2;
int main(void)
{
int x, y;
int k;
int i;
u8g2_SetupBuffer_Utf8(&u8g2, &u8g2_cb_r0);
u8x8_InitDisplay(u8g2_GetU8x8(&u8g2));
u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0);
u8g2_SetFont(&u8g2, u8g2_font_helvB18_tr);
x = 50;
y = 30+0;
#ifdef U8G2_WITH_HVLINE_COUNT
u8g2.hv_cnt = 0UL;
#endif /* U8G2_WITH_HVLINE_COUNT */
/*
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_FirstPage(&u8g2);
i = 0;
do
{
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");
if ( i == 1 )
{
u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y0, 1, 0);
u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y1-1, 1, 0);
u8g2_DrawHVLine(&u8g2, u8g2.user_x1-1, u8g2.user_y1-1, 1, 0);
u8g2_DrawHVLine(&u8g2, u8g2.user_x1-1, u8g2.user_y0, 1, 0);
}
i++;
} 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;
}