u8g2 logo

This commit is contained in:
olikraus 2016-01-03 13:20:48 +01:00
parent 9288d95bc5
commit 4dfab87baf
5 changed files with 78 additions and 2 deletions

View File

@ -113,7 +113,13 @@ u8g2_uint_t u8g2_GetUTF8Width(u8g2_t *u8g2, const char *str);
u8g2_uint_t getStrWidth(const char *s) { return u8g2_GetStrWidth(&u8g2, s); }
u8g2_uint_t getUTF8Width(const char *s) { return u8g2_GetUTF8Width(&u8g2, s); }
void drawHVLine(u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) {
u8g2_DrawHVLine(&u8g2, x, y, len, dir); }
void drawHLine(u8g_uint_t x, u8g_uint_t y, u8g_uint_t w) { u8g2_DrawHLine(&u8g, x, y, w); }
void drawVLine(u8g_uint_t x, u8g_uint_t y, u8g_uint_t h) { u8g2_DrawVLine(&u8g, x, y, h); }
/* virtual function for print base class */
size_t write(uint8_t v) {
tx += u8g2_DrawGlyph(&u8g2, tx, ty, v);
return 1;

View File

@ -344,6 +344,9 @@ uint8_t u8g2_NextPage(u8g2_t *u8g2);
/*==========================================*/
/* u8g2_hvline.c */
void u8g2_DrawHVLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir);
void u8g2_DrawHLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len);
void u8g2_DrawVLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len);
void u8g2_DrawPixel(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y);
@ -364,6 +367,7 @@ size_t u8g2_GetFontSize(const uint8_t *font_arg);
#define U8G2_FONT_HEIGHT_MODE_ALL 2
void u8g2_SetFont(u8g2_t *u8g2, const uint8_t *font);
void u8g2_SetFontMode(u8g2_t *u8g2, uint8_t is_transparent);
uint8_t u8g2_IsGlyph(u8g2_t *u8g2, uint16_t requested_encoding);
int8_t u8g2_GetGlyphWidth(u8g2_t *u8g2, uint16_t requested_encoding);

View File

@ -543,9 +543,28 @@ void u8g2_draw_hv_line_4dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uin
*/
void u8g2_DrawHVLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
{
/* Make a call the the callback function. The callback may rotate the hv line */
/* Make a call to the callback function. The callback may rotate the hv line */
/* after rotation this will call u8g2_draw_hv_line_4dir() */
if ( len != 0 )
u8g2->cb->draw_l90(u8g2, x, y, len, dir);
}
void u8g2_DrawHLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len)
{
u8g2_DrawHVLine(u8g2, x, y, len, 0);
}
void u8g2_DrawVLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len)
{
u8g2_DrawHVLine(u8g2, x, y, len, 1);
}
void u8g2_DrawPixel(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y)
{
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
}

View File

@ -42,3 +42,5 @@ u8g vs. u8g2
- begin() must be called (optional in u8g)
- constructor contains name of communicaton interface and
also contains the display orientation as first argument
- u8g2.drawStr90 does not exist use
void u8g2_SetFontDirection(u8g2_t *u8g2, uint8_t dir);

View File

@ -248,6 +248,51 @@ int main(void)
u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
u8g2_FirstPage(&u8g2);
do
{
u8g2_SetFontMode(&u8g2, 1); /* transparent */
u8g2_SetFontDirection(&u8g2, 0);
u8g2_SetFont(&u8g2, u8g2_font_inb24_mf);
u8g2_DrawStr(&u8g2, 0, 30, "U");
u8g2_SetFontDirection(&u8g2, 1);
u8g2_SetFont(&u8g2, u8g2_font_inb30_mr);
u8g2_DrawStr(&u8g2, 21, 8,"8");
u8g2_SetFont(&u8g2, u8g2_font_inb24_mf);
u8g2_SetFontDirection(&u8g2, 0);
u8g2_DrawStr(&u8g2, 51,30,"g");
u8g2_DrawStr(&u8g2, 67,30,"\xb2");
u8g2_DrawHLine(&u8g2, 2, 35, 47);
u8g2_DrawHLine(&u8g2, 3, 36, 47);
u8g2_DrawVLine(&u8g2, 45, 32, 12);
u8g2_DrawVLine(&u8g2, 46, 33, 12);
u8g2_SetFont(&u8g2, u8g2_font_4x6_tr);
u8g2_DrawStr(&u8g2, 1,54,"github.com/olikraus/u8g2");
} while( u8g2_NextPage(&u8g2) );
u8g2_SetFontDirection(&u8g2, 0);
tga_is_transparent = 1;
u8g2_FirstPage(&desc);
do
{
u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
} while( u8g2_NextPage(&desc) );
tga_is_transparent = 0;
tga_save_png("u8g2_logo.png");
/*=========================================*/
u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
return 0;
}