This commit is contained in:
olikraus 2016-05-04 22:22:33 +02:00
parent 6a228306e7
commit afadd9e866
4 changed files with 82 additions and 5 deletions

View File

@ -442,6 +442,7 @@ 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);
void u8g2_SetDrawColor(u8g2_t *u8g2, uint8_t color) U8G2_NOINLINE; /* u8g: u8g_SetColorIndex(u8g_t *u8g, uint8_t idx); */
void u8g2_DrawHBitmap(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t *b);
/*==========================================*/

View File

@ -223,14 +223,14 @@ 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)
{
#ifdef U8G2_WITH_INTERSECTION
if ( x < u8g2->user_x0 )
return;
if ( x > u8g2->user_x1 )
return;
if ( y < u8g2->user_y0 )
return;
if ( y > u8g2->user_y1 )
return;
if ( x < u8g2->user_x0 )
return;
if ( x > u8g2->user_x1 )
return;
#endif /* U8G2_WITH_INTERSECTION */
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
}
@ -251,7 +251,35 @@ void u8g2_SetDrawColor(u8g2_t *u8g2, uint8_t color)
u8g2->draw_color = 1;
}
void u8g2_DrawHBitmap(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t *b)
{
uint8_t mask;
uint8_t color = u8g2->draw_color;
uint8_t ncolor = 1-color;
#ifdef U8G2_WITH_INTERSECTION
if ( u8g2_IsIntersection(u8g2, x, y, x+len, y+1) == 0 )
return;
#endif /* U8G2_WITH_INTERSECTION */
mask = 128;
while(len > 0)
{
if ( *b & mask )
u8g2->draw_color = color;
else
u8g2->draw_color = ncolor;
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
x++;
mask >>= 1;
if ( mask == 0 )
{
mask = 128;
b++;
}
len--;
}
u8g2->draw_color = color;
}

View File

@ -0,0 +1,14 @@
CC = gcc
CFLAGS = -g -W -Wall -Wextra -Wcast-qual -Wno-overlength-strings -Wno-unused-parameter -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,34 @@
#include "u8g2.h"
#include <stdio.h>
u8g2_t u8g2;
uint8_t b[2] = { 0x55, 0x55 };
int main(void)
{
u8g2_SetupBuffer_Utf8(&u8g2, U8G2_R0);
u8g2_InitDisplay(&u8g2);
u8g2_SetPowerSave(&u8g2, 0);
u8g2_SetFont(&u8g2, u8g2_font_6x13_tf);
u8g2_SetFontDirection(&u8g2, 0);
u8g2_FirstPage(&u8g2);
do
{
u8g2_DrawHBitmap(&u8g2, 0, 0, 10, b);
u8g2_DrawStr(&u8g2, 30, 20, "HBitmap");
} while( u8g2_NextPage(&u8g2) );
utf8_show();
return 0;
}