XOR implemented, additional 8 bytes required. issue #56

This commit is contained in:
olikraus 2017-01-07 20:24:20 +01:00
parent c70c8580a0
commit 678b84fa59
3 changed files with 63 additions and 14 deletions

View File

@ -86,7 +86,7 @@
It will consume about 40 bytes more in flash memory of the AVR.
HVLine procedures are also used by the text drawing functions.
*/
#define U8G2_HVLINE_SPEED_OPTIMIZATION
//#define U8G2_HVLINE_SPEED_OPTIMIZATION
/*
The following macro enables all four drawing directions for glyphs and strings.

View File

@ -74,6 +74,7 @@ void u8g2_ll_hvline_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y,
uint16_t offset;
uint8_t *ptr;
uint8_t bit_pos, mask;
uint8_t or_mask, xor_mask;
//assert(x >= u8g2->buf_x0);
//assert(x < u8g2_GetU8x8(u8g2)->display_info->tile_width*8);
@ -86,6 +87,14 @@ void u8g2_ll_hvline_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y,
mask = 1;
mask <<= bit_pos;
or_mask = 0;
xor_mask = 0;
if ( u8g2->draw_color <= 1 )
or_mask = mask;
if ( u8g2->draw_color != 1 )
xor_mask = mask;
offset = y; /* y might be 8 or 16 bit, but we need 16 bit, so use a 16 bit variable */
offset &= ~7;
offset *= u8g2_GetU8x8(u8g2)->display_info->tile_width;
@ -95,14 +104,19 @@ void u8g2_ll_hvline_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y,
if ( dir == 0 )
{
/*
if ( u8g2->draw_color != 0 )
{
*/
do
{
*ptr |= mask;
//*ptr |= mask;
*ptr |= or_mask;
*ptr ^= xor_mask;
ptr++;
len--;
} while( len != 0 );
/*
}
else
{
@ -114,11 +128,15 @@ void u8g2_ll_hvline_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y,
len--;
} while( len != 0 );
}
*/
}
else
{
do
{
*ptr |= or_mask;
*ptr ^= xor_mask;
/*
if ( u8g2->draw_color != 0 )
{
*ptr |= mask;
@ -127,6 +145,7 @@ void u8g2_ll_hvline_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y,
{
*ptr &= ~mask;
}
*/
bit_pos++;
bit_pos &= 7;
@ -154,11 +173,18 @@ void u8g2_ll_hvline_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y,
}
*/
mask = 1;
//mask = 1;
if ( u8g2->draw_color <= 1 )
or_mask = 1;
if ( u8g2->draw_color != 1 )
xor_mask = 1;
}
else
{
mask <<= 1;
//mask <<= 1;
or_mask <<= 1;
xor_mask <<= 1;
}
} while( len != 0 );
}
@ -176,7 +202,7 @@ static void u8g2_draw_pixel_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_u
uint16_t offset;
uint8_t *ptr;
uint8_t bit_pos, mask;
//assert(x >= u8g2->buf_x0);
//assert(x < u8g2_GetU8x8(u8g2)->display_info->tile_width*8);
//assert(y >= u8g2->buf_y0);
@ -194,8 +220,14 @@ static void u8g2_draw_pixel_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_u
ptr = u8g2->tile_buf_ptr;
ptr += offset;
ptr += x;
if ( u8g2->draw_color <= 1 )
*ptr |= mask;
if ( u8g2->draw_color != 1 )
*ptr ^= mask;
/*
if ( u8g2->draw_color != 0 )
{
*ptr |= mask;
@ -204,7 +236,8 @@ static void u8g2_draw_pixel_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_u
{
mask ^= 255;
*ptr &= mask;
}
}
*/
}
/*
@ -273,7 +306,13 @@ static void u8g2_draw_pixel_horizontal_right_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8
ptr = u8g2->tile_buf_ptr;
ptr += offset;
if ( u8g2->draw_color <= 1 )
*ptr |= mask;
if ( u8g2->draw_color != 1 )
*ptr ^= mask;
/*
if ( u8g2->draw_color != 0 )
{
*ptr |= mask;
@ -282,7 +321,8 @@ static void u8g2_draw_pixel_horizontal_right_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8
{
mask ^= 255;
*ptr &= mask;
}
}
*/
}
/*

View File

@ -142,17 +142,26 @@ void testXOR(uint8_t x)
u8g2.firstPage();
do {
/* Solid mode with XOR drawing: Does not make much sense */
u8g2.setFontMode(0);
u8g2.setDrawColor(1);
u8g2.drawBox(10, 8, 10, 10);
u8g2.drawBox(40, 20, 30, 10);
u8g2.drawBox(100, 8, 4, 20);
u8g2.drawStr(x,26, "XOR Test");
u8g2.drawBox(40, 20, 30, 12);
u8g2.drawBox(100, 8, 4, 22);
u8g2.setDrawColor(2);
u8g2.drawStr(x,26, "XOR Test");
u8g2.drawHLine(0, 29, 128);
/* Transparent mdoe with XOR drawing: looks good */
u8g2.setFontMode(1);
u8g2.setDrawColor(1);
u8g2.drawBox(10, 8+32, 10, 10);
u8g2.drawBox(40, 20+32, 30, 10);
u8g2.drawBox(100, 8+32, 4, 20);
u8g2.drawBox(40, 20+32, 30, 12);
u8g2.drawBox(100, 8+32, 4, 22);
u8g2.setDrawColor(2);
u8g2.drawStr(x,26+32, "XOR Test");
u8g2.drawHLine(0, 29+32, 128);
} while ( u8g2.nextPage() );