Naming and coding style convention, new linter tool. (#945)

* Makefile, Scripts: new linter
* About: remove ID from IC
* Firmware: remove double define for DIVC/DIVR
* Scripts: check folder names too. Docker: replace syntax check with make lint.
* Reformat Sources and Migrate to new file naming convention
* Docker: symlink clang-format-12 to clang-format
* Add coding style guide
This commit is contained in:
あく
2022-01-05 19:10:18 +03:00
committed by GitHub
parent c98e54da10
commit 389ff92cc1
899 changed files with 379242 additions and 373418 deletions
+4187 -1458
View File
File diff suppressed because it is too large Load Diff
+137 -147
View File
@@ -35,9 +35,8 @@
#include "u8g2.h"
void u8g2_SetBitmapMode(u8g2_t *u8g2, uint8_t is_transparent) {
u8g2->bitmap_transparency = is_transparent;
void u8g2_SetBitmapMode(u8g2_t* u8g2, uint8_t is_transparent) {
u8g2->bitmap_transparency = is_transparent;
}
/*
@@ -47,172 +46,163 @@ void u8g2_SetBitmapMode(u8g2_t *u8g2, uint8_t is_transparent) {
Only draw pixels which are set.
*/
void u8g2_DrawHorizontalBitmap(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, const uint8_t *b)
{
uint8_t mask;
uint8_t color = u8g2->draw_color;
uint8_t ncolor = (color == 0 ? 1 : 0);
void u8g2_DrawHorizontalBitmap(
u8g2_t* u8g2,
u8g2_uint_t x,
u8g2_uint_t y,
u8g2_uint_t len,
const uint8_t* b) {
uint8_t mask;
uint8_t color = u8g2->draw_color;
uint8_t ncolor = (color == 0 ? 1 : 0);
#ifdef U8G2_WITH_INTERSECTION
if ( u8g2_IsIntersection(u8g2, x, y, x+len, y+1) == 0 )
return;
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;
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
} else if ( u8g2->bitmap_transparency == 0 ) {
u8g2->draw_color = ncolor;
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
}
x++;
mask >>= 1;
if ( mask == 0 )
{
mask = 128;
b++;
mask = 128;
while(len > 0) {
if(*b & mask) {
u8g2->draw_color = color;
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
} else if(u8g2->bitmap_transparency == 0) {
u8g2->draw_color = ncolor;
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
}
x++;
mask >>= 1;
if(mask == 0) {
mask = 128;
b++;
}
len--;
}
len--;
}
u8g2->draw_color = color;
u8g2->draw_color = color;
}
/* u8glib compatible bitmap draw function */
void u8g2_DrawBitmap(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t cnt, u8g2_uint_t h, const uint8_t *bitmap)
{
u8g2_uint_t w;
w = cnt;
w *= 8;
void u8g2_DrawBitmap(
u8g2_t* u8g2,
u8g2_uint_t x,
u8g2_uint_t y,
u8g2_uint_t cnt,
u8g2_uint_t h,
const uint8_t* bitmap) {
u8g2_uint_t w;
w = cnt;
w *= 8;
#ifdef U8G2_WITH_INTERSECTION
if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
return;
if(u8g2_IsIntersection(u8g2, x, y, x + w, y + h) == 0) return;
#endif /* U8G2_WITH_INTERSECTION */
while( h > 0 )
{
u8g2_DrawHorizontalBitmap(u8g2, x, y, w, bitmap);
bitmap += cnt;
y++;
h--;
}
}
void u8g2_DrawHXBM(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, const uint8_t *b)
{
uint8_t mask;
uint8_t color = u8g2->draw_color;
uint8_t ncolor = (color == 0 ? 1 : 0);
#ifdef U8G2_WITH_INTERSECTION
if ( u8g2_IsIntersection(u8g2, x, y, x+len, y+1) == 0 )
return;
#endif /* U8G2_WITH_INTERSECTION */
mask = 1;
while(len > 0) {
if ( *b & mask ) {
u8g2->draw_color = color;
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
} else if ( u8g2->bitmap_transparency == 0 ) {
u8g2->draw_color = ncolor;
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
while(h > 0) {
u8g2_DrawHorizontalBitmap(u8g2, x, y, w, bitmap);
bitmap += cnt;
y++;
h--;
}
x++;
mask <<= 1;
if ( mask == 0 )
{
mask = 1;
b++;
}
len--;
}
u8g2->draw_color = color;
}
void u8g2_DrawXBM(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, const uint8_t *bitmap)
{
u8g2_uint_t blen;
blen = w;
blen += 7;
blen >>= 3;
void u8g2_DrawHXBM(u8g2_t* u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, const uint8_t* b) {
uint8_t mask;
uint8_t color = u8g2->draw_color;
uint8_t ncolor = (color == 0 ? 1 : 0);
#ifdef U8G2_WITH_INTERSECTION
if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
return;
if(u8g2_IsIntersection(u8g2, x, y, x + len, y + 1) == 0) return;
#endif /* U8G2_WITH_INTERSECTION */
while( h > 0 )
{
u8g2_DrawHXBM(u8g2, x, y, w, bitmap);
bitmap += blen;
y++;
h--;
}
}
void u8g2_DrawHXBMP(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, const uint8_t *b)
{
uint8_t mask;
uint8_t color = u8g2->draw_color;
uint8_t ncolor = (color == 0 ? 1 : 0);
#ifdef U8G2_WITH_INTERSECTION
if ( u8g2_IsIntersection(u8g2, x, y, x+len, y+1) == 0 )
return;
#endif /* U8G2_WITH_INTERSECTION */
mask = 1;
while(len > 0)
{
if( u8x8_pgm_read(b) & mask ) {
u8g2->draw_color = color;
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
} else if( u8g2->bitmap_transparency == 0 ) {
u8g2->draw_color = ncolor;
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
mask = 1;
while(len > 0) {
if(*b & mask) {
u8g2->draw_color = color;
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
} else if(u8g2->bitmap_transparency == 0) {
u8g2->draw_color = ncolor;
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
}
x++;
mask <<= 1;
if(mask == 0) {
mask = 1;
b++;
}
len--;
}
x++;
mask <<= 1;
if ( mask == 0 )
{
mask = 1;
b++;
}
len--;
}
u8g2->draw_color = color;
u8g2->draw_color = color;
}
void u8g2_DrawXBMP(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, const uint8_t *bitmap)
{
u8g2_uint_t blen;
blen = w;
blen += 7;
blen >>= 3;
void u8g2_DrawXBM(
u8g2_t* u8g2,
u8g2_uint_t x,
u8g2_uint_t y,
u8g2_uint_t w,
u8g2_uint_t h,
const uint8_t* bitmap) {
u8g2_uint_t blen;
blen = w;
blen += 7;
blen >>= 3;
#ifdef U8G2_WITH_INTERSECTION
if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
return;
if(u8g2_IsIntersection(u8g2, x, y, x + w, y + h) == 0) return;
#endif /* U8G2_WITH_INTERSECTION */
while( h > 0 )
{
u8g2_DrawHXBMP(u8g2, x, y, w, bitmap);
bitmap += blen;
y++;
h--;
}
while(h > 0) {
u8g2_DrawHXBM(u8g2, x, y, w, bitmap);
bitmap += blen;
y++;
h--;
}
}
void u8g2_DrawHXBMP(u8g2_t* u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, const uint8_t* b) {
uint8_t mask;
uint8_t color = u8g2->draw_color;
uint8_t ncolor = (color == 0 ? 1 : 0);
#ifdef U8G2_WITH_INTERSECTION
if(u8g2_IsIntersection(u8g2, x, y, x + len, y + 1) == 0) return;
#endif /* U8G2_WITH_INTERSECTION */
mask = 1;
while(len > 0) {
if(u8x8_pgm_read(b) & mask) {
u8g2->draw_color = color;
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
} else if(u8g2->bitmap_transparency == 0) {
u8g2->draw_color = ncolor;
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
}
x++;
mask <<= 1;
if(mask == 0) {
mask = 1;
b++;
}
len--;
}
u8g2->draw_color = color;
}
void u8g2_DrawXBMP(
u8g2_t* u8g2,
u8g2_uint_t x,
u8g2_uint_t y,
u8g2_uint_t w,
u8g2_uint_t h,
const uint8_t* bitmap) {
u8g2_uint_t blen;
blen = w;
blen += 7;
blen >>= 3;
#ifdef U8G2_WITH_INTERSECTION
if(u8g2_IsIntersection(u8g2, x, y, x + w, y + h) == 0) return;
#endif /* U8G2_WITH_INTERSECTION */
while(h > 0) {
u8g2_DrawHXBMP(u8g2, x, y, w, bitmap);
bitmap += blen;
y++;
h--;
}
}
+131 -138
View File
@@ -39,169 +39,162 @@
draw a filled box
restriction: does not work for w = 0 or h = 0
*/
void u8g2_DrawBox(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h)
{
void u8g2_DrawBox(u8g2_t* u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h) {
#ifdef U8G2_WITH_INTERSECTION
if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
return;
if(u8g2_IsIntersection(u8g2, x, y, x + w, y + h) == 0) return;
#endif /* U8G2_WITH_INTERSECTION */
while( h != 0 )
{
u8g2_DrawHVLine(u8g2, x, y, w, 0);
y++;
h--;
}
while(h != 0) {
u8g2_DrawHVLine(u8g2, x, y, w, 0);
y++;
h--;
}
}
/*
draw a frame (empty box)
restriction: does not work for w = 0 or h = 0
ToDo:
pixel in the corners are drawn twice. This could be optimized.
*/
void u8g2_DrawFrame(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h)
{
u8g2_uint_t xtmp = x;
void u8g2_DrawFrame(u8g2_t* u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h) {
u8g2_uint_t xtmp = x;
#ifdef U8G2_WITH_INTERSECTION
if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
return;
if(u8g2_IsIntersection(u8g2, x, y, x + w, y + h) == 0) return;
#endif /* U8G2_WITH_INTERSECTION */
u8g2_DrawHVLine(u8g2, x, y, w, 0);
u8g2_DrawHVLine(u8g2, x, y, h, 1);
x+=w;
x--;
u8g2_DrawHVLine(u8g2, x, y, h, 1);
y+=h;
y--;
u8g2_DrawHVLine(u8g2, xtmp, y, w, 0);
u8g2_DrawHVLine(u8g2, x, y, w, 0);
u8g2_DrawHVLine(u8g2, x, y, h, 1);
x += w;
x--;
u8g2_DrawHVLine(u8g2, x, y, h, 1);
y += h;
y--;
u8g2_DrawHVLine(u8g2, xtmp, y, w, 0);
}
void u8g2_DrawRBox(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, u8g2_uint_t r)
{
u8g2_uint_t xl, yu;
u8g2_uint_t yl, xr;
#ifdef U8G2_WITH_INTERSECTION
if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
return;
#endif /* U8G2_WITH_INTERSECTION */
xl = x;
xl += r;
yu = y;
yu += r;
xr = x;
xr += w;
xr -= r;
xr -= 1;
yl = y;
yl += h;
yl -= r;
yl -= 1;
u8g2_DrawDisc(u8g2, xl, yu, r, U8G2_DRAW_UPPER_LEFT);
u8g2_DrawDisc(u8g2, xr, yu, r, U8G2_DRAW_UPPER_RIGHT);
u8g2_DrawDisc(u8g2, xl, yl, r, U8G2_DRAW_LOWER_LEFT);
u8g2_DrawDisc(u8g2, xr, yl, r, U8G2_DRAW_LOWER_RIGHT);
{
u8g2_uint_t ww, hh;
ww = w;
ww -= r;
ww -= r;
xl++;
yu++;
if ( ww >= 3 )
{
ww -= 2;
u8g2_DrawBox(u8g2, xl, y, ww, r+1);
u8g2_DrawBox(u8g2, xl, yl, ww, r+1);
}
hh = h;
hh -= r;
hh -= r;
//h--;
if ( hh >= 3 )
{
hh -= 2;
u8g2_DrawBox(u8g2, x, yu, w, hh);
}
}
}
void u8g2_DrawRFrame(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, u8g2_uint_t r)
{
u8g2_uint_t xl, yu;
#ifdef U8G2_WITH_INTERSECTION
if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
return;
#endif /* U8G2_WITH_INTERSECTION */
xl = x;
xl += r;
yu = y;
yu += r;
{
void u8g2_DrawRBox(
u8g2_t* u8g2,
u8g2_uint_t x,
u8g2_uint_t y,
u8g2_uint_t w,
u8g2_uint_t h,
u8g2_uint_t r) {
u8g2_uint_t xl, yu;
u8g2_uint_t yl, xr;
#ifdef U8G2_WITH_INTERSECTION
if(u8g2_IsIntersection(u8g2, x, y, x + w, y + h) == 0) return;
#endif /* U8G2_WITH_INTERSECTION */
xl = x;
xl += r;
yu = y;
yu += r;
xr = x;
xr += w;
xr -= r;
xr -= 1;
yl = y;
yl += h;
yl -= r;
yl -= r;
yl -= 1;
u8g2_DrawCircle(u8g2, xl, yu, r, U8G2_DRAW_UPPER_LEFT);
u8g2_DrawCircle(u8g2, xr, yu, r, U8G2_DRAW_UPPER_RIGHT);
u8g2_DrawCircle(u8g2, xl, yl, r, U8G2_DRAW_LOWER_LEFT);
u8g2_DrawCircle(u8g2, xr, yl, r, U8G2_DRAW_LOWER_RIGHT);
}
u8g2_DrawDisc(u8g2, xl, yu, r, U8G2_DRAW_UPPER_LEFT);
u8g2_DrawDisc(u8g2, xr, yu, r, U8G2_DRAW_UPPER_RIGHT);
u8g2_DrawDisc(u8g2, xl, yl, r, U8G2_DRAW_LOWER_LEFT);
u8g2_DrawDisc(u8g2, xr, yl, r, U8G2_DRAW_LOWER_RIGHT);
{
u8g2_uint_t ww, hh;
{
u8g2_uint_t ww, hh;
ww = w;
ww -= r;
ww -= r;
hh = h;
hh -= r;
hh -= r;
xl++;
yu++;
if ( ww >= 3 )
{
ww -= 2;
h--;
u8g2_DrawHLine(u8g2, xl, y, ww);
u8g2_DrawHLine(u8g2, xl, y+h, ww);
ww = w;
ww -= r;
ww -= r;
xl++;
yu++;
if(ww >= 3) {
ww -= 2;
u8g2_DrawBox(u8g2, xl, y, ww, r + 1);
u8g2_DrawBox(u8g2, xl, yl, ww, r + 1);
}
hh = h;
hh -= r;
hh -= r;
//h--;
if(hh >= 3) {
hh -= 2;
u8g2_DrawBox(u8g2, x, yu, w, hh);
}
}
if ( hh >= 3 )
{
hh -= 2;
w--;
u8g2_DrawVLine(u8g2, x, yu, hh);
u8g2_DrawVLine(u8g2, x+w, yu, hh);
}
}
}
void u8g2_DrawRFrame(
u8g2_t* u8g2,
u8g2_uint_t x,
u8g2_uint_t y,
u8g2_uint_t w,
u8g2_uint_t h,
u8g2_uint_t r) {
u8g2_uint_t xl, yu;
#ifdef U8G2_WITH_INTERSECTION
if(u8g2_IsIntersection(u8g2, x, y, x + w, y + h) == 0) return;
#endif /* U8G2_WITH_INTERSECTION */
xl = x;
xl += r;
yu = y;
yu += r;
{
u8g2_uint_t yl, xr;
xr = x;
xr += w;
xr -= r;
xr -= 1;
yl = y;
yl += h;
yl -= r;
yl -= 1;
u8g2_DrawCircle(u8g2, xl, yu, r, U8G2_DRAW_UPPER_LEFT);
u8g2_DrawCircle(u8g2, xr, yu, r, U8G2_DRAW_UPPER_RIGHT);
u8g2_DrawCircle(u8g2, xl, yl, r, U8G2_DRAW_LOWER_LEFT);
u8g2_DrawCircle(u8g2, xr, yl, r, U8G2_DRAW_LOWER_RIGHT);
}
{
u8g2_uint_t ww, hh;
ww = w;
ww -= r;
ww -= r;
hh = h;
hh -= r;
hh -= r;
xl++;
yu++;
if(ww >= 3) {
ww -= 2;
h--;
u8g2_DrawHLine(u8g2, xl, y, ww);
u8g2_DrawHLine(u8g2, xl, y + h, ww);
}
if(hh >= 3) {
hh -= 2;
w--;
u8g2_DrawVLine(u8g2, x, yu, hh);
u8g2_DrawVLine(u8g2, x + w, yu, hh);
}
}
}
+114 -117
View File
@@ -37,30 +37,28 @@
#include <string.h>
/*============================================*/
void u8g2_ClearBuffer(u8g2_t *u8g2)
{
size_t cnt;
cnt = u8g2_GetU8x8(u8g2)->display_info->tile_width;
cnt *= u8g2->tile_buf_height;
cnt *= 8;
memset(u8g2->tile_buf_ptr, 0, cnt);
void u8g2_ClearBuffer(u8g2_t* u8g2) {
size_t cnt;
cnt = u8g2_GetU8x8(u8g2)->display_info->tile_width;
cnt *= u8g2->tile_buf_height;
cnt *= 8;
memset(u8g2->tile_buf_ptr, 0, cnt);
}
/*============================================*/
static void u8g2_send_tile_row(u8g2_t *u8g2, uint8_t src_tile_row, uint8_t dest_tile_row)
{
uint8_t *ptr;
uint16_t offset;
uint8_t w;
w = u8g2_GetU8x8(u8g2)->display_info->tile_width;
offset = src_tile_row;
ptr = u8g2->tile_buf_ptr;
offset *= w;
offset *= 8;
ptr += offset;
u8x8_DrawTile(u8g2_GetU8x8(u8g2), 0, dest_tile_row, w, ptr);
static void u8g2_send_tile_row(u8g2_t* u8g2, uint8_t src_tile_row, uint8_t dest_tile_row) {
uint8_t* ptr;
uint16_t offset;
uint8_t w;
w = u8g2_GetU8x8(u8g2)->display_info->tile_width;
offset = src_tile_row;
ptr = u8g2->tile_buf_ptr;
offset *= w;
offset *= 8;
ptr += offset;
u8x8_DrawTile(u8g2_GetU8x8(u8g2), 0, dest_tile_row, w, ptr);
}
/*
@@ -68,72 +66,61 @@ static void u8g2_send_tile_row(u8g2_t *u8g2, uint8_t src_tile_row, uint8_t dest_
For most displays, this will make the content visible to the user.
Some displays (like the SSD1606) require a u8x8_RefreshDisplay()
*/
static void u8g2_send_buffer(u8g2_t *u8g2) U8X8_NOINLINE;
static void u8g2_send_buffer(u8g2_t *u8g2)
{
uint8_t src_row;
uint8_t src_max;
uint8_t dest_row;
uint8_t dest_max;
static void u8g2_send_buffer(u8g2_t* u8g2) U8X8_NOINLINE;
static void u8g2_send_buffer(u8g2_t* u8g2) {
uint8_t src_row;
uint8_t src_max;
uint8_t dest_row;
uint8_t dest_max;
src_row = 0;
src_max = u8g2->tile_buf_height;
dest_row = u8g2->tile_curr_row;
dest_max = u8g2_GetU8x8(u8g2)->display_info->tile_height;
do
{
u8g2_send_tile_row(u8g2, src_row, dest_row);
src_row++;
dest_row++;
} while( src_row < src_max && dest_row < dest_max );
src_row = 0;
src_max = u8g2->tile_buf_height;
dest_row = u8g2->tile_curr_row;
dest_max = u8g2_GetU8x8(u8g2)->display_info->tile_height;
do {
u8g2_send_tile_row(u8g2, src_row, dest_row);
src_row++;
dest_row++;
} while(src_row < src_max && dest_row < dest_max);
}
/* same as u8g2_send_buffer but also send the DISPLAY_REFRESH message (used by SSD1606) */
void u8g2_SendBuffer(u8g2_t *u8g2)
{
u8g2_send_buffer(u8g2);
u8x8_RefreshDisplay( u8g2_GetU8x8(u8g2) );
void u8g2_SendBuffer(u8g2_t* u8g2) {
u8g2_send_buffer(u8g2);
u8x8_RefreshDisplay(u8g2_GetU8x8(u8g2));
}
/*============================================*/
void u8g2_SetBufferCurrTileRow(u8g2_t *u8g2, uint8_t row)
{
u8g2->tile_curr_row = row;
u8g2->cb->update_dimension(u8g2);
u8g2->cb->update_page_win(u8g2);
void u8g2_SetBufferCurrTileRow(u8g2_t* u8g2, uint8_t row) {
u8g2->tile_curr_row = row;
u8g2->cb->update_dimension(u8g2);
u8g2->cb->update_page_win(u8g2);
}
void u8g2_FirstPage(u8g2_t *u8g2)
{
if ( u8g2->is_auto_page_clear )
{
u8g2_ClearBuffer(u8g2);
}
u8g2_SetBufferCurrTileRow(u8g2, 0);
void u8g2_FirstPage(u8g2_t* u8g2) {
if(u8g2->is_auto_page_clear) {
u8g2_ClearBuffer(u8g2);
}
u8g2_SetBufferCurrTileRow(u8g2, 0);
}
uint8_t u8g2_NextPage(u8g2_t *u8g2)
{
uint8_t row;
u8g2_send_buffer(u8g2);
row = u8g2->tile_curr_row;
row += u8g2->tile_buf_height;
if ( row >= u8g2_GetU8x8(u8g2)->display_info->tile_height )
{
u8x8_RefreshDisplay( u8g2_GetU8x8(u8g2) );
return 0;
}
if ( u8g2->is_auto_page_clear )
{
u8g2_ClearBuffer(u8g2);
}
u8g2_SetBufferCurrTileRow(u8g2, row);
return 1;
uint8_t u8g2_NextPage(u8g2_t* u8g2) {
uint8_t row;
u8g2_send_buffer(u8g2);
row = u8g2->tile_curr_row;
row += u8g2->tile_buf_height;
if(row >= u8g2_GetU8x8(u8g2)->display_info->tile_height) {
u8x8_RefreshDisplay(u8g2_GetU8x8(u8g2));
return 0;
}
if(u8g2->is_auto_page_clear) {
u8g2_ClearBuffer(u8g2);
}
u8g2_SetBufferCurrTileRow(u8g2, row);
return 1;
}
/*============================================*/
/*
Description:
@@ -150,64 +137,74 @@ uint8_t u8g2_NextPage(u8g2_t *u8g2)
- Only works with displays, which support U8x8 API
- Will not send the e-paper refresh message (will probably not work with e-paper devices)
*/
void u8g2_UpdateDisplayArea(u8g2_t *u8g2, uint8_t tx, uint8_t ty, uint8_t tw, uint8_t th)
{
uint16_t page_size;
uint8_t *ptr;
/* check, whether we are in full buffer mode */
if ( u8g2->tile_buf_height != u8g2_GetU8x8(u8g2)->display_info->tile_height )
return; /* not in full buffer mode, do nothing */
void u8g2_UpdateDisplayArea(u8g2_t* u8g2, uint8_t tx, uint8_t ty, uint8_t tw, uint8_t th) {
uint16_t page_size;
uint8_t* ptr;
page_size = u8g2->pixel_buf_width; /* 8*u8g2->u8g2_GetU8x8(u8g2)->display_info->tile_width */
ptr = u8g2_GetBufferPtr(u8g2);
ptr += tx*8;
ptr += page_size*ty;
while( th > 0 )
{
u8x8_DrawTile( u8g2_GetU8x8(u8g2), tx, ty, tw, ptr );
ptr += page_size;
ty++;
th--;
}
/* check, whether we are in full buffer mode */
if(u8g2->tile_buf_height != u8g2_GetU8x8(u8g2)->display_info->tile_height)
return; /* not in full buffer mode, do nothing */
page_size = u8g2->pixel_buf_width; /* 8*u8g2->u8g2_GetU8x8(u8g2)->display_info->tile_width */
ptr = u8g2_GetBufferPtr(u8g2);
ptr += tx * 8;
ptr += page_size * ty;
while(th > 0) {
u8x8_DrawTile(u8g2_GetU8x8(u8g2), tx, ty, tw, ptr);
ptr += page_size;
ty++;
th--;
}
}
/* same as sendBuffer, but does not send the ePaper refresh message */
void u8g2_UpdateDisplay(u8g2_t *u8g2)
{
u8g2_send_buffer(u8g2);
void u8g2_UpdateDisplay(u8g2_t* u8g2) {
u8g2_send_buffer(u8g2);
}
/*============================================*/
/* vertical_top memory architecture */
void u8g2_WriteBufferPBM(u8g2_t *u8g2, void (*out)(const char *s))
{
u8x8_capture_write_pbm_pre(u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), out);
u8x8_capture_write_pbm_buffer(u8g2_GetBufferPtr(u8g2), u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), u8x8_capture_get_pixel_1, out);
void u8g2_WriteBufferPBM(u8g2_t* u8g2, void (*out)(const char* s)) {
u8x8_capture_write_pbm_pre(u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), out);
u8x8_capture_write_pbm_buffer(
u8g2_GetBufferPtr(u8g2),
u8g2_GetBufferTileWidth(u8g2),
u8g2_GetBufferTileHeight(u8g2),
u8x8_capture_get_pixel_1,
out);
}
void u8g2_WriteBufferXBM(u8g2_t *u8g2, void (*out)(const char *s))
{
u8x8_capture_write_xbm_pre(u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), out);
u8x8_capture_write_xbm_buffer(u8g2_GetBufferPtr(u8g2), u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), u8x8_capture_get_pixel_1, out);
void u8g2_WriteBufferXBM(u8g2_t* u8g2, void (*out)(const char* s)) {
u8x8_capture_write_xbm_pre(u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), out);
u8x8_capture_write_xbm_buffer(
u8g2_GetBufferPtr(u8g2),
u8g2_GetBufferTileWidth(u8g2),
u8g2_GetBufferTileHeight(u8g2),
u8x8_capture_get_pixel_1,
out);
}
/* horizontal right memory architecture */
/* SH1122, LD7032, ST7920, ST7986, LC7981, T6963, SED1330, RA8835, MAX7219, LS0 */
void u8g2_WriteBufferPBM2(u8g2_t *u8g2, void (*out)(const char *s))
{
u8x8_capture_write_pbm_pre(u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), out);
u8x8_capture_write_pbm_buffer(u8g2_GetBufferPtr(u8g2), u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), u8x8_capture_get_pixel_2, out);
/* SH1122, LD7032, ST7920, ST7986, LC7981, T6963, SED1330, RA8835, MAX7219, LS0 */
void u8g2_WriteBufferPBM2(u8g2_t* u8g2, void (*out)(const char* s)) {
u8x8_capture_write_pbm_pre(u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), out);
u8x8_capture_write_pbm_buffer(
u8g2_GetBufferPtr(u8g2),
u8g2_GetBufferTileWidth(u8g2),
u8g2_GetBufferTileHeight(u8g2),
u8x8_capture_get_pixel_2,
out);
}
void u8g2_WriteBufferXBM2(u8g2_t *u8g2, void (*out)(const char *s))
{
u8x8_capture_write_xbm_pre(u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), out);
u8x8_capture_write_xbm_buffer(u8g2_GetBufferPtr(u8g2), u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), u8x8_capture_get_pixel_2, out);
void u8g2_WriteBufferXBM2(u8g2_t* u8g2, void (*out)(const char* s)) {
u8x8_capture_write_xbm_pre(u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), out);
u8x8_capture_write_xbm_buffer(
u8g2_GetBufferPtr(u8g2),
u8g2_GetBufferTileWidth(u8g2),
u8g2_GetBufferTileHeight(u8g2),
u8x8_capture_get_pixel_2,
out);
}
+353 -330
View File
@@ -38,41 +38,48 @@
/*==============================================*/
/* Circle */
static void u8g2_draw_circle_section(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t x0, u8g2_uint_t y0, uint8_t option) U8G2_NOINLINE;
static void u8g2_draw_circle_section(
u8g2_t* u8g2,
u8g2_uint_t x,
u8g2_uint_t y,
u8g2_uint_t x0,
u8g2_uint_t y0,
uint8_t option) U8G2_NOINLINE;
static void u8g2_draw_circle_section(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t x0, u8g2_uint_t y0, uint8_t option)
{
static void u8g2_draw_circle_section(
u8g2_t* u8g2,
u8g2_uint_t x,
u8g2_uint_t y,
u8g2_uint_t x0,
u8g2_uint_t y0,
uint8_t option) {
/* upper right */
if ( option & U8G2_DRAW_UPPER_RIGHT )
{
u8g2_DrawPixel(u8g2, x0 + x, y0 - y);
u8g2_DrawPixel(u8g2, x0 + y, y0 - x);
if(option & U8G2_DRAW_UPPER_RIGHT) {
u8g2_DrawPixel(u8g2, x0 + x, y0 - y);
u8g2_DrawPixel(u8g2, x0 + y, y0 - x);
}
/* upper left */
if ( option & U8G2_DRAW_UPPER_LEFT )
{
u8g2_DrawPixel(u8g2, x0 - x, y0 - y);
u8g2_DrawPixel(u8g2, x0 - y, y0 - x);
if(option & U8G2_DRAW_UPPER_LEFT) {
u8g2_DrawPixel(u8g2, x0 - x, y0 - y);
u8g2_DrawPixel(u8g2, x0 - y, y0 - x);
}
/* lower right */
if ( option & U8G2_DRAW_LOWER_RIGHT )
{
u8g2_DrawPixel(u8g2, x0 + x, y0 + y);
u8g2_DrawPixel(u8g2, x0 + y, y0 + x);
if(option & U8G2_DRAW_LOWER_RIGHT) {
u8g2_DrawPixel(u8g2, x0 + x, y0 + y);
u8g2_DrawPixel(u8g2, x0 + y, y0 + x);
}
/* lower left */
if ( option & U8G2_DRAW_LOWER_LEFT )
{
u8g2_DrawPixel(u8g2, x0 - x, y0 + y);
u8g2_DrawPixel(u8g2, x0 - y, y0 + x);
if(option & U8G2_DRAW_LOWER_LEFT) {
u8g2_DrawPixel(u8g2, x0 - x, y0 + y);
u8g2_DrawPixel(u8g2, x0 - y, y0 + x);
}
}
static void u8g2_draw_circle(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rad, uint8_t option)
{
static void
u8g2_draw_circle(u8g2_t* u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rad, uint8_t option) {
u8g2_int_t f;
u8g2_int_t ddF_x;
u8g2_int_t ddF_y;
@@ -89,121 +96,119 @@ static void u8g2_draw_circle(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_
y = rad;
u8g2_draw_circle_section(u8g2, x, y, x0, y0, option);
while ( x < y )
{
if (f >= 0)
{
y--;
ddF_y += 2;
f += ddF_y;
}
x++;
ddF_x += 2;
f += ddF_x;
u8g2_draw_circle_section(u8g2, x, y, x0, y0, option);
while(x < y) {
if(f >= 0) {
y--;
ddF_y += 2;
f += ddF_y;
}
x++;
ddF_x += 2;
f += ddF_x;
u8g2_draw_circle_section(u8g2, x, y, x0, y0, option);
}
}
void u8g2_DrawCircle(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rad, uint8_t option)
{
/* check for bounding box */
void u8g2_DrawCircle(u8g2_t* u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rad, uint8_t option) {
/* check for bounding box */
#ifdef U8G2_WITH_INTERSECTION
{
if ( u8g2_IsIntersection(u8g2, x0-rad, y0-rad, x0+rad+1, y0+rad+1) == 0 )
return;
}
{
if(u8g2_IsIntersection(u8g2, x0 - rad, y0 - rad, x0 + rad + 1, y0 + rad + 1) == 0) return;
}
#endif /* U8G2_WITH_INTERSECTION */
/* draw circle */
u8g2_draw_circle(u8g2, x0, y0, rad, option);
/* draw circle */
u8g2_draw_circle(u8g2, x0, y0, rad, option);
}
/*==============================================*/
/* Disk */
static void u8g2_draw_disc_section(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t x0, u8g2_uint_t y0, uint8_t option) U8G2_NOINLINE;
static void u8g2_draw_disc_section(
u8g2_t* u8g2,
u8g2_uint_t x,
u8g2_uint_t y,
u8g2_uint_t x0,
u8g2_uint_t y0,
uint8_t option) U8G2_NOINLINE;
static void u8g2_draw_disc_section(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t x0, u8g2_uint_t y0, uint8_t option)
{
static void u8g2_draw_disc_section(
u8g2_t* u8g2,
u8g2_uint_t x,
u8g2_uint_t y,
u8g2_uint_t x0,
u8g2_uint_t y0,
uint8_t option) {
/* upper right */
if ( option & U8G2_DRAW_UPPER_RIGHT )
{
u8g2_DrawVLine(u8g2, x0+x, y0-y, y+1);
u8g2_DrawVLine(u8g2, x0+y, y0-x, x+1);
if(option & U8G2_DRAW_UPPER_RIGHT) {
u8g2_DrawVLine(u8g2, x0 + x, y0 - y, y + 1);
u8g2_DrawVLine(u8g2, x0 + y, y0 - x, x + 1);
}
/* upper left */
if ( option & U8G2_DRAW_UPPER_LEFT )
{
u8g2_DrawVLine(u8g2, x0-x, y0-y, y+1);
u8g2_DrawVLine(u8g2, x0-y, y0-x, x+1);
if(option & U8G2_DRAW_UPPER_LEFT) {
u8g2_DrawVLine(u8g2, x0 - x, y0 - y, y + 1);
u8g2_DrawVLine(u8g2, x0 - y, y0 - x, x + 1);
}
/* lower right */
if ( option & U8G2_DRAW_LOWER_RIGHT )
{
u8g2_DrawVLine(u8g2, x0+x, y0, y+1);
u8g2_DrawVLine(u8g2, x0+y, y0, x+1);
if(option & U8G2_DRAW_LOWER_RIGHT) {
u8g2_DrawVLine(u8g2, x0 + x, y0, y + 1);
u8g2_DrawVLine(u8g2, x0 + y, y0, x + 1);
}
/* lower left */
if ( option & U8G2_DRAW_LOWER_LEFT )
{
u8g2_DrawVLine(u8g2, x0-x, y0, y+1);
u8g2_DrawVLine(u8g2, x0-y, y0, x+1);
if(option & U8G2_DRAW_LOWER_LEFT) {
u8g2_DrawVLine(u8g2, x0 - x, y0, y + 1);
u8g2_DrawVLine(u8g2, x0 - y, y0, x + 1);
}
}
static void u8g2_draw_disc(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rad, uint8_t option)
{
u8g2_int_t f;
u8g2_int_t ddF_x;
u8g2_int_t ddF_y;
u8g2_uint_t x;
u8g2_uint_t y;
static void
u8g2_draw_disc(u8g2_t* u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rad, uint8_t option) {
u8g2_int_t f;
u8g2_int_t ddF_x;
u8g2_int_t ddF_y;
u8g2_uint_t x;
u8g2_uint_t y;
f = 1;
f -= rad;
ddF_x = 1;
ddF_y = 0;
ddF_y -= rad;
ddF_y *= 2;
x = 0;
y = rad;
f = 1;
f -= rad;
ddF_x = 1;
ddF_y = 0;
ddF_y -= rad;
ddF_y *= 2;
x = 0;
y = rad;
u8g2_draw_disc_section(u8g2, x, y, x0, y0, option);
while ( x < y )
{
if (f >= 0)
{
y--;
ddF_y += 2;
f += ddF_y;
u8g2_draw_disc_section(u8g2, x, y, x0, y0, option);
while(x < y) {
if(f >= 0) {
y--;
ddF_y += 2;
f += ddF_y;
}
x++;
ddF_x += 2;
f += ddF_x;
u8g2_draw_disc_section(u8g2, x, y, x0, y0, option);
}
x++;
ddF_x += 2;
f += ddF_x;
u8g2_draw_disc_section(u8g2, x, y, x0, y0, option);
}
}
void u8g2_DrawDisc(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rad, uint8_t option)
{
/* check for bounding box */
void u8g2_DrawDisc(u8g2_t* u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rad, uint8_t option) {
/* check for bounding box */
#ifdef U8G2_WITH_INTERSECTION
{
if ( u8g2_IsIntersection(u8g2, x0-rad, y0-rad, x0+rad+1, y0+rad+1) == 0 )
return;
}
{
if(u8g2_IsIntersection(u8g2, x0 - rad, y0 - rad, x0 + rad + 1, y0 + rad + 1) == 0) return;
}
#endif /* U8G2_WITH_INTERSECTION */
/* draw disc */
u8g2_draw_disc(u8g2, x0, y0, rad, option);
/* draw disc */
u8g2_draw_disc(u8g2, x0, y0, rad, option);
}
/*==============================================*/
@@ -213,267 +218,285 @@ void u8g2_DrawDisc(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rad
Source:
Foley, Computer Graphics, p 90
*/
static void u8g2_draw_ellipse_section(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t x0, u8g2_uint_t y0, uint8_t option) U8G2_NOINLINE;
static void u8g2_draw_ellipse_section(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t x0, u8g2_uint_t y0, uint8_t option)
{
static void u8g2_draw_ellipse_section(
u8g2_t* u8g2,
u8g2_uint_t x,
u8g2_uint_t y,
u8g2_uint_t x0,
u8g2_uint_t y0,
uint8_t option) U8G2_NOINLINE;
static void u8g2_draw_ellipse_section(
u8g2_t* u8g2,
u8g2_uint_t x,
u8g2_uint_t y,
u8g2_uint_t x0,
u8g2_uint_t y0,
uint8_t option) {
/* upper right */
if ( option & U8G2_DRAW_UPPER_RIGHT )
{
u8g2_DrawPixel(u8g2, x0 + x, y0 - y);
if(option & U8G2_DRAW_UPPER_RIGHT) {
u8g2_DrawPixel(u8g2, x0 + x, y0 - y);
}
/* upper left */
if ( option & U8G2_DRAW_UPPER_LEFT )
{
u8g2_DrawPixel(u8g2, x0 - x, y0 - y);
if(option & U8G2_DRAW_UPPER_LEFT) {
u8g2_DrawPixel(u8g2, x0 - x, y0 - y);
}
/* lower right */
if ( option & U8G2_DRAW_LOWER_RIGHT )
{
u8g2_DrawPixel(u8g2, x0 + x, y0 + y);
if(option & U8G2_DRAW_LOWER_RIGHT) {
u8g2_DrawPixel(u8g2, x0 + x, y0 + y);
}
/* lower left */
if ( option & U8G2_DRAW_LOWER_LEFT )
{
u8g2_DrawPixel(u8g2, x0 - x, y0 + y);
if(option & U8G2_DRAW_LOWER_LEFT) {
u8g2_DrawPixel(u8g2, x0 - x, y0 + y);
}
}
static void u8g2_draw_ellipse(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rx, u8g2_uint_t ry, uint8_t option)
{
u8g2_uint_t x, y;
u8g2_long_t xchg, ychg;
u8g2_long_t err;
u8g2_long_t rxrx2;
u8g2_long_t ryry2;
u8g2_long_t stopx, stopy;
rxrx2 = rx;
rxrx2 *= rx;
rxrx2 *= 2;
ryry2 = ry;
ryry2 *= ry;
ryry2 *= 2;
x = rx;
y = 0;
xchg = 1;
xchg -= rx;
xchg -= rx;
xchg *= ry;
xchg *= ry;
ychg = rx;
ychg *= rx;
err = 0;
stopx = ryry2;
stopx *= rx;
stopy = 0;
while( stopx >= stopy )
{
u8g2_draw_ellipse_section(u8g2, x, y, x0, y0, option);
y++;
stopy += rxrx2;
err += ychg;
ychg += rxrx2;
if ( 2*err+xchg > 0 )
{
x--;
stopx -= ryry2;
err += xchg;
xchg += ryry2;
static void u8g2_draw_ellipse(
u8g2_t* u8g2,
u8g2_uint_t x0,
u8g2_uint_t y0,
u8g2_uint_t rx,
u8g2_uint_t ry,
uint8_t option) {
u8g2_uint_t x, y;
u8g2_long_t xchg, ychg;
u8g2_long_t err;
u8g2_long_t rxrx2;
u8g2_long_t ryry2;
u8g2_long_t stopx, stopy;
rxrx2 = rx;
rxrx2 *= rx;
rxrx2 *= 2;
ryry2 = ry;
ryry2 *= ry;
ryry2 *= 2;
x = rx;
y = 0;
xchg = 1;
xchg -= rx;
xchg -= rx;
xchg *= ry;
xchg *= ry;
ychg = rx;
ychg *= rx;
err = 0;
stopx = ryry2;
stopx *= rx;
stopy = 0;
while(stopx >= stopy) {
u8g2_draw_ellipse_section(u8g2, x, y, x0, y0, option);
y++;
stopy += rxrx2;
err += ychg;
ychg += rxrx2;
if(2 * err + xchg > 0) {
x--;
stopx -= ryry2;
err += xchg;
xchg += ryry2;
}
}
}
x = 0;
y = ry;
xchg = ry;
xchg *= ry;
ychg = 1;
ychg -= ry;
ychg -= ry;
ychg *= rx;
ychg *= rx;
err = 0;
stopx = 0;
x = 0;
y = ry;
stopy = rxrx2;
stopy *= ry;
xchg = ry;
xchg *= ry;
while( stopx <= stopy )
{
u8g2_draw_ellipse_section(u8g2, x, y, x0, y0, option);
x++;
stopx += ryry2;
err += xchg;
xchg += ryry2;
if ( 2*err+ychg > 0 )
{
y--;
stopy -= rxrx2;
err += ychg;
ychg += rxrx2;
ychg = 1;
ychg -= ry;
ychg -= ry;
ychg *= rx;
ychg *= rx;
err = 0;
stopx = 0;
stopy = rxrx2;
stopy *= ry;
while(stopx <= stopy) {
u8g2_draw_ellipse_section(u8g2, x, y, x0, y0, option);
x++;
stopx += ryry2;
err += xchg;
xchg += ryry2;
if(2 * err + ychg > 0) {
y--;
stopy -= rxrx2;
err += ychg;
ychg += rxrx2;
}
}
}
}
void u8g2_DrawEllipse(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rx, u8g2_uint_t ry, uint8_t option)
{
/* check for bounding box */
void u8g2_DrawEllipse(
u8g2_t* u8g2,
u8g2_uint_t x0,
u8g2_uint_t y0,
u8g2_uint_t rx,
u8g2_uint_t ry,
uint8_t option) {
/* check for bounding box */
#ifdef U8G2_WITH_INTERSECTION
{
if ( u8g2_IsIntersection(u8g2, x0-rx, y0-ry, x0+rx+1, y0+ry+1) == 0 )
return;
}
{
if(u8g2_IsIntersection(u8g2, x0 - rx, y0 - ry, x0 + rx + 1, y0 + ry + 1) == 0) return;
}
#endif /* U8G2_WITH_INTERSECTION */
u8g2_draw_ellipse(u8g2, x0, y0, rx, ry, option);
u8g2_draw_ellipse(u8g2, x0, y0, rx, ry, option);
}
/*==============================================*/
/* Filled Ellipse */
static void u8g2_draw_filled_ellipse_section(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t x0, u8g2_uint_t y0, uint8_t option) U8G2_NOINLINE;
static void u8g2_draw_filled_ellipse_section(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t x0, u8g2_uint_t y0, uint8_t option)
{
static void u8g2_draw_filled_ellipse_section(
u8g2_t* u8g2,
u8g2_uint_t x,
u8g2_uint_t y,
u8g2_uint_t x0,
u8g2_uint_t y0,
uint8_t option) U8G2_NOINLINE;
static void u8g2_draw_filled_ellipse_section(
u8g2_t* u8g2,
u8g2_uint_t x,
u8g2_uint_t y,
u8g2_uint_t x0,
u8g2_uint_t y0,
uint8_t option) {
/* upper right */
if ( option & U8G2_DRAW_UPPER_RIGHT )
{
u8g2_DrawVLine(u8g2, x0+x, y0-y, y+1);
if(option & U8G2_DRAW_UPPER_RIGHT) {
u8g2_DrawVLine(u8g2, x0 + x, y0 - y, y + 1);
}
/* upper left */
if ( option & U8G2_DRAW_UPPER_LEFT )
{
u8g2_DrawVLine(u8g2, x0-x, y0-y, y+1);
if(option & U8G2_DRAW_UPPER_LEFT) {
u8g2_DrawVLine(u8g2, x0 - x, y0 - y, y + 1);
}
/* lower right */
if ( option & U8G2_DRAW_LOWER_RIGHT )
{
u8g2_DrawVLine(u8g2, x0+x, y0, y+1);
if(option & U8G2_DRAW_LOWER_RIGHT) {
u8g2_DrawVLine(u8g2, x0 + x, y0, y + 1);
}
/* lower left */
if ( option & U8G2_DRAW_LOWER_LEFT )
{
u8g2_DrawVLine(u8g2, x0-x, y0, y+1);
if(option & U8G2_DRAW_LOWER_LEFT) {
u8g2_DrawVLine(u8g2, x0 - x, y0, y + 1);
}
}
static void u8g2_draw_filled_ellipse(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rx, u8g2_uint_t ry, uint8_t option)
{
u8g2_uint_t x, y;
u8g2_long_t xchg, ychg;
u8g2_long_t err;
u8g2_long_t rxrx2;
u8g2_long_t ryry2;
u8g2_long_t stopx, stopy;
rxrx2 = rx;
rxrx2 *= rx;
rxrx2 *= 2;
ryry2 = ry;
ryry2 *= ry;
ryry2 *= 2;
x = rx;
y = 0;
xchg = 1;
xchg -= rx;
xchg -= rx;
xchg *= ry;
xchg *= ry;
ychg = rx;
ychg *= rx;
err = 0;
stopx = ryry2;
stopx *= rx;
stopy = 0;
while( stopx >= stopy )
{
u8g2_draw_filled_ellipse_section(u8g2, x, y, x0, y0, option);
y++;
stopy += rxrx2;
err += ychg;
ychg += rxrx2;
if ( 2*err+xchg > 0 )
{
x--;
stopx -= ryry2;
err += xchg;
xchg += ryry2;
static void u8g2_draw_filled_ellipse(
u8g2_t* u8g2,
u8g2_uint_t x0,
u8g2_uint_t y0,
u8g2_uint_t rx,
u8g2_uint_t ry,
uint8_t option) {
u8g2_uint_t x, y;
u8g2_long_t xchg, ychg;
u8g2_long_t err;
u8g2_long_t rxrx2;
u8g2_long_t ryry2;
u8g2_long_t stopx, stopy;
rxrx2 = rx;
rxrx2 *= rx;
rxrx2 *= 2;
ryry2 = ry;
ryry2 *= ry;
ryry2 *= 2;
x = rx;
y = 0;
xchg = 1;
xchg -= rx;
xchg -= rx;
xchg *= ry;
xchg *= ry;
ychg = rx;
ychg *= rx;
err = 0;
stopx = ryry2;
stopx *= rx;
stopy = 0;
while(stopx >= stopy) {
u8g2_draw_filled_ellipse_section(u8g2, x, y, x0, y0, option);
y++;
stopy += rxrx2;
err += ychg;
ychg += rxrx2;
if(2 * err + xchg > 0) {
x--;
stopx -= ryry2;
err += xchg;
xchg += ryry2;
}
}
}
x = 0;
y = ry;
xchg = ry;
xchg *= ry;
ychg = 1;
ychg -= ry;
ychg -= ry;
ychg *= rx;
ychg *= rx;
err = 0;
stopx = 0;
x = 0;
y = ry;
stopy = rxrx2;
stopy *= ry;
xchg = ry;
xchg *= ry;
while( stopx <= stopy )
{
u8g2_draw_filled_ellipse_section(u8g2, x, y, x0, y0, option);
x++;
stopx += ryry2;
err += xchg;
xchg += ryry2;
if ( 2*err+ychg > 0 )
{
y--;
stopy -= rxrx2;
err += ychg;
ychg += rxrx2;
ychg = 1;
ychg -= ry;
ychg -= ry;
ychg *= rx;
ychg *= rx;
err = 0;
stopx = 0;
stopy = rxrx2;
stopy *= ry;
while(stopx <= stopy) {
u8g2_draw_filled_ellipse_section(u8g2, x, y, x0, y0, option);
x++;
stopx += ryry2;
err += xchg;
xchg += ryry2;
if(2 * err + ychg > 0) {
y--;
stopy -= rxrx2;
err += ychg;
ychg += rxrx2;
}
}
}
}
void u8g2_DrawFilledEllipse(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t rx, u8g2_uint_t ry, uint8_t option)
{
/* check for bounding box */
void u8g2_DrawFilledEllipse(
u8g2_t* u8g2,
u8g2_uint_t x0,
u8g2_uint_t y0,
u8g2_uint_t rx,
u8g2_uint_t ry,
uint8_t option) {
/* check for bounding box */
#ifdef U8G2_WITH_INTERSECTION
{
if ( u8g2_IsIntersection(u8g2, x0-rx, y0-ry, x0+rx+1, y0+ry+1) == 0 )
return;
}
{
if(u8g2_IsIntersection(u8g2, x0 - rx, y0 - ry, x0 + rx + 1, y0 + ry + 1) == 0) return;
}
#endif /* U8G2_WITH_INTERSECTION */
u8g2_draw_filled_ellipse(u8g2, x0, y0, rx, ry, option);
u8g2_draw_filled_ellipse(u8g2, x0, y0, rx, ry, option);
}
+1319 -1451
View File
File diff suppressed because it is too large Load Diff
+745 -876
View File
File diff suppressed because it is too large Load Diff
+333534 -333348
View File
File diff suppressed because it is too large Load Diff
+105 -98
View File
@@ -1,6 +1,6 @@
#include "u8g2_glue.h"
#include <furi-hal.h>
#include <furi_hal.h>
uint8_t u8g2_gpio_and_delay_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr) {
switch(msg) {
@@ -49,135 +49,138 @@ uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_
return 1;
}
#define ST756X_CMD_ON_OFF 0b10101110 /**< 0:0 Switch Display ON/OFF: last bit */
#define ST756X_CMD_SET_LINE 0b01000000 /**< 0:0 Set Start Line: last 6 bits */
#define ST756X_CMD_SET_PAGE 0b10110000 /**< 0:0 Set Page address: last 4 bits */
#define ST756X_CMD_SET_COLUMN_MSB 0b00010000 /**< 0:0 Set Column MSB: last 4 bits */
#define ST756X_CMD_SET_COLUMN_LSB 0b00000000 /**< 0:0 Set Column LSB: last 4 bits */
#define ST756X_CMD_SEG_DIRECTION 0b10100000 /**< 0:0 Reverse scan direction of SEG: last bit */
#define ST756X_CMD_INVERSE_DISPLAY 0b10100110 /**< 0:0 Invert display: last bit */
#define ST756X_CMD_ALL_PIXEL_ON 0b10100100 /**< 0:0 Set all pixel on: last bit */
#define ST756X_CMD_BIAS_SELECT 0b10100010 /**< 0:0 Select 1/9(0) or 1/7(1) bias: last bit */
#define ST756X_CMD_R_M_W 0b11100000 /**< 0:0 Enter Read Modify Write mode: read+0, write+1 */
#define ST756X_CMD_END 0b11101110 /**< 0:0 Exit Read Modify Write mode */
#define ST756X_CMD_RESET 0b11100010 /**< 0:0 Software Reset */
#define ST756X_CMD_COM_DIRECTION 0b11000000 /**< 0:0 Com direction reverse: +0b1000 */
#define ST756X_CMD_POWER_CONTROL 0b00101000 /**< 0:0 Power control: last 3 bits VB:VR:VF */
#define ST756X_CMD_REGULATION_RATIO 0b00100000 /**< 0:0 Regulation resistor ration: last 3bits */
#define ST756X_CMD_SET_EV 0b10000001 /**< 0:0 Set electronic volume: 5 bits in next byte */
#define ST756X_CMD_SET_BOOSTER 0b11111000 /**< 0:0 Set Booster level, 4X(0) or 5X(1): last bit in next byte */
#define ST756X_CMD_NOP 0b11100011 /**< 0:0 No operation */
#define ST756X_CMD_ON_OFF 0b10101110 /**< 0:0 Switch Display ON/OFF: last bit */
#define ST756X_CMD_SET_LINE 0b01000000 /**< 0:0 Set Start Line: last 6 bits */
#define ST756X_CMD_SET_PAGE 0b10110000 /**< 0:0 Set Page address: last 4 bits */
#define ST756X_CMD_SET_COLUMN_MSB 0b00010000 /**< 0:0 Set Column MSB: last 4 bits */
#define ST756X_CMD_SET_COLUMN_LSB 0b00000000 /**< 0:0 Set Column LSB: last 4 bits */
#define ST756X_CMD_SEG_DIRECTION 0b10100000 /**< 0:0 Reverse scan direction of SEG: last bit */
#define ST756X_CMD_INVERSE_DISPLAY 0b10100110 /**< 0:0 Invert display: last bit */
#define ST756X_CMD_ALL_PIXEL_ON 0b10100100 /**< 0:0 Set all pixel on: last bit */
#define ST756X_CMD_BIAS_SELECT 0b10100010 /**< 0:0 Select 1/9(0) or 1/7(1) bias: last bit */
#define ST756X_CMD_R_M_W 0b11100000 /**< 0:0 Enter Read Modify Write mode: read+0, write+1 */
#define ST756X_CMD_END 0b11101110 /**< 0:0 Exit Read Modify Write mode */
#define ST756X_CMD_RESET 0b11100010 /**< 0:0 Software Reset */
#define ST756X_CMD_COM_DIRECTION 0b11000000 /**< 0:0 Com direction reverse: +0b1000 */
#define ST756X_CMD_POWER_CONTROL 0b00101000 /**< 0:0 Power control: last 3 bits VB:VR:VF */
#define ST756X_CMD_REGULATION_RATIO 0b00100000 /**< 0:0 Regulation resistor ration: last 3bits */
#define ST756X_CMD_SET_EV 0b10000001 /**< 0:0 Set electronic volume: 5 bits in next byte */
#define ST756X_CMD_SET_BOOSTER \
0b11111000 /**< 0:0 Set Booster level, 4X(0) or 5X(1): last bit in next byte */
#define ST756X_CMD_NOP 0b11100011 /**< 0:0 No operation */
static const uint8_t u8x8_d_st756x_powersave0_seq[] = {
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
U8X8_C(ST756X_CMD_ALL_PIXEL_ON | 0b0), /* all pixel off */
U8X8_C(ST756X_CMD_ON_OFF | 0b1), /* display on */
U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
U8X8_C(ST756X_CMD_ALL_PIXEL_ON | 0b0), /* all pixel off */
U8X8_C(ST756X_CMD_ON_OFF | 0b1), /* display on */
U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */
};
static const uint8_t u8x8_d_st756x_powersave1_seq[] = {
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
U8X8_C(ST756X_CMD_ON_OFF | 0b0), /* display off */
U8X8_C(ST756X_CMD_ALL_PIXEL_ON | 0b1), /* all pixel on */
U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
U8X8_C(ST756X_CMD_ON_OFF | 0b0), /* display off */
U8X8_C(ST756X_CMD_ALL_PIXEL_ON | 0b1), /* all pixel on */
U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */
};
static const uint8_t u8x8_d_st756x_flip0_seq[] = {
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
U8X8_C(0x0a1), /* segment remap a0/a1*/
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
U8X8_C(0x0a1), /* segment remap a0/a1*/
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */
};
static const uint8_t u8x8_d_st756x_flip1_seq[] = {
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
U8X8_C(0x0a0), /* segment remap a0/a1*/
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
U8X8_C(0x0a0), /* segment remap a0/a1*/
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */
};
static const u8x8_display_info_t u8x8_st756x_128x64_display_info = {
.chip_enable_level = 0,
.chip_disable_level = 1,
.post_chip_enable_wait_ns = 150, /* st7565 datasheet, table 26, tcsh */
.pre_chip_disable_wait_ns = 50, /* st7565 datasheet, table 26, tcss */
.post_chip_enable_wait_ns = 150, /* st7565 datasheet, table 26, tcsh */
.pre_chip_disable_wait_ns = 50, /* st7565 datasheet, table 26, tcss */
.reset_pulse_width_ms = 1,
.post_reset_wait_ms = 1,
.sda_setup_time_ns = 50, /* st7565 datasheet, table 26, tsds */
.sck_pulse_width_ns = 120, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
.sck_clock_hz = 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
.spi_mode = 0, /* active high, rising edge */
.sda_setup_time_ns = 50, /* st7565 datasheet, table 26, tsds */
.sck_pulse_width_ns =
120, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
.sck_clock_hz =
4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
.spi_mode = 0, /* active high, rising edge */
.i2c_bus_clock_100kHz = 4,
.data_setup_time_ns = 40, /* st7565 datasheet, table 24, tds8 */
.write_pulse_width_ns = 80, /* st7565 datasheet, table 24, tcclw */
.tile_width = 16, /* width of 16*8=128 pixel */
.data_setup_time_ns = 40, /* st7565 datasheet, table 24, tds8 */
.write_pulse_width_ns = 80, /* st7565 datasheet, table 24, tcclw */
.tile_width = 16, /* width of 16*8=128 pixel */
.tile_height = 8,
.default_x_offset = 0,
.flipmode_x_offset = 4,
.pixel_width = 128,
.pixel_height = 64
};
.pixel_height = 64};
uint8_t u8x8_d_st756x_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) {
uint8_t u8x8_d_st756x_common(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr) {
uint8_t x, c;
uint8_t *ptr;
uint8_t* ptr;
switch(msg) {
case U8X8_MSG_DISPLAY_DRAW_TILE:
u8x8_cad_StartTransfer(u8x8);
case U8X8_MSG_DISPLAY_DRAW_TILE:
u8x8_cad_StartTransfer(u8x8);
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
x *= 8;
x += u8x8->x_offset;
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
x = ((u8x8_tile_t*)arg_ptr)->x_pos;
x *= 8;
x += u8x8->x_offset;
u8x8_cad_SendCmd(u8x8, 0x010 | (x >> 4));
u8x8_cad_SendCmd(u8x8, 0x000 | ((x & 15)));
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t*)arg_ptr)->y_pos));
c = ((u8x8_tile_t *)arg_ptr)->cnt;
c *= 8;
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
/*
c = ((u8x8_tile_t*)arg_ptr)->cnt;
c *= 8;
ptr = ((u8x8_tile_t*)arg_ptr)->tile_ptr;
/*
The following if condition checks the hardware limits of the st7565
controller: It is not allowed to write beyond the display limits.
This is in fact an issue within flip mode.
*/
if ( c + x > 132u ) {
c = 132u;
c -= x;
}
if(c + x > 132u) {
c = 132u;
c -= x;
}
do {
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
arg_int--;
} while( arg_int > 0 );
do {
u8x8_cad_SendData(
u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
arg_int--;
} while(arg_int > 0);
u8x8_cad_EndTransfer(u8x8);
break;
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
if ( arg_int == 0 )
u8x8_cad_SendSequence(u8x8, u8x8_d_st756x_powersave0_seq);
else
u8x8_cad_SendSequence(u8x8, u8x8_d_st756x_powersave1_seq);
break;
u8x8_cad_EndTransfer(u8x8);
break;
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
if(arg_int == 0)
u8x8_cad_SendSequence(u8x8, u8x8_d_st756x_powersave0_seq);
else
u8x8_cad_SendSequence(u8x8, u8x8_d_st756x_powersave1_seq);
break;
#ifdef U8X8_WITH_SET_CONTRAST
case U8X8_MSG_DISPLAY_SET_CONTRAST:
u8x8_cad_StartTransfer(u8x8);
u8x8_cad_SendCmd(u8x8, ST756X_CMD_SET_EV);
u8x8_cad_SendArg(u8x8, arg_int >> 2 ); /* st7565 has range from 0 to 63 */
u8x8_cad_EndTransfer(u8x8);
break;
case U8X8_MSG_DISPLAY_SET_CONTRAST:
u8x8_cad_StartTransfer(u8x8);
u8x8_cad_SendCmd(u8x8, ST756X_CMD_SET_EV);
u8x8_cad_SendArg(u8x8, arg_int >> 2); /* st7565 has range from 0 to 63 */
u8x8_cad_EndTransfer(u8x8);
break;
#endif
default:
return 0;
default:
return 0;
}
return 1;
}
void u8x8_d_st756x_init(u8x8_t *u8x8, uint8_t contrast, uint8_t regulation_ratio, bool bias) {
void u8x8_d_st756x_init(u8x8_t* u8x8, uint8_t contrast, uint8_t regulation_ratio, bool bias) {
contrast = contrast & 0b00111111;
regulation_ratio = regulation_ratio & 0b111;
@@ -201,18 +204,18 @@ void u8x8_d_st756x_init(u8x8_t *u8x8, uint8_t contrast, uint8_t regulation_ratio
u8x8_cad_EndTransfer(u8x8);
}
uint8_t u8x8_d_st756x_flipper(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) {
uint8_t u8x8_d_st756x_flipper(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr) {
/* call common procedure first and handle messages there */
if (u8x8_d_st756x_common(u8x8, msg, arg_int, arg_ptr) == 0) {
if(u8x8_d_st756x_common(u8x8, msg, arg_int, arg_ptr) == 0) {
/* msg not handled, then try here */
switch(msg){
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
switch(msg) {
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st756x_128x64_display_info);
break;
case U8X8_MSG_DISPLAY_INIT:
u8x8_d_helper_display_init(u8x8);
FuriHalVersionDisplay display = furi_hal_version_get_hw_display();
if (display == FuriHalVersionDisplayMgg) {
if(display == FuriHalVersionDisplayMgg) {
/* MGG v0+(ST7567)
* EV = 32
* RR = V0 / ((1 - (63 - EV) / 162) * 2.1)
@@ -231,13 +234,13 @@ uint8_t u8x8_d_st756x_flipper(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *
}
break;
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
if ( arg_int == 0 ) {
if(arg_int == 0) {
u8x8_cad_SendSequence(u8x8, u8x8_d_st756x_flip1_seq);
u8x8->x_offset = u8x8->display_info->default_x_offset;
} else {
u8x8_cad_SendSequence(u8x8, u8x8_d_st756x_flip0_seq);
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
}
}
break;
default:
/* msg unknown */
@@ -247,9 +250,13 @@ uint8_t u8x8_d_st756x_flipper(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *
return 1;
}
void u8g2_Setup_st756x_flipper(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb) {
void u8g2_Setup_st756x_flipper(
u8g2_t* u8g2,
const u8g2_cb_t* rotation,
u8x8_msg_cb byte_cb,
u8x8_msg_cb gpio_and_delay_cb) {
uint8_t tile_buf_height;
uint8_t *buf;
uint8_t* buf;
u8g2_SetupDisplay(u8g2, u8x8_d_st756x_flipper, u8x8_cad_001, byte_cb, gpio_and_delay_cb);
buf = u8g2_m_16_8_f(&tile_buf_height);
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation);
+6 -2
View File
@@ -7,6 +7,10 @@ uint8_t u8g2_gpio_and_delay_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, vo
uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr);
void u8g2_Setup_st756x_flipper(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
void u8g2_Setup_st756x_flipper(
u8g2_t* u8g2,
const u8g2_cb_t* rotation,
u8x8_msg_cb byte_cb,
u8x8_msg_cb gpio_and_delay_cb);
void u8x8_d_st756x_init(u8x8_t *u8x8, uint8_t contrast, uint8_t regulation_ratio, bool bias);
void u8x8_d_st756x_init(u8x8_t* u8x8, uint8_t contrast, uint8_t regulation_ratio, bool bias);
+97 -131
View File
@@ -58,14 +58,14 @@
*/
static uint8_t u8g2_clip_intersection2(u8g2_uint_t *ap, u8g2_uint_t *len, u8g2_uint_t c, u8g2_uint_t d)
{
u8g2_uint_t a = *ap;
u8g2_uint_t b;
b = a;
b += *len;
static uint8_t
u8g2_clip_intersection2(u8g2_uint_t* ap, u8g2_uint_t* len, u8g2_uint_t c, u8g2_uint_t d) {
u8g2_uint_t a = *ap;
u8g2_uint_t b;
b = a;
b += *len;
/*
/*
Description:
clip range from a (included) to b (excluded) agains c (included) to d (excluded)
Assumptions:
@@ -78,45 +78,35 @@ static uint8_t u8g2_clip_intersection2(u8g2_uint_t *ap, u8g2_uint_t *len, u8g2_u
replaced by uint8_t u8g2_clip_intersection2
*/
/* handle the a>b case correctly. If code and time is critical, this could */
/* be removed completly (be aware about memory curruption for wrong */
/* arguments) or return 0 for a>b (will lead to skipped lines for wrong */
/* arguments) */
/* removing the following if clause completly may lead to memory corruption of a>b */
if ( a > b )
{
/* replacing this if with a simple "return 0;" will not handle the case with negative a */
if ( a < d )
{
b = d;
b--;
/* handle the a>b case correctly. If code and time is critical, this could */
/* be removed completly (be aware about memory curruption for wrong */
/* arguments) or return 0 for a>b (will lead to skipped lines for wrong */
/* arguments) */
/* removing the following if clause completly may lead to memory corruption of a>b */
if(a > b) {
/* replacing this if with a simple "return 0;" will not handle the case with negative a */
if(a < d) {
b = d;
b--;
} else {
a = c;
}
}
else
{
a = c;
}
}
/* from now on, the asumption a <= b is ok */
if ( a >= d )
return 0;
if ( b <= c )
return 0;
if ( a < c )
a = c;
if ( b > d )
b = d;
*ap = a;
b -= a;
*len = b;
return 1;
/* from now on, the asumption a <= b is ok */
if(a >= d) return 0;
if(b <= c) return 0;
if(a < c) a = c;
if(b > d) b = d;
*ap = a;
b -= a;
*len = b;
return 1;
}
/*==========================================================*/
/* draw procedures */
@@ -129,108 +119,86 @@ static uint8_t u8g2_clip_intersection2(u8g2_uint_t *ap, u8g2_uint_t *len, u8g2_u
will clip the line and call u8g2_draw_low_level_hv_line()
*/
void u8g2_draw_hv_line_2dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
{
void u8g2_draw_hv_line_2dir(
u8g2_t* u8g2,
u8g2_uint_t x,
u8g2_uint_t y,
u8g2_uint_t len,
uint8_t dir) {
/* clipping happens before the display rotation */
/* clipping happens before the display rotation */
/* transform to pixel buffer coordinates */
y -= u8g2->pixel_curr_row;
/* transform to pixel buffer coordinates */
y -= u8g2->pixel_curr_row;
u8g2->ll_hvline(u8g2, x, y, len, dir);
u8g2->ll_hvline(u8g2, x, y, len, dir);
}
/*
This is the toplevel function for the hv line draw procedures.
This function should be called by the user.
"dir" may have 4 directions: 0 (left to right), 1, 2, 3 (down up)
*/
void u8g2_DrawHVLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
{
/* Make a call to the callback function (e.g. u8g2_draw_l90_r0). */
/* The callback may rotate the hv line */
/* after rotation this will call u8g2_draw_hv_line_4dir() */
void u8g2_DrawHVLine(u8g2_t* u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) {
/* Make a call to the callback function (e.g. u8g2_draw_l90_r0). */
/* The callback may rotate the hv line */
/* after rotation this will call u8g2_draw_hv_line_4dir() */
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
if ( u8g2->is_page_clip_window_intersection != 0 )
if(u8g2->is_page_clip_window_intersection != 0)
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
if ( len != 0 )
{
/* convert to two directions */
if ( len > 1 )
{
if ( dir == 2 )
{
x -= len;
x++;
}
else if ( dir == 3 )
{
y -= len;
y++;
}
}
dir &= 1;
/* clip against the user window */
if ( dir == 0 )
{
if ( y < u8g2->user_y0 )
return;
if ( y >= u8g2->user_y1 )
return;
if ( u8g2_clip_intersection2(&x, &len, u8g2->user_x0, u8g2->user_x1) == 0 )
return;
}
else
{
if ( x < u8g2->user_x0 )
return;
if ( x >= u8g2->user_x1 )
return;
if ( u8g2_clip_intersection2(&y, &len, u8g2->user_y0, u8g2->user_y1) == 0 )
return;
}
u8g2->cb->draw_l90(u8g2, x, y, len, dir);
}
if(len != 0) {
/* convert to two directions */
if(len > 1) {
if(dir == 2) {
x -= len;
x++;
} else if(dir == 3) {
y -= len;
y++;
}
}
dir &= 1;
/* clip against the user window */
if(dir == 0) {
if(y < u8g2->user_y0) return;
if(y >= u8g2->user_y1) return;
if(u8g2_clip_intersection2(&x, &len, u8g2->user_x0, u8g2->user_x1) == 0) return;
} else {
if(x < u8g2->user_x0) return;
if(x >= u8g2->user_x1) return;
if(u8g2_clip_intersection2(&y, &len, u8g2->user_y0, u8g2->user_y1) == 0) return;
}
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)
{
// #ifdef U8G2_WITH_INTERSECTION
// if ( u8g2_IsIntersection(u8g2, x, y, x+len, y+1) == 0 )
// return;
// #endif /* U8G2_WITH_INTERSECTION */
u8g2_DrawHVLine(u8g2, x, y, len, 0);
void u8g2_DrawHLine(u8g2_t* u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len) {
// #ifdef U8G2_WITH_INTERSECTION
// if ( u8g2_IsIntersection(u8g2, x, y, x+len, y+1) == 0 )
// return;
// #endif /* U8G2_WITH_INTERSECTION */
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)
{
// #ifdef U8G2_WITH_INTERSECTION
// if ( u8g2_IsIntersection(u8g2, x, y, x+1, y+len) == 0 )
// return;
// #endif /* U8G2_WITH_INTERSECTION */
u8g2_DrawHVLine(u8g2, x, y, len, 1);
void u8g2_DrawVLine(u8g2_t* u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len) {
// #ifdef U8G2_WITH_INTERSECTION
// if ( u8g2_IsIntersection(u8g2, x, y, x+1, y+len) == 0 )
// return;
// #endif /* U8G2_WITH_INTERSECTION */
u8g2_DrawHVLine(u8g2, x, y, len, 1);
}
void u8g2_DrawPixel(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y)
{
void u8g2_DrawPixel(u8g2_t* u8g2, u8g2_uint_t x, u8g2_uint_t y) {
#ifdef U8G2_WITH_INTERSECTION
if ( y < u8g2->user_y0 )
return;
if ( y >= u8g2->user_y1 )
return;
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);
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
}
/*
@@ -246,10 +214,8 @@ void u8g2_DrawPixel(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y)
7 Jan 2017: Allow color value 2 for XOR operation.
*/
void u8g2_SetDrawColor(u8g2_t *u8g2, uint8_t color)
{
u8g2->draw_color = color; /* u8g2_SetDrawColor: just assign the argument */
if ( color >= 3 )
u8g2->draw_color = 1; /* u8g2_SetDrawColor: make color as one if arg is invalid */
void u8g2_SetDrawColor(u8g2_t* u8g2, uint8_t color) {
u8g2->draw_color = color; /* u8g2_SetDrawColor: just assign the argument */
if(color >= 3)
u8g2->draw_color = 1; /* u8g2_SetDrawColor: make color as one if arg is invalid */
}
+66 -89
View File
@@ -41,8 +41,7 @@
#define U8G2_ALWAYS_INLINE __inline__ __attribute__((always_inline))
#else
#define U8G2_ALWAYS_INLINE
#endif
#endif
#if defined(U8G2_WITH_INTERSECTION) || defined(U8G2_WITH_CLIP_WINDOW_SUPPORT)
@@ -58,7 +57,6 @@
---1-1--- 1 b1 <= a2 && b2 >= a1
*/
/*
calculate the intersection between a0/a1 and v0/v1
The intersection check returns one if the range of a0/a1 has an intersection with v0/v1.
@@ -71,106 +69,85 @@
assert( u8g2_is_intersection_decision_tree(7, 9, 4, 6) == 0 );
*/
//static uint8_t U8G2_ALWAYS_INLINE u8g2_is_intersection_decision_tree(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
static uint8_t u8g2_is_intersection_decision_tree(u8g2_uint_t a0, u8g2_uint_t a1, u8g2_uint_t v0, u8g2_uint_t v1)
{
if ( v0 <= a1 )
{
if ( v1 >= a0 )
{
return 1;
//static uint8_t U8G2_ALWAYS_INLINE u8g2_is_intersection_decision_tree(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
static uint8_t u8g2_is_intersection_decision_tree(
u8g2_uint_t a0,
u8g2_uint_t a1,
u8g2_uint_t v0,
u8g2_uint_t v1) {
if(v0 <= a1) {
if(v1 >= a0) {
return 1;
} else {
if(v0 > v1) {
return 1;
} else {
return 0;
}
}
} else {
if(v1 >= a0) {
if(v0 > v1) {
return 1;
} else {
return 0;
}
} else {
return 0;
}
}
else
{
if ( v0 > v1 )
{
return 1;
}
else
{
return 0;
}
}
}
else
{
if ( v1 >= a0 )
{
if ( v0 > v1 )
{
return 1;
}
else
{
return 0;
}
}
else
{
return 0;
}
}
}
#endif /* OLD_VERSION_WITH_SYMETRIC_BOUNDARIES */
#endif /* OLD_VERSION_WITH_SYMETRIC_BOUNDARIES */
/*
version with asymetric boundaries.
a1 and v1 are excluded
v0 == v1 is not support end return 1
*/
uint8_t u8g2_is_intersection_decision_tree(u8g2_uint_t a0, u8g2_uint_t a1, u8g2_uint_t v0, u8g2_uint_t v1)
{
if ( v0 < a1 ) // v0 <= a1
{
if ( v1 > a0 ) // v1 >= a0
uint8_t u8g2_is_intersection_decision_tree(
u8g2_uint_t a0,
u8g2_uint_t a1,
u8g2_uint_t v0,
u8g2_uint_t v1) {
if(v0 < a1) // v0 <= a1
{
return 1;
if(v1 > a0) // v1 >= a0
{
return 1;
} else {
if(v0 > v1) // v0 > v1
{
return 1;
} else {
return 0;
}
}
} else {
if(v1 > a0) // v1 >= a0
{
if(v0 > v1) // v0 > v1
{
return 1;
} else {
return 0;
}
} else {
return 0;
}
}
else
{
if ( v0 > v1 ) // v0 > v1
{
return 1;
}
else
{
return 0;
}
}
}
else
{
if ( v1 > a0 ) // v1 >= a0
{
if ( v0 > v1 ) // v0 > v1
{
return 1;
}
else
{
return 0;
}
}
else
{
return 0;
}
}
}
/* upper limits are not included (asymetric boundaries) */
uint8_t u8g2_IsIntersection(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t x1, u8g2_uint_t y1)
{
if ( u8g2_is_intersection_decision_tree(u8g2->user_y0, u8g2->user_y1, y0, y1) == 0 )
return 0;
return u8g2_is_intersection_decision_tree(u8g2->user_x0, u8g2->user_x1, x0, x1);
uint8_t u8g2_IsIntersection(
u8g2_t* u8g2,
u8g2_uint_t x0,
u8g2_uint_t y0,
u8g2_uint_t x1,
u8g2_uint_t y1) {
if(u8g2_is_intersection_decision_tree(u8g2->user_y0, u8g2->user_y1, y0, y1) == 0) return 0;
return u8g2_is_intersection_decision_tree(u8g2->user_x0, u8g2->user_x1, x0, x1);
}
#endif /* U8G2_WITH_INTERSECTION */
+55 -45
View File
@@ -35,58 +35,68 @@
#include "u8g2.h"
void u8g2_DrawLine(u8g2_t* u8g2, u8g2_uint_t x1, u8g2_uint_t y1, u8g2_uint_t x2, u8g2_uint_t y2) {
u8g2_uint_t tmp;
u8g2_uint_t x, y;
u8g2_uint_t dx, dy;
u8g2_int_t err;
u8g2_int_t ystep;
void u8g2_DrawLine(u8g2_t *u8g2, u8g2_uint_t x1, u8g2_uint_t y1, u8g2_uint_t x2, u8g2_uint_t y2)
{
u8g2_uint_t tmp;
u8g2_uint_t x,y;
u8g2_uint_t dx, dy;
u8g2_int_t err;
u8g2_int_t ystep;
uint8_t swapxy = 0;
uint8_t swapxy = 0;
/* no intersection check at the moment, should be added... */
/* no intersection check at the moment, should be added... */
if ( x1 > x2 ) dx = x1-x2; else dx = x2-x1;
if ( y1 > y2 ) dy = y1-y2; else dy = y2-y1;
if(x1 > x2)
dx = x1 - x2;
else
dx = x2 - x1;
if(y1 > y2)
dy = y1 - y2;
else
dy = y2 - y1;
if ( dy > dx )
{
swapxy = 1;
tmp = dx; dx =dy; dy = tmp;
tmp = x1; x1 =y1; y1 = tmp;
tmp = x2; x2 =y2; y2 = tmp;
}
if ( x1 > x2 )
{
tmp = x1; x1 =x2; x2 = tmp;
tmp = y1; y1 =y2; y2 = tmp;
}
err = dx >> 1;
if ( y2 > y1 ) ystep = 1; else ystep = -1;
y = y1;
if(dy > dx) {
swapxy = 1;
tmp = dx;
dx = dy;
dy = tmp;
tmp = x1;
x1 = y1;
y1 = tmp;
tmp = x2;
x2 = y2;
y2 = tmp;
}
if(x1 > x2) {
tmp = x1;
x1 = x2;
x2 = tmp;
tmp = y1;
y1 = y2;
y2 = tmp;
}
err = dx >> 1;
if(y2 > y1)
ystep = 1;
else
ystep = -1;
y = y1;
#ifndef U8G2_16BIT
if ( x2 == 255 )
x2--;
#ifndef U8G2_16BIT
if(x2 == 255) x2--;
#else
if ( x2 == 0xffff )
x2--;
if(x2 == 0xffff) x2--;
#endif
for( x = x1; x <= x2; x++ )
{
if ( swapxy == 0 )
u8g2_DrawPixel(u8g2, x, y);
else
u8g2_DrawPixel(u8g2, y, x);
err -= (uint8_t)dy;
if ( err < 0 )
{
y += (u8g2_uint_t)ystep;
err += (u8g2_uint_t)dx;
for(x = x1; x <= x2; x++) {
if(swapxy == 0)
u8g2_DrawPixel(u8g2, x, y);
else
u8g2_DrawPixel(u8g2, y, x);
err -= (uint8_t)dy;
if(err < 0) {
y += (u8g2_uint_t)ystep;
err += (u8g2_uint_t)dx;
}
}
}
}
+189 -221
View File
@@ -58,7 +58,6 @@
UC1701
*/
#ifdef U8G2_WITH_HVLINE_SPEED_OPTIMIZATION
/*
@@ -69,125 +68,111 @@
asumption:
all clipping done
*/
void u8g2_ll_hvline_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
{
uint16_t offset;
uint8_t *ptr;
uint8_t bit_pos, mask;
uint8_t or_mask, xor_mask;
void u8g2_ll_hvline_vertical_top_lsb(
u8g2_t* u8g2,
u8g2_uint_t x,
u8g2_uint_t y,
u8g2_uint_t len,
uint8_t dir) {
uint16_t offset;
uint8_t* ptr;
uint8_t bit_pos, mask;
uint8_t or_mask, xor_mask;
#ifdef __unix
uint8_t *max_ptr = u8g2->tile_buf_ptr + u8g2_GetU8x8(u8g2)->display_info->tile_width*u8g2->tile_buf_height*8;
uint8_t* max_ptr = u8g2->tile_buf_ptr +
u8g2_GetU8x8(u8g2)->display_info->tile_width * u8g2->tile_buf_height * 8;
#endif
//assert(x >= u8g2->buf_x0);
//assert(x < u8g2_GetU8x8(u8g2)->display_info->tile_width*8);
//assert(y >= u8g2->buf_y0);
//assert(y < u8g2_GetU8x8(u8g2)->display_info->tile_height*8);
/* bytes are vertical, lsb on top (y=0), msb at bottom (y=7) */
bit_pos = y; /* overflow truncate is ok here... */
bit_pos &= 7; /* ... because only the lowest 3 bits are needed */
mask = 1;
mask <<= bit_pos;
//assert(x >= u8g2->buf_x0);
//assert(x < u8g2_GetU8x8(u8g2)->display_info->tile_width*8);
//assert(y >= u8g2->buf_y0);
//assert(y < u8g2_GetU8x8(u8g2)->display_info->tile_height*8);
or_mask = 0;
xor_mask = 0;
if ( u8g2->draw_color <= 1 )
or_mask = mask;
if ( u8g2->draw_color != 1 )
xor_mask = mask;
/* bytes are vertical, lsb on top (y=0), msb at bottom (y=7) */
bit_pos = y; /* overflow truncate is ok here... */
bit_pos &= 7; /* ... because only the lowest 3 bits are needed */
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;
ptr = u8g2->tile_buf_ptr;
ptr += offset;
ptr += x;
if ( dir == 0 )
{
do
{
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;
ptr = u8g2->tile_buf_ptr;
ptr += offset;
ptr += x;
if(dir == 0) {
do {
#ifdef __unix
assert(ptr < max_ptr);
assert(ptr < max_ptr);
#endif
*ptr |= or_mask;
*ptr ^= xor_mask;
ptr++;
len--;
} while( len != 0 );
}
else
{
do
{
*ptr |= or_mask;
*ptr ^= xor_mask;
ptr++;
len--;
} while(len != 0);
} else {
do {
#ifdef __unix
assert(ptr < max_ptr);
assert(ptr < max_ptr);
#endif
*ptr |= or_mask;
*ptr ^= xor_mask;
bit_pos++;
bit_pos &= 7;
*ptr |= or_mask;
*ptr ^= xor_mask;
len--;
bit_pos++;
bit_pos &= 7;
if ( bit_pos == 0 )
{
ptr+=u8g2->pixel_buf_width; /* 6 Jan 17: Changed u8g2->width to u8g2->pixel_buf_width, issue #148 */
if ( u8g2->draw_color <= 1 )
or_mask = 1;
if ( u8g2->draw_color != 1 )
xor_mask = 1;
}
else
{
or_mask <<= 1;
xor_mask <<= 1;
}
} while( len != 0 );
}
len--;
if(bit_pos == 0) {
ptr +=
u8g2->pixel_buf_width; /* 6 Jan 17: Changed u8g2->width to u8g2->pixel_buf_width, issue #148 */
if(u8g2->draw_color <= 1) or_mask = 1;
if(u8g2->draw_color != 1) xor_mask = 1;
} else {
or_mask <<= 1;
xor_mask <<= 1;
}
} while(len != 0);
}
}
#else /* U8G2_WITH_HVLINE_SPEED_OPTIMIZATION */
/*
x,y position within the buffer
*/
static void u8g2_draw_pixel_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;
//assert(x >= u8g2->buf_x0);
//assert(x < u8g2_GetU8x8(u8g2)->display_info->tile_width*8);
//assert(y >= u8g2->buf_y0);
//assert(y < u8g2_GetU8x8(u8g2)->display_info->tile_height*8);
/* bytes are vertical, lsb on top (y=0), msb at bottom (y=7) */
bit_pos = y; /* overflow truncate is ok here... */
bit_pos &= 7; /* ... because only the lowest 3 bits are needed */
mask = 1;
mask <<= bit_pos;
static void u8g2_draw_pixel_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;
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;
ptr = u8g2->tile_buf_ptr;
ptr += offset;
ptr += x;
//assert(x >= u8g2->buf_x0);
//assert(x < u8g2_GetU8x8(u8g2)->display_info->tile_width*8);
//assert(y >= u8g2->buf_y0);
//assert(y < u8g2_GetU8x8(u8g2)->display_info->tile_height*8);
/* bytes are vertical, lsb on top (y=0), msb at bottom (y=7) */
bit_pos = y; /* overflow truncate is ok here... */
bit_pos &= 7; /* ... because only the lowest 3 bits are needed */
mask = 1;
mask <<= bit_pos;
if ( u8g2->draw_color <= 1 )
*ptr |= mask;
if ( u8g2->draw_color != 1 )
*ptr ^= 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;
ptr = u8g2->tile_buf_ptr;
ptr += offset;
ptr += x;
if(u8g2->draw_color <= 1) *ptr |= mask;
if(u8g2->draw_color != 1) *ptr ^= mask;
}
/*
@@ -198,29 +183,27 @@ static void u8g2_draw_pixel_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_u
asumption:
all clipping done
*/
void u8g2_ll_hvline_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
{
if ( dir == 0 )
{
do
{
u8g2_draw_pixel_vertical_top_lsb(u8g2, x, y);
x++;
len--;
} while( len != 0 );
}
else
{
do
{
u8g2_draw_pixel_vertical_top_lsb(u8g2, x, y);
y++;
len--;
} while( len != 0 );
}
void u8g2_ll_hvline_vertical_top_lsb(
u8g2_t* u8g2,
u8g2_uint_t x,
u8g2_uint_t y,
u8g2_uint_t len,
uint8_t dir) {
if(dir == 0) {
do {
u8g2_draw_pixel_vertical_top_lsb(u8g2, x, y);
x++;
len--;
} while(len != 0);
} else {
do {
u8g2_draw_pixel_vertical_top_lsb(u8g2, x, y);
y++;
len--;
} while(len != 0);
}
}
#endif /* U8G2_WITH_HVLINE_SPEED_OPTIMIZATION */
/*=================================================*/
@@ -240,101 +223,87 @@ void u8g2_ll_hvline_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y,
all clipping done
*/
/* SH1122, LD7032, ST7920, ST7986, LC7981, T6963, SED1330, RA8835, MAX7219, LS0 */
void u8g2_ll_hvline_horizontal_right_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
{
uint16_t offset;
uint8_t *ptr;
uint8_t bit_pos;
uint8_t mask;
uint8_t tile_width = u8g2_GetU8x8(u8g2)->display_info->tile_width;
/* SH1122, LD7032, ST7920, ST7986, LC7981, T6963, SED1330, RA8835, MAX7219, LS0 */
void u8g2_ll_hvline_horizontal_right_lsb(
u8g2_t* u8g2,
u8g2_uint_t x,
u8g2_uint_t y,
u8g2_uint_t len,
uint8_t dir) {
uint16_t offset;
uint8_t* ptr;
uint8_t bit_pos;
uint8_t mask;
uint8_t tile_width = u8g2_GetU8x8(u8g2)->display_info->tile_width;
bit_pos = x; /* overflow truncate is ok here... */
bit_pos &= 7; /* ... because only the lowest 3 bits are needed */
mask = 128;
mask >>= bit_pos;
bit_pos = x; /* overflow truncate is ok here... */
bit_pos &= 7; /* ... because only the lowest 3 bits are needed */
mask = 128;
mask >>= bit_pos;
offset = y; /* y might be 8 or 16 bit, but we need 16 bit, so use a 16 bit variable */
offset *= tile_width;
offset += x>>3;
ptr = u8g2->tile_buf_ptr;
ptr += offset;
if ( dir == 0 )
{
do
{
offset = y; /* y might be 8 or 16 bit, but we need 16 bit, so use a 16 bit variable */
offset *= tile_width;
offset += x >> 3;
ptr = u8g2->tile_buf_ptr;
ptr += offset;
if ( u8g2->draw_color <= 1 )
*ptr |= mask;
if ( u8g2->draw_color != 1 )
*ptr ^= mask;
mask >>= 1;
if ( mask == 0 )
{
mask = 128;
ptr++;
}
//x++;
len--;
} while( len != 0 );
}
else
{
do
{
if ( u8g2->draw_color <= 1 )
*ptr |= mask;
if ( u8g2->draw_color != 1 )
*ptr ^= mask;
ptr += tile_width;
//y++;
len--;
} while( len != 0 );
}
if(dir == 0) {
do {
if(u8g2->draw_color <= 1) *ptr |= mask;
if(u8g2->draw_color != 1) *ptr ^= mask;
mask >>= 1;
if(mask == 0) {
mask = 128;
ptr++;
}
//x++;
len--;
} while(len != 0);
} else {
do {
if(u8g2->draw_color <= 1) *ptr |= mask;
if(u8g2->draw_color != 1) *ptr ^= mask;
ptr += tile_width;
//y++;
len--;
} while(len != 0);
}
}
#else /* U8G2_WITH_HVLINE_SPEED_OPTIMIZATION */
/*
x,y position within the buffer
*/
/* SH1122, LD7032, ST7920, ST7986, LC7981, T6963, SED1330, RA8835, MAX7219, LS0 */
static void u8g2_draw_pixel_horizontal_right_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y)
{
uint16_t offset;
uint8_t *ptr;
uint8_t bit_pos, mask;
/* SH1122, LD7032, ST7920, ST7986, LC7981, T6963, SED1330, RA8835, MAX7219, LS0 */
static void u8g2_draw_pixel_horizontal_right_lsb(u8g2_t* u8g2, u8g2_uint_t x, u8g2_uint_t y) {
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);
//assert(y < u8g2_GetU8x8(u8g2)->display_info->tile_height*8);
/* bytes are vertical, lsb on top (y=0), msb at bottom (y=7) */
bit_pos = x; /* overflow truncate is ok here... */
bit_pos &= 7; /* ... because only the lowest 3 bits are needed */
mask = 128;
mask >>= bit_pos;
x >>= 3;
//assert(x >= u8g2->buf_x0);
//assert(x < u8g2_GetU8x8(u8g2)->display_info->tile_width*8);
//assert(y >= u8g2->buf_y0);
//assert(y < u8g2_GetU8x8(u8g2)->display_info->tile_height*8);
offset = y; /* y might be 8 or 16 bit, but we need 16 bit, so use a 16 bit variable */
offset *= u8g2_GetU8x8(u8g2)->display_info->tile_width;
offset += x;
ptr = u8g2->tile_buf_ptr;
ptr += offset;
/* bytes are vertical, lsb on top (y=0), msb at bottom (y=7) */
bit_pos = x; /* overflow truncate is ok here... */
bit_pos &= 7; /* ... because only the lowest 3 bits are needed */
mask = 128;
mask >>= bit_pos;
x >>= 3;
if ( u8g2->draw_color <= 1 )
*ptr |= mask;
if ( u8g2->draw_color != 1 )
*ptr ^= mask;
offset = y; /* y might be 8 or 16 bit, but we need 16 bit, so use a 16 bit variable */
offset *= u8g2_GetU8x8(u8g2)->display_info->tile_width;
offset += x;
ptr = u8g2->tile_buf_ptr;
ptr += offset;
if(u8g2->draw_color <= 1) *ptr |= mask;
if(u8g2->draw_color != 1) *ptr ^= mask;
}
/*
@@ -345,27 +314,26 @@ static void u8g2_draw_pixel_horizontal_right_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8
asumption:
all clipping done
*/
/* SH1122, LD7032, ST7920, ST7986, LC7981, T6963, SED1330, RA8835, MAX7219, LS0 */
void u8g2_ll_hvline_horizontal_right_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
{
if ( dir == 0 )
{
do
{
u8g2_draw_pixel_horizontal_right_lsb(u8g2, x, y);
x++;
len--;
} while( len != 0 );
}
else
{
do
{
u8g2_draw_pixel_horizontal_right_lsb(u8g2, x, y);
y++;
len--;
} while( len != 0 );
}
/* SH1122, LD7032, ST7920, ST7986, LC7981, T6963, SED1330, RA8835, MAX7219, LS0 */
void u8g2_ll_hvline_horizontal_right_lsb(
u8g2_t* u8g2,
u8g2_uint_t x,
u8g2_uint_t y,
u8g2_uint_t len,
uint8_t dir) {
if(dir == 0) {
do {
u8g2_draw_pixel_horizontal_right_lsb(u8g2, x, y);
x++;
len--;
} while(len != 0);
} else {
do {
u8g2_draw_pixel_horizontal_right_lsb(u8g2, x, y);
y++;
len--;
} while(len != 0);
}
}
#endif /* U8G2_WITH_HVLINE_SPEED_OPTIMIZATION */
+246 -278
View File
@@ -37,29 +37,30 @@
#include <string.h>
#include <assert.h>
/*============================================*/
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
void u8g2_SetMaxClipWindow(u8g2_t *u8g2)
{
u8g2->clip_x0 = 0;
u8g2->clip_y0 = 0;
u8g2->clip_x1 = (u8g2_uint_t)~(u8g2_uint_t)0;
u8g2->clip_y1 = (u8g2_uint_t)~(u8g2_uint_t)0;
u8g2->cb->update_page_win(u8g2);
void u8g2_SetMaxClipWindow(u8g2_t* u8g2) {
u8g2->clip_x0 = 0;
u8g2->clip_y0 = 0;
u8g2->clip_x1 = (u8g2_uint_t) ~(u8g2_uint_t)0;
u8g2->clip_y1 = (u8g2_uint_t) ~(u8g2_uint_t)0;
u8g2->cb->update_page_win(u8g2);
}
void u8g2_SetClipWindow(u8g2_t *u8g2, u8g2_uint_t clip_x0, u8g2_uint_t clip_y0, u8g2_uint_t clip_x1, u8g2_uint_t clip_y1 )
{
u8g2->clip_x0 = clip_x0;
u8g2->clip_y0 = clip_y0;
u8g2->clip_x1 = clip_x1;
u8g2->clip_y1 = clip_y1;
u8g2->cb->update_page_win(u8g2);
void u8g2_SetClipWindow(
u8g2_t* u8g2,
u8g2_uint_t clip_x0,
u8g2_uint_t clip_y0,
u8g2_uint_t clip_x1,
u8g2_uint_t clip_y1) {
u8g2->clip_x0 = clip_x0;
u8g2->clip_y0 = clip_y0;
u8g2->clip_x1 = clip_x1;
u8g2->clip_y1 = clip_y1;
u8g2->cb->update_page_win(u8g2);
}
#endif
@@ -68,38 +69,42 @@ void u8g2_SetClipWindow(u8g2_t *u8g2, u8g2_uint_t clip_x0, u8g2_uint_t clip_y0,
This procedure is called after setting up the display (u8x8 structure).
--> This is the central init procedure for u8g2 object
*/
void u8g2_SetupBuffer(u8g2_t *u8g2, uint8_t *buf, uint8_t tile_buf_height, u8g2_draw_ll_hvline_cb ll_hvline_cb, const u8g2_cb_t *u8g2_cb)
{
u8g2->font = NULL;
//u8g2->kerning = NULL;
//u8g2->get_kerning_cb = u8g2_GetNullKerning;
//u8g2->ll_hvline = u8g2_ll_hvline_vertical_top_lsb;
u8g2->ll_hvline = ll_hvline_cb;
u8g2->tile_buf_ptr = buf;
u8g2->tile_buf_height = tile_buf_height;
u8g2->tile_curr_row = 0;
u8g2->font_decode.is_transparent = 0; /* issue 443 */
u8g2->bitmap_transparency = 0;
u8g2->draw_color = 1;
u8g2->is_auto_page_clear = 1;
u8g2->cb = u8g2_cb;
u8g2->cb->update_dimension(u8g2);
void u8g2_SetupBuffer(
u8g2_t* u8g2,
uint8_t* buf,
uint8_t tile_buf_height,
u8g2_draw_ll_hvline_cb ll_hvline_cb,
const u8g2_cb_t* u8g2_cb) {
u8g2->font = NULL;
//u8g2->kerning = NULL;
//u8g2->get_kerning_cb = u8g2_GetNullKerning;
//u8g2->ll_hvline = u8g2_ll_hvline_vertical_top_lsb;
u8g2->ll_hvline = ll_hvline_cb;
u8g2->tile_buf_ptr = buf;
u8g2->tile_buf_height = tile_buf_height;
u8g2->tile_curr_row = 0;
u8g2->font_decode.is_transparent = 0; /* issue 443 */
u8g2->bitmap_transparency = 0;
u8g2->draw_color = 1;
u8g2->is_auto_page_clear = 1;
u8g2->cb = u8g2_cb;
u8g2->cb->update_dimension(u8g2);
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
u8g2_SetMaxClipWindow(u8g2); /* assign a clip window and call the update() procedure */
u8g2_SetMaxClipWindow(u8g2); /* assign a clip window and call the update() procedure */
#else
u8g2->cb->update_page_win(u8g2);
u8g2->cb->update_page_win(u8g2);
#endif
u8g2_SetFontPosBaseline(u8g2); /* issue 195 */
#ifdef U8G2_WITH_FONT_ROTATION
u8g2->font_decode.dir = 0;
u8g2_SetFontPosBaseline(u8g2); /* issue 195 */
#ifdef U8G2_WITH_FONT_ROTATION
u8g2->font_decode.dir = 0;
#endif
}
@@ -107,24 +112,21 @@ void u8g2_SetupBuffer(u8g2_t *u8g2, uint8_t *buf, uint8_t tile_buf_height, u8g2_
Usually the display rotation is set initially, but it could be done later also
u8g2_cb can be U8G2_R0..U8G2_R3
*/
void u8g2_SetDisplayRotation(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
{
u8g2->cb = u8g2_cb;
u8g2->cb->update_dimension(u8g2);
u8g2->cb->update_page_win(u8g2);
void u8g2_SetDisplayRotation(u8g2_t* u8g2, const u8g2_cb_t* u8g2_cb) {
u8g2->cb = u8g2_cb;
u8g2->cb->update_dimension(u8g2);
u8g2->cb->update_page_win(u8g2);
}
/*============================================*/
void u8g2_SendF(u8g2_t * u8g2, const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
u8x8_cad_vsendf(u8g2_GetU8x8(u8g2), fmt, va);
va_end(va);
void u8g2_SendF(u8g2_t* u8g2, const char* fmt, ...) {
va_list va;
va_start(va, fmt);
u8x8_cad_vsendf(u8g2_GetU8x8(u8g2), fmt, va);
va_end(va);
}
/*============================================*/
/*
update dimension:
@@ -135,230 +137,204 @@ void u8g2_SendF(u8g2_t * u8g2, const char *fmt, ...)
u8g2_uint_t buf_y1;
*/
static void u8g2_update_dimension_common(u8g2_t *u8g2)
{
const u8x8_display_info_t *display_info = u8g2_GetU8x8(u8g2)->display_info;
u8g2_uint_t t;
t = u8g2->tile_buf_height;
t *= 8;
u8g2->pixel_buf_height = t;
t = display_info->tile_width;
static void u8g2_update_dimension_common(u8g2_t* u8g2) {
const u8x8_display_info_t* display_info = u8g2_GetU8x8(u8g2)->display_info;
u8g2_uint_t t;
t = u8g2->tile_buf_height;
t *= 8;
u8g2->pixel_buf_height = t;
t = display_info->tile_width;
#ifndef U8G2_16BIT
if ( t >= 32 )
t = 31;
if(t >= 32) t = 31;
#endif
t *= 8;
u8g2->pixel_buf_width = t;
t = u8g2->tile_curr_row;
t *= 8;
u8g2->pixel_curr_row = t;
t = u8g2->tile_buf_height;
/* handle the case, where the buffer is larger than the (remaining) part of the display */
if ( t + u8g2->tile_curr_row > display_info->tile_height )
t = display_info->tile_height - u8g2->tile_curr_row;
t *= 8;
u8g2->buf_y0 = u8g2->pixel_curr_row;
u8g2->buf_y1 = u8g2->buf_y0;
u8g2->buf_y1 += t;
t *= 8;
u8g2->pixel_buf_width = t;
t = u8g2->tile_curr_row;
t *= 8;
u8g2->pixel_curr_row = t;
t = u8g2->tile_buf_height;
/* handle the case, where the buffer is larger than the (remaining) part of the display */
if(t + u8g2->tile_curr_row > display_info->tile_height)
t = display_info->tile_height - u8g2->tile_curr_row;
t *= 8;
u8g2->buf_y0 = u8g2->pixel_curr_row;
u8g2->buf_y1 = u8g2->buf_y0;
u8g2->buf_y1 += t;
#ifdef U8G2_16BIT
u8g2->width = display_info->pixel_width;
u8g2->height = display_info->pixel_height;
#else
u8g2->width = 240;
if ( display_info->pixel_width <= 240 )
u8g2->width = display_info->pixel_width;
u8g2->height = display_info->pixel_height;
u8g2->height = display_info->pixel_height;
#else
u8g2->width = 240;
if(display_info->pixel_width <= 240) u8g2->width = display_info->pixel_width;
u8g2->height = display_info->pixel_height;
#endif
}
/*==========================================================*/
/* apply clip window */
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
static void u8g2_apply_clip_window(u8g2_t *u8g2)
{
/* check aganst the current user_??? window */
if ( u8g2_IsIntersection(u8g2, u8g2->clip_x0, u8g2->clip_y0, u8g2->clip_x1, u8g2->clip_y1) == 0 )
{
u8g2->is_page_clip_window_intersection = 0;
}
else
{
u8g2->is_page_clip_window_intersection = 1;
static void u8g2_apply_clip_window(u8g2_t* u8g2) {
/* check aganst the current user_??? window */
if(u8g2_IsIntersection(u8g2, u8g2->clip_x0, u8g2->clip_y0, u8g2->clip_x1, u8g2->clip_y1) ==
0) {
u8g2->is_page_clip_window_intersection = 0;
} else {
u8g2->is_page_clip_window_intersection = 1;
if ( u8g2->user_x0 < u8g2->clip_x0 )
u8g2->user_x0 = u8g2->clip_x0;
if ( u8g2->user_x1 > u8g2->clip_x1 )
u8g2->user_x1 = u8g2->clip_x1;
if ( u8g2->user_y0 < u8g2->clip_y0 )
u8g2->user_y0 = u8g2->clip_y0;
if ( u8g2->user_y1 > u8g2->clip_y1 )
u8g2->user_y1 = u8g2->clip_y1;
}
if(u8g2->user_x0 < u8g2->clip_x0) u8g2->user_x0 = u8g2->clip_x0;
if(u8g2->user_x1 > u8g2->clip_x1) u8g2->user_x1 = u8g2->clip_x1;
if(u8g2->user_y0 < u8g2->clip_y0) u8g2->user_y0 = u8g2->clip_y0;
if(u8g2->user_y1 > u8g2->clip_y1) u8g2->user_y1 = u8g2->clip_y1;
}
}
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
/*==========================================================*/
void u8g2_update_dimension_r0(u8g2_t *u8g2)
{
u8g2_update_dimension_common(u8g2);
void u8g2_update_dimension_r0(u8g2_t* u8g2) {
u8g2_update_dimension_common(u8g2);
}
void u8g2_update_page_win_r0(u8g2_t *u8g2)
{
u8g2->user_x0 = 0;
u8g2->user_x1 = u8g2->width; /* pixel_buf_width replaced with width */
u8g2->user_y0 = u8g2->buf_y0;
u8g2->user_y1 = u8g2->buf_y1;
void u8g2_update_page_win_r0(u8g2_t* u8g2) {
u8g2->user_x0 = 0;
u8g2->user_x1 = u8g2->width; /* pixel_buf_width replaced with width */
u8g2->user_y0 = u8g2->buf_y0;
u8g2->user_y1 = u8g2->buf_y1;
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
u8g2_apply_clip_window(u8g2);
u8g2_apply_clip_window(u8g2);
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
}
void u8g2_update_dimension_r1(u8g2_t* u8g2) {
u8g2_update_dimension_common(u8g2);
void u8g2_update_dimension_r1(u8g2_t *u8g2)
{
u8g2_update_dimension_common(u8g2);
u8g2->height = u8g2_GetU8x8(u8g2)->display_info->pixel_width;
u8g2->width = u8g2_GetU8x8(u8g2)->display_info->pixel_height;
u8g2->height = u8g2_GetU8x8(u8g2)->display_info->pixel_width;
u8g2->width = u8g2_GetU8x8(u8g2)->display_info->pixel_height;
}
void u8g2_update_page_win_r1(u8g2_t *u8g2)
{
u8g2->user_x0 = u8g2->buf_y0;
u8g2->user_x1 = u8g2->buf_y1;
u8g2->user_y0 = 0;
u8g2->user_y1 = u8g2->height; /* pixel_buf_width replaced with height (which is the real pixel width) */
void u8g2_update_page_win_r1(u8g2_t* u8g2) {
u8g2->user_x0 = u8g2->buf_y0;
u8g2->user_x1 = u8g2->buf_y1;
u8g2->user_y0 = 0;
u8g2->user_y1 =
u8g2->height; /* pixel_buf_width replaced with height (which is the real pixel width) */
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
u8g2_apply_clip_window(u8g2);
u8g2_apply_clip_window(u8g2);
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
}
void u8g2_update_dimension_r2(u8g2_t *u8g2)
{
u8g2_update_dimension_common(u8g2);
void u8g2_update_dimension_r2(u8g2_t* u8g2) {
u8g2_update_dimension_common(u8g2);
}
void u8g2_update_page_win_r2(u8g2_t *u8g2)
{
u8g2->user_x0 = 0;
u8g2->user_x1 = u8g2->width; /* pixel_buf_width replaced with width */
/* there are ases where the height is not a multiple of 8. */
/* in such a case u8g2->buf_y1 might be heigher than u8g2->height */
u8g2->user_y0 = 0;
if ( u8g2->height >= u8g2->buf_y1 )
u8g2->user_y0 = u8g2->height - u8g2->buf_y1;
u8g2->user_y1 = u8g2->height - u8g2->buf_y0;
void u8g2_update_page_win_r2(u8g2_t* u8g2) {
u8g2->user_x0 = 0;
u8g2->user_x1 = u8g2->width; /* pixel_buf_width replaced with width */
/* there are ases where the height is not a multiple of 8. */
/* in such a case u8g2->buf_y1 might be heigher than u8g2->height */
u8g2->user_y0 = 0;
if(u8g2->height >= u8g2->buf_y1) u8g2->user_y0 = u8g2->height - u8g2->buf_y1;
u8g2->user_y1 = u8g2->height - u8g2->buf_y0;
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
u8g2_apply_clip_window(u8g2);
u8g2_apply_clip_window(u8g2);
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
}
void u8g2_update_dimension_r3(u8g2_t* u8g2) {
u8g2_update_dimension_common(u8g2);
void u8g2_update_dimension_r3(u8g2_t *u8g2)
{
u8g2_update_dimension_common(u8g2);
u8g2->height = u8g2_GetU8x8(u8g2)->display_info->pixel_width;
u8g2->width = u8g2_GetU8x8(u8g2)->display_info->pixel_height;
u8g2->height = u8g2_GetU8x8(u8g2)->display_info->pixel_width;
u8g2->width = u8g2_GetU8x8(u8g2)->display_info->pixel_height;
}
void u8g2_update_page_win_r3(u8g2_t *u8g2)
{
/* there are ases where the height is not a multiple of 8. */
/* in such a case u8g2->buf_y1 might be heigher than u8g2->width */
u8g2->user_x0 = 0;
if ( u8g2->width >= u8g2->buf_y1 )
u8g2->user_x0 = u8g2->width - u8g2->buf_y1;
u8g2->user_x1 = u8g2->width - u8g2->buf_y0;
u8g2->user_y0 = 0;
u8g2->user_y1 = u8g2->height; /* pixel_buf_width replaced with height (pixel_width) */
void u8g2_update_page_win_r3(u8g2_t* u8g2) {
/* there are ases where the height is not a multiple of 8. */
/* in such a case u8g2->buf_y1 might be heigher than u8g2->width */
u8g2->user_x0 = 0;
if(u8g2->width >= u8g2->buf_y1) u8g2->user_x0 = u8g2->width - u8g2->buf_y1;
u8g2->user_x1 = u8g2->width - u8g2->buf_y0;
u8g2->user_y0 = 0;
u8g2->user_y1 = u8g2->height; /* pixel_buf_width replaced with height (pixel_width) */
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
u8g2_apply_clip_window(u8g2);
u8g2_apply_clip_window(u8g2);
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
}
/*============================================*/
extern void u8g2_draw_hv_line_2dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir);
extern void u8g2_draw_hv_line_2dir(
u8g2_t* u8g2,
u8g2_uint_t x,
u8g2_uint_t y,
u8g2_uint_t len,
uint8_t dir);
void u8g2_draw_l90_r0(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
{
void u8g2_draw_l90_r0(u8g2_t* u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) {
#ifdef __unix
assert( dir <= 1 );
assert(dir <= 1);
#endif
u8g2_draw_hv_line_2dir(u8g2, x, y, len, dir);
u8g2_draw_hv_line_2dir(u8g2, x, y, len, dir);
}
void u8g2_draw_l90_mirrorr_r0(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
{
u8g2_uint_t xx;
xx = u8g2->width;
xx -= x;
if ( (dir & 1) == 0 )
{
xx -= len;
}
else
{
xx--;
}
u8g2_draw_hv_line_2dir(u8g2, xx, y, len, dir);
void u8g2_draw_l90_mirrorr_r0(
u8g2_t* u8g2,
u8g2_uint_t x,
u8g2_uint_t y,
u8g2_uint_t len,
uint8_t dir) {
u8g2_uint_t xx;
xx = u8g2->width;
xx -= x;
if((dir & 1) == 0) {
xx -= len;
} else {
xx--;
}
u8g2_draw_hv_line_2dir(u8g2, xx, y, len, dir);
}
/* dir = 0 or 1 */
void u8g2_draw_l90_r1(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
{
u8g2_uint_t xx, yy;
void u8g2_draw_l90_r1(u8g2_t* u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) {
u8g2_uint_t xx, yy;
#ifdef __unix
assert( dir <= 1 );
assert(dir <= 1);
#endif
yy = x;
xx = u8g2->height;
xx -= y;
xx--;
dir ++;
if ( dir == 2 )
{
xx -= len;
xx++;
dir = 0;
}
u8g2_draw_hv_line_2dir(u8g2, xx, yy, len, dir);
yy = x;
xx = u8g2->height;
xx -= y;
xx--;
dir++;
if(dir == 2) {
xx -= len;
xx++;
dir = 0;
}
u8g2_draw_hv_line_2dir(u8g2, xx, yy, len, dir);
}
void u8g2_draw_l90_r2(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
{
u8g2_uint_t xx, yy;
void u8g2_draw_l90_r2(u8g2_t* u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) {
u8g2_uint_t xx, yy;
/*
/*
yy = u8g2->height;
yy -= y;
yy--;
@@ -379,73 +355,65 @@ void u8g2_draw_l90_r2(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t le
}
*/
yy = u8g2->height;
yy -= y;
xx = u8g2->width;
xx -= x;
if ( dir == 0 )
{
yy--;
xx -= len;
}
else if ( dir == 1 )
{
xx--;
yy -= len;
}
yy = u8g2->height;
yy -= y;
u8g2_draw_hv_line_2dir(u8g2, xx, yy, len, dir);
xx = u8g2->width;
xx -= x;
if(dir == 0) {
yy--;
xx -= len;
} else if(dir == 1) {
xx--;
yy -= len;
}
u8g2_draw_hv_line_2dir(u8g2, xx, yy, len, dir);
}
void u8g2_draw_l90_r3(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
{
u8g2_uint_t xx, yy;
void u8g2_draw_l90_r3(u8g2_t* u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) {
u8g2_uint_t xx, yy;
xx = y;
yy = u8g2->width;
yy -= x;
if ( dir == 0 )
{
yy--;
yy -= len;
yy++;
dir = 1;
}
else
{
yy--;
dir = 0;
}
u8g2_draw_hv_line_2dir(u8g2, xx, yy, len, dir);
xx = y;
yy = u8g2->width;
yy -= x;
if(dir == 0) {
yy--;
yy -= len;
yy++;
dir = 1;
} else {
yy--;
dir = 0;
}
u8g2_draw_hv_line_2dir(u8g2, xx, yy, len, dir);
}
/*============================================*/
const u8g2_cb_t u8g2_cb_r0 = { u8g2_update_dimension_r0, u8g2_update_page_win_r0, u8g2_draw_l90_r0 };
const u8g2_cb_t u8g2_cb_r1 = { u8g2_update_dimension_r1, u8g2_update_page_win_r1, u8g2_draw_l90_r1 };
const u8g2_cb_t u8g2_cb_r2 = { u8g2_update_dimension_r2, u8g2_update_page_win_r2, u8g2_draw_l90_r2 };
const u8g2_cb_t u8g2_cb_r3 = { u8g2_update_dimension_r3, u8g2_update_page_win_r3, u8g2_draw_l90_r3 };
const u8g2_cb_t u8g2_cb_mirror = { u8g2_update_dimension_r0, u8g2_update_page_win_r0, u8g2_draw_l90_mirrorr_r0 };
const u8g2_cb_t u8g2_cb_r0 = {u8g2_update_dimension_r0, u8g2_update_page_win_r0, u8g2_draw_l90_r0};
const u8g2_cb_t u8g2_cb_r1 = {u8g2_update_dimension_r1, u8g2_update_page_win_r1, u8g2_draw_l90_r1};
const u8g2_cb_t u8g2_cb_r2 = {u8g2_update_dimension_r2, u8g2_update_page_win_r2, u8g2_draw_l90_r2};
const u8g2_cb_t u8g2_cb_r3 = {u8g2_update_dimension_r3, u8g2_update_page_win_r3, u8g2_draw_l90_r3};
const u8g2_cb_t u8g2_cb_mirror = {
u8g2_update_dimension_r0,
u8g2_update_page_win_r0,
u8g2_draw_l90_mirrorr_r0};
/*============================================*/
/* setup for the null device */
/* setup for the null (empty) device */
void u8g2_Setup_null(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)
{
static uint8_t buf[8];
u8g2_SetupDisplay(u8g2, u8x8_d_null_cb, u8x8_cad_empty, byte_cb, gpio_and_delay_cb);
u8g2_SetupBuffer(u8g2, buf, 1, u8g2_ll_hvline_vertical_top_lsb, rotation);
void u8g2_Setup_null(
u8g2_t* u8g2,
const u8g2_cb_t* rotation,
u8x8_msg_cb byte_cb,
u8x8_msg_cb gpio_and_delay_cb) {
static uint8_t buf[8];
u8g2_SetupDisplay(u8g2, u8x8_d_null_cb, u8x8_cad_empty, byte_cb, gpio_and_delay_cb);
u8g2_SetupBuffer(u8g2, buf, 1, u8g2_ll_hvline_vertical_top_lsb, rotation);
}
+638 -562
View File
File diff suppressed because it is too large Load Diff
+289 -365
View File
@@ -38,18 +38,15 @@
#include "u8x8.h"
#if defined(ESP8266)
uint8_t u8x8_pgm_read_esp(const uint8_t * addr)
{
uint8_t u8x8_pgm_read_esp(const uint8_t* addr) {
uint32_t bytes;
bytes = *(uint32_t*)((uint32_t)addr & ~3);
return ((uint8_t*)&bytes)[(uint32_t)addr & 3];
}
#endif
void u8x8_SetFont(u8x8_t *u8x8, const uint8_t *font_8x8)
{
u8x8->font = font_8x8;
void u8x8_SetFont(u8x8_t* u8x8, const uint8_t* font_8x8) {
u8x8->font = font_8x8;
}
/*
@@ -58,74 +55,63 @@ void u8x8_SetFont(u8x8_t *u8x8, const uint8_t *font_8x8)
encoding: glyph for which the data is requested (must be between 0 and 255)
buf: pointer to 8 bytes
*/
static void u8x8_get_glyph_data(u8x8_t *u8x8, uint8_t encoding, uint8_t *buf, uint8_t tile_offset) U8X8_NOINLINE;
static void u8x8_get_glyph_data(u8x8_t *u8x8, uint8_t encoding, uint8_t *buf, uint8_t tile_offset)
{
uint8_t first, last, tiles, i;
uint16_t offset;
first = u8x8_pgm_read(u8x8->font+0);
last = u8x8_pgm_read(u8x8->font+1);
tiles = u8x8_pgm_read(u8x8->font+2); /* new 2019 format */
tiles *= u8x8_pgm_read(u8x8->font+3); /* new 2019 format */
/* get the glyph bitmap from the font */
if ( first <= encoding && encoding <= last )
{
offset = encoding;
offset -= first;
offset *= tiles; /* new 2019 format */
offset += tile_offset; /* new 2019 format */
offset *= 8;
offset +=4; /* changed from 2 to 4, new 2019 format */
for( i = 0; i < 8; i++ )
{
buf[i] = u8x8_pgm_read(u8x8->font+offset);
offset++;
static void u8x8_get_glyph_data(u8x8_t* u8x8, uint8_t encoding, uint8_t* buf, uint8_t tile_offset)
U8X8_NOINLINE;
static void
u8x8_get_glyph_data(u8x8_t* u8x8, uint8_t encoding, uint8_t* buf, uint8_t tile_offset) {
uint8_t first, last, tiles, i;
uint16_t offset;
first = u8x8_pgm_read(u8x8->font + 0);
last = u8x8_pgm_read(u8x8->font + 1);
tiles = u8x8_pgm_read(u8x8->font + 2); /* new 2019 format */
tiles *= u8x8_pgm_read(u8x8->font + 3); /* new 2019 format */
/* get the glyph bitmap from the font */
if(first <= encoding && encoding <= last) {
offset = encoding;
offset -= first;
offset *= tiles; /* new 2019 format */
offset += tile_offset; /* new 2019 format */
offset *= 8;
offset += 4; /* changed from 2 to 4, new 2019 format */
for(i = 0; i < 8; i++) {
buf[i] = u8x8_pgm_read(u8x8->font + offset);
offset++;
}
} else {
for(i = 0; i < 8; i++) {
buf[i] = 0;
}
}
}
else
{
for( i = 0; i < 8; i++ )
{
buf[i] = 0;
/* invert the bitmap if required */
if(u8x8->is_font_inverse_mode) {
for(i = 0; i < 8; i++) {
buf[i] ^= 255;
}
}
}
/* invert the bitmap if required */
if ( u8x8->is_font_inverse_mode )
{
for( i = 0; i < 8; i++ )
{
buf[i] ^= 255;
}
}
}
void u8x8_DrawGlyph(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t encoding)
{
uint8_t th = u8x8_pgm_read(u8x8->font+2); /* new 2019 format */
uint8_t tv = u8x8_pgm_read(u8x8->font+3); /* new 2019 format */
uint8_t xx, tile;
uint8_t buf[8];
th += x;
tv += y;
tile = 0;
do
{
xx = x;
do
{
u8x8_get_glyph_data(u8x8, encoding, buf, tile);
u8x8_DrawTile(u8x8, xx, y, 1, buf);
tile++;
xx++;
} while( xx < th );
y++;
} while( y < tv );
void u8x8_DrawGlyph(u8x8_t* u8x8, uint8_t x, uint8_t y, uint8_t encoding) {
uint8_t th = u8x8_pgm_read(u8x8->font + 2); /* new 2019 format */
uint8_t tv = u8x8_pgm_read(u8x8->font + 3); /* new 2019 format */
uint8_t xx, tile;
uint8_t buf[8];
th += x;
tv += y;
tile = 0;
do {
xx = x;
do {
u8x8_get_glyph_data(u8x8, encoding, buf, tile);
u8x8_DrawTile(u8x8, xx, y, 1, buf);
tile++;
xx++;
} while(xx < th);
y++;
} while(y < tv);
}
/*
Source: http://graphics.stanford.edu/~seander/bithacks.html
Section: Interleave bits by Binary Magic Numbers
@@ -150,122 +136,110 @@ void u8x8_DrawGlyph(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t encoding)
z = x | (y << 1);
*/
uint16_t u8x8_upscale_byte(uint8_t x)
{
uint16_t y = x;
y |= (y << 4); // x = (x | (x << S[2])) & B[2];
y &= 0x0f0f;
y |= (y << 2); // x = (x | (x << S[1])) & B[1];
y &= 0x3333;
y |= (y << 1); // x = (x | (x << S[0])) & B[0];
y &= 0x5555;
y |= (y << 1); // z = x | (y << 1);
return y;
uint16_t u8x8_upscale_byte(uint8_t x) {
uint16_t y = x;
y |= (y << 4); // x = (x | (x << S[2])) & B[2];
y &= 0x0f0f;
y |= (y << 2); // x = (x | (x << S[1])) & B[1];
y &= 0x3333;
y |= (y << 1); // x = (x | (x << S[0])) & B[0];
y &= 0x5555;
y |= (y << 1); // z = x | (y << 1);
return y;
}
static void u8x8_upscale_buf(uint8_t *src, uint8_t *dest) U8X8_NOINLINE;
static void u8x8_upscale_buf(uint8_t *src, uint8_t *dest)
{
uint8_t i = 4;
do
{
*dest++ = *src;
*dest++ = *src++;
i--;
} while( i > 0 );
static void u8x8_upscale_buf(uint8_t* src, uint8_t* dest) U8X8_NOINLINE;
static void u8x8_upscale_buf(uint8_t* src, uint8_t* dest) {
uint8_t i = 4;
do {
*dest++ = *src;
*dest++ = *src++;
i--;
} while(i > 0);
}
static void u8x8_draw_2x2_subglyph(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t encoding, uint8_t tile)
{
uint8_t i;
uint16_t t;
uint8_t buf[8];
uint8_t buf1[8];
uint8_t buf2[8];
u8x8_get_glyph_data(u8x8, encoding, buf, tile);
for( i = 0; i < 8; i ++ )
{
t = u8x8_upscale_byte(buf[i]);
buf1[i] = t >> 8;
buf2[i] = t & 255;
}
u8x8_upscale_buf(buf2, buf);
u8x8_DrawTile(u8x8, x, y, 1, buf);
u8x8_upscale_buf(buf2+4, buf);
u8x8_DrawTile(u8x8, x+1, y, 1, buf);
u8x8_upscale_buf(buf1, buf);
u8x8_DrawTile(u8x8, x, y+1, 1, buf);
u8x8_upscale_buf(buf1+4, buf);
u8x8_DrawTile(u8x8, x+1, y+1, 1, buf);
static void
u8x8_draw_2x2_subglyph(u8x8_t* u8x8, uint8_t x, uint8_t y, uint8_t encoding, uint8_t tile) {
uint8_t i;
uint16_t t;
uint8_t buf[8];
uint8_t buf1[8];
uint8_t buf2[8];
u8x8_get_glyph_data(u8x8, encoding, buf, tile);
for(i = 0; i < 8; i++) {
t = u8x8_upscale_byte(buf[i]);
buf1[i] = t >> 8;
buf2[i] = t & 255;
}
u8x8_upscale_buf(buf2, buf);
u8x8_DrawTile(u8x8, x, y, 1, buf);
u8x8_upscale_buf(buf2 + 4, buf);
u8x8_DrawTile(u8x8, x + 1, y, 1, buf);
u8x8_upscale_buf(buf1, buf);
u8x8_DrawTile(u8x8, x, y + 1, 1, buf);
u8x8_upscale_buf(buf1 + 4, buf);
u8x8_DrawTile(u8x8, x + 1, y + 1, 1, buf);
}
void u8x8_Draw2x2Glyph(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t encoding)
{
uint8_t th = u8x8_pgm_read(u8x8->font+2); /* new 2019 format */
uint8_t tv = u8x8_pgm_read(u8x8->font+3); /* new 2019 format */
uint8_t xx, tile;
th *= 2;
th += x;
tv *= 2;
tv += y;
tile = 0;
do
{
xx = x;
do
{
u8x8_draw_2x2_subglyph(u8x8, xx, y, encoding, tile);
tile++;
xx+=2;
} while( xx < th );
y+=2;
} while( y < tv );
void u8x8_Draw2x2Glyph(u8x8_t* u8x8, uint8_t x, uint8_t y, uint8_t encoding) {
uint8_t th = u8x8_pgm_read(u8x8->font + 2); /* new 2019 format */
uint8_t tv = u8x8_pgm_read(u8x8->font + 3); /* new 2019 format */
uint8_t xx, tile;
th *= 2;
th += x;
tv *= 2;
tv += y;
tile = 0;
do {
xx = x;
do {
u8x8_draw_2x2_subglyph(u8x8, xx, y, encoding, tile);
tile++;
xx += 2;
} while(xx < th);
y += 2;
} while(y < tv);
}
/* https://github.com/olikraus/u8g2/issues/474 */
static void u8x8_draw_1x2_subglyph(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t encoding, uint8_t tile)
{
uint8_t i;
uint16_t t;
uint8_t buf[8];
uint8_t buf1[8];
uint8_t buf2[8];
u8x8_get_glyph_data(u8x8, encoding, buf, tile);
for( i = 0; i < 8; i ++ )
{
t = u8x8_upscale_byte(buf[i]);
buf1[i] = t >> 8;
buf2[i] = t & 255;
}
u8x8_DrawTile(u8x8, x, y, 1, buf2);
u8x8_DrawTile(u8x8, x, y+1, 1, buf1);
static void
u8x8_draw_1x2_subglyph(u8x8_t* u8x8, uint8_t x, uint8_t y, uint8_t encoding, uint8_t tile) {
uint8_t i;
uint16_t t;
uint8_t buf[8];
uint8_t buf1[8];
uint8_t buf2[8];
u8x8_get_glyph_data(u8x8, encoding, buf, tile);
for(i = 0; i < 8; i++) {
t = u8x8_upscale_byte(buf[i]);
buf1[i] = t >> 8;
buf2[i] = t & 255;
}
u8x8_DrawTile(u8x8, x, y, 1, buf2);
u8x8_DrawTile(u8x8, x, y + 1, 1, buf1);
}
void u8x8_Draw1x2Glyph(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t encoding)
{
uint8_t th = u8x8_pgm_read(u8x8->font+2); /* new 2019 format */
uint8_t tv = u8x8_pgm_read(u8x8->font+3); /* new 2019 format */
uint8_t xx, tile;
th += x;
tv *= 2;
tv += y;
tile = 0;
do
{
xx = x;
do
{
u8x8_draw_1x2_subglyph(u8x8, xx, y, encoding, tile);
tile++;
xx++;
} while( xx < th );
y+=2;
} while( y < tv );
void u8x8_Draw1x2Glyph(u8x8_t* u8x8, uint8_t x, uint8_t y, uint8_t encoding) {
uint8_t th = u8x8_pgm_read(u8x8->font + 2); /* new 2019 format */
uint8_t tv = u8x8_pgm_read(u8x8->font + 3); /* new 2019 format */
uint8_t xx, tile;
th += x;
tv *= 2;
tv += y;
tile = 0;
do {
xx = x;
do {
u8x8_draw_1x2_subglyph(u8x8, xx, y, encoding, tile);
tile++;
xx++;
} while(xx < th);
y += 2;
} while(y < tv);
}
/*
@@ -282,16 +256,14 @@ Bits from to bytes Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6
*/
/* reset the internal state machine */
void u8x8_utf8_init(u8x8_t *u8x8)
{
u8x8->utf8_state = 0; /* also reset during u8x8_SetupDefaults() */
void u8x8_utf8_init(u8x8_t* u8x8) {
u8x8->utf8_state = 0; /* also reset during u8x8_SetupDefaults() */
}
uint16_t u8x8_ascii_next(U8X8_UNUSED u8x8_t *u8x8, uint8_t b)
{
if ( b == 0 || b == '\n' ) /* '\n' terminates the string to support the string list procedures */
return 0x0ffff; /* end of string detected*/
return b;
uint16_t u8x8_ascii_next(U8X8_UNUSED u8x8_t* u8x8, uint8_t b) {
if(b == 0 || b == '\n') /* '\n' terminates the string to support the string list procedures */
return 0x0ffff; /* end of string detected*/
return b;
}
/*
@@ -301,193 +273,145 @@ uint16_t u8x8_ascii_next(U8X8_UNUSED u8x8_t *u8x8, uint8_t b)
0x0ffff: end of string
anything else: The decoded encoding
*/
uint16_t u8x8_utf8_next(u8x8_t *u8x8, uint8_t b)
{
if ( b == 0 || b == '\n' ) /* '\n' terminates the string to support the string list procedures */
return 0x0ffff; /* end of string detected, pending UTF8 is discarded */
if ( u8x8->utf8_state == 0 )
{
if ( b >= 0xfc ) /* 6 byte sequence */
{
u8x8->utf8_state = 5;
b &= 1;
uint16_t u8x8_utf8_next(u8x8_t* u8x8, uint8_t b) {
if(b == 0 || b == '\n') /* '\n' terminates the string to support the string list procedures */
return 0x0ffff; /* end of string detected, pending UTF8 is discarded */
if(u8x8->utf8_state == 0) {
if(b >= 0xfc) /* 6 byte sequence */
{
u8x8->utf8_state = 5;
b &= 1;
} else if(b >= 0xf8) {
u8x8->utf8_state = 4;
b &= 3;
} else if(b >= 0xf0) {
u8x8->utf8_state = 3;
b &= 7;
} else if(b >= 0xe0) {
u8x8->utf8_state = 2;
b &= 15;
} else if(b >= 0xc0) {
u8x8->utf8_state = 1;
b &= 0x01f;
} else {
/* do nothing, just use the value as encoding */
return b;
}
u8x8->encoding = b;
return 0x0fffe;
} else {
u8x8->utf8_state--;
/* The case b < 0x080 (an illegal UTF8 encoding) is not checked here. */
u8x8->encoding <<= 6;
b &= 0x03f;
u8x8->encoding |= b;
if(u8x8->utf8_state != 0) return 0x0fffe; /* nothing to do yet */
}
else if ( b >= 0xf8 )
{
u8x8->utf8_state = 4;
b &= 3;
return u8x8->encoding;
}
static uint8_t u8x8_draw_string(u8x8_t* u8x8, uint8_t x, uint8_t y, const char* s) U8X8_NOINLINE;
static uint8_t u8x8_draw_string(u8x8_t* u8x8, uint8_t x, uint8_t y, const char* s) {
uint16_t e;
uint8_t cnt = 0;
uint8_t th = u8x8_pgm_read(u8x8->font + 2); /* new 2019 format */
u8x8_utf8_init(u8x8);
for(;;) {
e = u8x8->next_cb(u8x8, (uint8_t)*s);
if(e == 0x0ffff) break;
s++;
if(e != 0x0fffe) {
u8x8_DrawGlyph(u8x8, x, y, e);
x += th;
cnt++;
}
}
else if ( b >= 0xf0 )
{
u8x8->utf8_state = 3;
b &= 7;
return cnt;
}
uint8_t u8x8_DrawString(u8x8_t* u8x8, uint8_t x, uint8_t y, const char* s) {
u8x8->next_cb = u8x8_ascii_next;
return u8x8_draw_string(u8x8, x, y, s);
}
uint8_t u8x8_DrawUTF8(u8x8_t* u8x8, uint8_t x, uint8_t y, const char* s) {
u8x8->next_cb = u8x8_utf8_next;
return u8x8_draw_string(u8x8, x, y, s);
}
static uint8_t
u8x8_draw_2x2_string(u8x8_t* u8x8, uint8_t x, uint8_t y, const char* s) U8X8_NOINLINE;
static uint8_t u8x8_draw_2x2_string(u8x8_t* u8x8, uint8_t x, uint8_t y, const char* s) {
uint16_t e;
uint8_t cnt = 0;
uint8_t th = u8x8_pgm_read(u8x8->font + 2); /* new 2019 format */
th <<= 1;
u8x8_utf8_init(u8x8);
for(;;) {
e = u8x8->next_cb(u8x8, (uint8_t)*s);
if(e == 0x0ffff) break;
s++;
if(e != 0x0fffe) {
u8x8_Draw2x2Glyph(u8x8, x, y, e);
x += th;
cnt++;
}
}
else if ( b >= 0xe0 )
{
u8x8->utf8_state = 2;
b &= 15;
return cnt;
}
uint8_t u8x8_Draw2x2String(u8x8_t* u8x8, uint8_t x, uint8_t y, const char* s) {
u8x8->next_cb = u8x8_ascii_next;
return u8x8_draw_2x2_string(u8x8, x, y, s);
}
uint8_t u8x8_Draw2x2UTF8(u8x8_t* u8x8, uint8_t x, uint8_t y, const char* s) {
u8x8->next_cb = u8x8_utf8_next;
return u8x8_draw_2x2_string(u8x8, x, y, s);
}
static uint8_t
u8x8_draw_1x2_string(u8x8_t* u8x8, uint8_t x, uint8_t y, const char* s) U8X8_NOINLINE;
static uint8_t u8x8_draw_1x2_string(u8x8_t* u8x8, uint8_t x, uint8_t y, const char* s) {
uint16_t e;
uint8_t cnt = 0;
uint8_t th = u8x8_pgm_read(u8x8->font + 2); /* new 2019 format */
u8x8_utf8_init(u8x8);
for(;;) {
e = u8x8->next_cb(u8x8, (uint8_t)*s);
if(e == 0x0ffff) break;
s++;
if(e != 0x0fffe) {
u8x8_Draw1x2Glyph(u8x8, x, y, e);
x += th;
cnt++;
}
}
else if ( b >= 0xc0 )
{
u8x8->utf8_state = 1;
b &= 0x01f;
return cnt;
}
uint8_t u8x8_Draw1x2String(u8x8_t* u8x8, uint8_t x, uint8_t y, const char* s) {
u8x8->next_cb = u8x8_ascii_next;
return u8x8_draw_1x2_string(u8x8, x, y, s);
}
uint8_t u8x8_Draw1x2UTF8(u8x8_t* u8x8, uint8_t x, uint8_t y, const char* s) {
u8x8->next_cb = u8x8_utf8_next;
return u8x8_draw_1x2_string(u8x8, x, y, s);
}
uint8_t u8x8_GetUTF8Len(u8x8_t* u8x8, const char* s) {
uint16_t e;
uint8_t cnt = 0;
u8x8_utf8_init(u8x8);
for(;;) {
e = u8x8_utf8_next(u8x8, *s);
if(e == 0x0ffff) break;
s++;
if(e != 0x0fffe) cnt++;
}
else
{
/* do nothing, just use the value as encoding */
return b;
}
u8x8->encoding = b;
return 0x0fffe;
}
else
{
u8x8->utf8_state--;
/* The case b < 0x080 (an illegal UTF8 encoding) is not checked here. */
u8x8->encoding<<=6;
b &= 0x03f;
u8x8->encoding |= b;
if ( u8x8->utf8_state != 0 )
return 0x0fffe; /* nothing to do yet */
}
return u8x8->encoding;
return cnt;
}
static uint8_t u8x8_draw_string(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s) U8X8_NOINLINE;
static uint8_t u8x8_draw_string(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
{
uint16_t e;
uint8_t cnt = 0;
uint8_t th = u8x8_pgm_read(u8x8->font+2); /* new 2019 format */
u8x8_utf8_init(u8x8);
for(;;)
{
e = u8x8->next_cb(u8x8, (uint8_t)*s);
if ( e == 0x0ffff )
break;
s++;
if ( e != 0x0fffe )
{
u8x8_DrawGlyph(u8x8, x, y, e);
x+=th;
cnt++;
}
}
return cnt;
}
uint8_t u8x8_DrawString(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
{
u8x8->next_cb = u8x8_ascii_next;
return u8x8_draw_string(u8x8, x, y, s);
}
uint8_t u8x8_DrawUTF8(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
{
u8x8->next_cb = u8x8_utf8_next;
return u8x8_draw_string(u8x8, x, y, s);
}
static uint8_t u8x8_draw_2x2_string(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s) U8X8_NOINLINE;
static uint8_t u8x8_draw_2x2_string(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
{
uint16_t e;
uint8_t cnt = 0;
uint8_t th = u8x8_pgm_read(u8x8->font+2); /* new 2019 format */
th <<= 1;
u8x8_utf8_init(u8x8);
for(;;)
{
e = u8x8->next_cb(u8x8, (uint8_t)*s);
if ( e == 0x0ffff )
break;
s++;
if ( e != 0x0fffe )
{
u8x8_Draw2x2Glyph(u8x8, x, y, e);
x+=th;
cnt++;
}
}
return cnt;
}
uint8_t u8x8_Draw2x2String(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
{
u8x8->next_cb = u8x8_ascii_next;
return u8x8_draw_2x2_string(u8x8, x, y, s);
}
uint8_t u8x8_Draw2x2UTF8(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
{
u8x8->next_cb = u8x8_utf8_next;
return u8x8_draw_2x2_string(u8x8, x, y, s);
}
static uint8_t u8x8_draw_1x2_string(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s) U8X8_NOINLINE;
static uint8_t u8x8_draw_1x2_string(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
{
uint16_t e;
uint8_t cnt = 0;
uint8_t th = u8x8_pgm_read(u8x8->font+2); /* new 2019 format */
u8x8_utf8_init(u8x8);
for(;;)
{
e = u8x8->next_cb(u8x8, (uint8_t)*s);
if ( e == 0x0ffff )
break;
s++;
if ( e != 0x0fffe )
{
u8x8_Draw1x2Glyph(u8x8, x, y, e);
x+=th;
cnt++;
}
}
return cnt;
}
uint8_t u8x8_Draw1x2String(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
{
u8x8->next_cb = u8x8_ascii_next;
return u8x8_draw_1x2_string(u8x8, x, y, s);
}
uint8_t u8x8_Draw1x2UTF8(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s)
{
u8x8->next_cb = u8x8_utf8_next;
return u8x8_draw_1x2_string(u8x8, x, y, s);
}
uint8_t u8x8_GetUTF8Len(u8x8_t *u8x8, const char *s)
{
uint16_t e;
uint8_t cnt = 0;
u8x8_utf8_init(u8x8);
for(;;)
{
e = u8x8_utf8_next(u8x8, *s);
if ( e == 0x0ffff )
break;
s++;
if ( e != 0x0fffe )
cnt++;
}
return cnt;
}
+429 -472
View File
File diff suppressed because it is too large Load Diff
+433 -499
View File
File diff suppressed because it is too large Load Diff
+70 -85
View File
@@ -37,10 +37,8 @@
*/
#include "u8x8.h"
/*==========================================*/
/* internal library function */
@@ -49,11 +47,10 @@
It can be called within the display callback function to carry out the usual standard tasks.
*/
void u8x8_d_helper_display_setup_memory(u8x8_t *u8x8, const u8x8_display_info_t *display_info)
{
/* 1) set display info struct */
u8x8->display_info = display_info;
u8x8->x_offset = u8x8->display_info->default_x_offset;
void u8x8_d_helper_display_setup_memory(u8x8_t* u8x8, const u8x8_display_info_t* display_info) {
/* 1) set display info struct */
u8x8->display_info = display_info;
u8x8->x_offset = u8x8->display_info->default_x_offset;
}
/*
@@ -61,105 +58,93 @@ void u8x8_d_helper_display_setup_memory(u8x8_t *u8x8, const u8x8_display_info_t
It can be called within the display callback function to carry out the usual standard tasks.
*/
void u8x8_d_helper_display_init(u8x8_t *u8x8)
{
/* 2) apply port directions to the GPIO lines and apply default values for the IO lines*/
u8x8_gpio_Init(u8x8);
u8x8_cad_Init(u8x8);
void u8x8_d_helper_display_init(u8x8_t* u8x8) {
/* 2) apply port directions to the GPIO lines and apply default values for the IO lines*/
u8x8_gpio_Init(u8x8);
u8x8_cad_Init(u8x8);
/* 3) do reset */
u8x8_gpio_SetReset(u8x8, 1);
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, u8x8->display_info->reset_pulse_width_ms);
u8x8_gpio_SetReset(u8x8, 0);
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, u8x8->display_info->reset_pulse_width_ms);
u8x8_gpio_SetReset(u8x8, 1);
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, u8x8->display_info->post_reset_wait_ms);
}
/* 3) do reset */
u8x8_gpio_SetReset(u8x8, 1);
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, u8x8->display_info->reset_pulse_width_ms);
u8x8_gpio_SetReset(u8x8, 0);
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, u8x8->display_info->reset_pulse_width_ms);
u8x8_gpio_SetReset(u8x8, 1);
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, u8x8->display_info->post_reset_wait_ms);
}
/*==========================================*/
/* official functions */
uint8_t u8x8_DrawTile(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t cnt, uint8_t *tile_ptr)
{
u8x8_tile_t tile;
tile.x_pos = x;
tile.y_pos = y;
tile.cnt = cnt;
tile.tile_ptr = tile_ptr;
return u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_DRAW_TILE, 1, (void *)&tile);
uint8_t u8x8_DrawTile(u8x8_t* u8x8, uint8_t x, uint8_t y, uint8_t cnt, uint8_t* tile_ptr) {
u8x8_tile_t tile;
tile.x_pos = x;
tile.y_pos = y;
tile.cnt = cnt;
tile.tile_ptr = tile_ptr;
return u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_DRAW_TILE, 1, (void*)&tile);
}
/* should be implemented as macro */
void u8x8_SetupMemory(u8x8_t *u8x8)
{
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SETUP_MEMORY, 0, NULL);
void u8x8_SetupMemory(u8x8_t* u8x8) {
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SETUP_MEMORY, 0, NULL);
}
void u8x8_InitDisplay(u8x8_t *u8x8)
{
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_INIT, 0, NULL);
void u8x8_InitDisplay(u8x8_t* u8x8) {
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_INIT, 0, NULL);
}
void u8x8_SetPowerSave(u8x8_t *u8x8, uint8_t is_enable)
{
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SET_POWER_SAVE, is_enable, NULL);
void u8x8_SetPowerSave(u8x8_t* u8x8, uint8_t is_enable) {
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SET_POWER_SAVE, is_enable, NULL);
}
void u8x8_SetFlipMode(u8x8_t *u8x8, uint8_t mode)
{
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SET_FLIP_MODE, mode, NULL);
void u8x8_SetFlipMode(u8x8_t* u8x8, uint8_t mode) {
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SET_FLIP_MODE, mode, NULL);
}
void u8x8_SetContrast(u8x8_t *u8x8, uint8_t value)
{
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SET_CONTRAST, value, NULL);
void u8x8_SetContrast(u8x8_t* u8x8, uint8_t value) {
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SET_CONTRAST, value, NULL);
}
void u8x8_RefreshDisplay(u8x8_t *u8x8)
{
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_REFRESH, 0, NULL);
void u8x8_RefreshDisplay(u8x8_t* u8x8) {
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_REFRESH, 0, NULL);
}
void u8x8_ClearDisplayWithTile(u8x8_t *u8x8, const uint8_t *buf)
{
u8x8_tile_t tile;
uint8_t h;
void u8x8_ClearDisplayWithTile(u8x8_t* u8x8, const uint8_t* buf) {
u8x8_tile_t tile;
uint8_t h;
tile.x_pos = 0;
tile.cnt = 1;
tile.tile_ptr = (uint8_t *)buf; /* tile_ptr should be const, but isn't */
h = u8x8->display_info->tile_height;
tile.y_pos = 0;
do
{
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_DRAW_TILE, u8x8->display_info->tile_width, (void *)&tile);
tile.y_pos++;
} while( tile.y_pos < h );
}
void u8x8_ClearDisplay(u8x8_t *u8x8)
{
uint8_t buf[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
u8x8_ClearDisplayWithTile(u8x8, buf);
}
void u8x8_FillDisplay(u8x8_t *u8x8)
{
uint8_t buf[8] = { 255, 255, 255, 255, 255, 255, 255, 255 };
u8x8_ClearDisplayWithTile(u8x8, buf);
}
void u8x8_ClearLine(u8x8_t *u8x8, uint8_t line)
{
uint8_t buf[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
u8x8_tile_t tile;
if ( line < u8x8->display_info->tile_height )
{
tile.x_pos = 0;
tile.y_pos = line;
tile.cnt = 1;
tile.tile_ptr = (uint8_t *)buf; /* tile_ptr should be const, but isn't */
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_DRAW_TILE, u8x8->display_info->tile_width, (void *)&tile);
}
tile.tile_ptr = (uint8_t*)buf; /* tile_ptr should be const, but isn't */
h = u8x8->display_info->tile_height;
tile.y_pos = 0;
do {
u8x8->display_cb(
u8x8, U8X8_MSG_DISPLAY_DRAW_TILE, u8x8->display_info->tile_width, (void*)&tile);
tile.y_pos++;
} while(tile.y_pos < h);
}
void u8x8_ClearDisplay(u8x8_t* u8x8) {
uint8_t buf[8] = {0, 0, 0, 0, 0, 0, 0, 0};
u8x8_ClearDisplayWithTile(u8x8, buf);
}
void u8x8_FillDisplay(u8x8_t* u8x8) {
uint8_t buf[8] = {255, 255, 255, 255, 255, 255, 255, 255};
u8x8_ClearDisplayWithTile(u8x8, buf);
}
void u8x8_ClearLine(u8x8_t* u8x8, uint8_t line) {
uint8_t buf[8] = {0, 0, 0, 0, 0, 0, 0, 0};
u8x8_tile_t tile;
if(line < u8x8->display_info->tile_height) {
tile.x_pos = 0;
tile.y_pos = line;
tile.cnt = 1;
tile.tile_ptr = (uint8_t*)buf; /* tile_ptr should be const, but isn't */
u8x8->display_cb(
u8x8, U8X8_MSG_DISPLAY_DRAW_TILE, u8x8->display_info->tile_width, (void*)&tile);
}
}
+2 -5
View File
@@ -33,13 +33,10 @@
*/
#include "u8x8.h"
void u8x8_gpio_call(u8x8_t *u8x8, uint8_t msg, uint8_t arg)
{
u8x8->gpio_and_delay_cb(u8x8, msg, arg, NULL);
void u8x8_gpio_call(u8x8_t* u8x8, uint8_t msg, uint8_t arg) {
u8x8->gpio_and_delay_cb(u8x8, msg, arg, NULL);
}
/*
+67 -66
View File
@@ -33,67 +33,67 @@
*/
#include "u8x8.h"
/* universal dummy callback, which will be default for all callbacks */
uint8_t u8x8_dummy_cb(U8X8_UNUSED u8x8_t *u8x8, U8X8_UNUSED uint8_t msg, U8X8_UNUSED uint8_t arg_int, U8X8_UNUSED void *arg_ptr)
{
/* the dummy callback will not handle any message and will fail for all messages */
return 0;
uint8_t u8x8_dummy_cb(
U8X8_UNUSED u8x8_t* u8x8,
U8X8_UNUSED uint8_t msg,
U8X8_UNUSED uint8_t arg_int,
U8X8_UNUSED void* arg_ptr) {
/* the dummy callback will not handle any message and will fail for all messages */
return 0;
}
static const u8x8_display_info_t u8x8_null_display_info = {
/* chip_enable_level = */ 0,
/* chip_disable_level = */ 1,
static const u8x8_display_info_t u8x8_null_display_info =
{
/* chip_enable_level = */ 0,
/* chip_disable_level = */ 1,
/* post_chip_enable_wait_ns = */ 0,
/* pre_chip_disable_wait_ns = */ 0,
/* reset_pulse_width_ms = */ 0,
/* post_reset_wait_ms = */ 0,
/* sda_setup_time_ns = */ 0,
/* sck_pulse_width_ns = */ 0, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
/* spi_mode = */ 0, /* active high, rising edge */
/* i2c_bus_clock_100kHz = */ 4,
/* data_setup_time_ns = */ 0,
/* write_pulse_width_ns = */ 0,
/* tile_width = */ 1, /* 8x8 */
/* tile_hight = */ 1,
/* default_x_offset = */ 0,
/* flipmode_x_offset = */ 0,
/* pixel_width = */ 8,
/* pixel_height = */ 8
};
/* post_chip_enable_wait_ns = */ 0,
/* pre_chip_disable_wait_ns = */ 0,
/* reset_pulse_width_ms = */ 0,
/* post_reset_wait_ms = */ 0,
/* sda_setup_time_ns = */ 0,
/* sck_pulse_width_ns = */
0, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
/* sck_clock_hz = */
4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
/* spi_mode = */ 0, /* active high, rising edge */
/* i2c_bus_clock_100kHz = */ 4,
/* data_setup_time_ns = */ 0,
/* write_pulse_width_ns = */ 0,
/* tile_width = */ 1, /* 8x8 */
/* tile_hight = */ 1,
/* default_x_offset = */ 0,
/* flipmode_x_offset = */ 0,
/* pixel_width = */ 8,
/* pixel_height = */ 8};
/* a special null device */
uint8_t u8x8_d_null_cb(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, U8X8_UNUSED void *arg_ptr)
{
switch(msg)
{
uint8_t u8x8_d_null_cb(
u8x8_t* u8x8,
uint8_t msg,
U8X8_UNUSED uint8_t arg_int,
U8X8_UNUSED void* arg_ptr) {
switch(msg) {
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_null_display_info);
break;
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_null_display_info);
break;
case U8X8_MSG_DISPLAY_INIT:
u8x8_d_helper_display_init(u8x8);
break;
}
/* the null device callback will succeed for all messages */
return 1;
u8x8_d_helper_display_init(u8x8);
break;
}
/* the null device callback will succeed for all messages */
return 1;
}
/*
Description:
Setup u8x8
Args:
u8x8 An empty u8x8 structure
*/
void u8x8_SetupDefaults(u8x8_t *u8x8)
{
void u8x8_SetupDefaults(u8x8_t* u8x8) {
u8x8->display_info = NULL;
u8x8->display_cb = u8x8_dummy_cb;
u8x8->cad_cb = u8x8_dummy_cb;
@@ -101,21 +101,19 @@ void u8x8_SetupDefaults(u8x8_t *u8x8)
u8x8->gpio_and_delay_cb = u8x8_dummy_cb;
u8x8->is_font_inverse_mode = 0;
//u8x8->device_address = 0;
u8x8->utf8_state = 0; /* also reset by u8x8_utf8_init */
u8x8->bus_clock = 0; /* issue 769 */
u8x8->utf8_state = 0; /* also reset by u8x8_utf8_init */
u8x8->bus_clock = 0; /* issue 769 */
u8x8->i2c_address = 255;
u8x8->debounce_default_pin_state = 255; /* assume all low active buttons */
#ifdef U8X8_USE_PINS
{
uint8_t i;
for( i = 0; i < U8X8_PIN_CNT; i++ )
u8x8->pins[i] = U8X8_PIN_NONE;
}
u8x8->debounce_default_pin_state = 255; /* assume all low active buttons */
#ifdef U8X8_USE_PINS
{
uint8_t i;
for(i = 0; i < U8X8_PIN_CNT; i++) u8x8->pins[i] = U8X8_PIN_NONE;
}
#endif
}
/*
Description:
Setup u8x8 and assign the callback function. The dummy
@@ -130,18 +128,21 @@ void u8x8_SetupDefaults(u8x8_t *u8x8)
gpio_and_delay_cb Environment specific callback function
*/
void u8x8_Setup(u8x8_t *u8x8, u8x8_msg_cb display_cb, u8x8_msg_cb cad_cb, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)
{
/* setup defaults and reset pins to U8X8_PIN_NONE */
u8x8_SetupDefaults(u8x8);
void u8x8_Setup(
u8x8_t* u8x8,
u8x8_msg_cb display_cb,
u8x8_msg_cb cad_cb,
u8x8_msg_cb byte_cb,
u8x8_msg_cb gpio_and_delay_cb) {
/* setup defaults and reset pins to U8X8_PIN_NONE */
u8x8_SetupDefaults(u8x8);
/* setup specific callbacks */
u8x8->display_cb = display_cb;
u8x8->cad_cb = cad_cb;
u8x8->byte_cb = byte_cb;
u8x8->gpio_and_delay_cb = gpio_and_delay_cb;
/* setup specific callbacks */
u8x8->display_cb = display_cb;
u8x8->cad_cb = cad_cb;
u8x8->byte_cb = byte_cb;
u8x8->gpio_and_delay_cb = gpio_and_delay_cb;
/* setup display info */
u8x8_SetupMemory(u8x8);
/* setup display info */
u8x8_SetupMemory(u8x8);
}