changed #ifdefs and GCC detection in u8x8
fixed cast issues in u8g2_font.c
This commit is contained in:
parent
c2e377e573
commit
e9febcfe6a
13
csrc/u8g2.h
13
csrc/u8g2.h
|
@ -148,6 +148,9 @@ extern "C" {
|
|||
/*==========================================*/
|
||||
|
||||
typedef uint16_t u8g2_uint_t; /* for pixel position only */
|
||||
typedef int16_t u8g2_int_t; /* introduced for circle calculation */
|
||||
typedef int32_t u8g2_long_t; /* introduced for ellipse calculation */
|
||||
|
||||
|
||||
typedef struct u8g2_struct u8g2_t;
|
||||
typedef struct u8g2_cb_struct u8g2_cb_t;
|
||||
|
@ -413,6 +416,16 @@ uint8_t u8g2_IsIntersection(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_u
|
|||
#endif /* U8G2_WITH_INTERSECTION */
|
||||
|
||||
|
||||
|
||||
/*==========================================*/
|
||||
/* u8g2_circle.c */
|
||||
#define U8G2_DRAW_UPPER_RIGHT 0x01
|
||||
#define U8G2_DRAW_UPPER_LEFT 0x02
|
||||
#define U8G2_DRAW_LOWER_LEFT 0x04
|
||||
#define U8G2_DRAW_LOWER_RIGHT 0x08
|
||||
#define U8G2_DRAW_ALL (U8G2_DRAW_UPPER_RIGHT|U8G2_DRAW_UPPER_LEFT|U8G2_DRAW_LOWER_RIGHT|U8G2_DRAW_LOWER_LEFT)
|
||||
|
||||
|
||||
/*==========================================*/
|
||||
/* u8g2_box.c */
|
||||
void u8g2_DrawBox(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h);
|
||||
|
|
|
@ -111,7 +111,7 @@ void u8g2_font_GetStrMinBox(u8g2_t *u8g2, const void *font, const char *s, u8g2_
|
|||
static uint8_t u8g2_font_get_byte(const uint8_t *font, uint8_t offset)
|
||||
{
|
||||
font += offset;
|
||||
return u8x8_pgm_read( (uint8_t *)font );
|
||||
return u8x8_pgm_read( font );
|
||||
}
|
||||
|
||||
static uint16_t u8g2_font_get_word(const uint8_t *font, uint8_t offset) U8G2_NOINLINE;
|
||||
|
@ -119,10 +119,10 @@ static uint16_t u8g2_font_get_word(const uint8_t *font, uint8_t offset)
|
|||
{
|
||||
uint16_t pos;
|
||||
font += offset;
|
||||
pos = u8x8_pgm_read( (uint8_t *)font );
|
||||
pos = u8x8_pgm_read( font );
|
||||
font++;
|
||||
pos <<= 8;
|
||||
pos += u8x8_pgm_read( (uint8_t *)font);
|
||||
pos += u8x8_pgm_read( font);
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
@ -175,9 +175,9 @@ size_t u8g2_GetFontSize(const uint8_t *font_arg)
|
|||
|
||||
for(;;)
|
||||
{
|
||||
if ( u8x8_pgm_read( ((uint8_t *)font) + 1 ) == 0 )
|
||||
if ( u8x8_pgm_read( font + 1 ) == 0 )
|
||||
break;
|
||||
font += u8x8_pgm_read( ((uint8_t *)font) + 1 );
|
||||
font += u8x8_pgm_read( font + 1 );
|
||||
}
|
||||
|
||||
/* continue with unicode section */
|
||||
|
@ -185,15 +185,15 @@ size_t u8g2_GetFontSize(const uint8_t *font_arg)
|
|||
|
||||
for(;;)
|
||||
{
|
||||
e = u8x8_pgm_read( ((uint8_t *)font) );
|
||||
e = u8x8_pgm_read( font );
|
||||
e <<= 8;
|
||||
e |= u8x8_pgm_read( ((uint8_t *)font) + 1 );
|
||||
e |= u8x8_pgm_read( font + 1 );
|
||||
if ( e == 0 )
|
||||
break;
|
||||
font += u8x8_pgm_read( ((uint8_t *)font) + 2 );
|
||||
font += u8x8_pgm_read( font + 2 );
|
||||
}
|
||||
|
||||
return (font - (const uint8_t *)font_arg) + 2;
|
||||
return (font - font_arg) + 2;
|
||||
}
|
||||
|
||||
/*========================================================================*/
|
||||
|
@ -238,7 +238,7 @@ uint8_t u8g2_font_decode_get_unsigned_bits(u8g2_font_decode_t *f, uint8_t cnt)
|
|||
uint8_t bit_pos_plus_cnt;
|
||||
|
||||
//val = *(f->decode_ptr);
|
||||
val = u8x8_pgm_read( (uint8_t *)(f->decode_ptr) );
|
||||
val = u8x8_pgm_read( f->decode_ptr );
|
||||
|
||||
val >>= bit_pos;
|
||||
bit_pos_plus_cnt = bit_pos;
|
||||
|
@ -249,7 +249,7 @@ uint8_t u8g2_font_decode_get_unsigned_bits(u8g2_font_decode_t *f, uint8_t cnt)
|
|||
s -= bit_pos;
|
||||
f->decode_ptr++;
|
||||
//val |= *(f->decode_ptr) << (8-bit_pos);
|
||||
val |= u8x8_pgm_read( (uint8_t *)(f->decode_ptr) ) << (s);
|
||||
val |= u8x8_pgm_read( f->decode_ptr ) << (s);
|
||||
//bit_pos -= 8;
|
||||
bit_pos_plus_cnt -= 8;
|
||||
}
|
||||
|
@ -591,13 +591,13 @@ const uint8_t *u8g2_font_get_glyph_data(u8g2_t *u8g2, uint16_t encoding)
|
|||
|
||||
for(;;)
|
||||
{
|
||||
if ( u8x8_pgm_read( ((uint8_t *)font) + 1 ) == 0 )
|
||||
if ( u8x8_pgm_read( font + 1 ) == 0 )
|
||||
break;
|
||||
if ( u8x8_pgm_read( (uint8_t *)font ) == encoding )
|
||||
if ( u8x8_pgm_read( font ) == encoding )
|
||||
{
|
||||
return font+2; /* skip encoding and glyph size */
|
||||
}
|
||||
font += u8x8_pgm_read( ((uint8_t *)font) + 1 );
|
||||
font += u8x8_pgm_read( font + 1 );
|
||||
}
|
||||
}
|
||||
#ifdef U8G2_WITH_UNICODE
|
||||
|
@ -607,9 +607,9 @@ const uint8_t *u8g2_font_get_glyph_data(u8g2_t *u8g2, uint16_t encoding)
|
|||
font += u8g2->font_info.start_pos_unicode;
|
||||
for(;;)
|
||||
{
|
||||
e = u8x8_pgm_read( ((uint8_t *)font) );
|
||||
e = u8x8_pgm_read( font );
|
||||
e <<= 8;
|
||||
e |= u8x8_pgm_read( ((uint8_t *)font) + 1 );
|
||||
e |= u8x8_pgm_read( font + 1 );
|
||||
|
||||
if ( e == 0 )
|
||||
break;
|
||||
|
@ -618,7 +618,7 @@ const uint8_t *u8g2_font_get_glyph_data(u8g2_t *u8g2, uint16_t encoding)
|
|||
{
|
||||
return font+3; /* skip encoding and glyph size */
|
||||
}
|
||||
font += u8x8_pgm_read( ((uint8_t *)font) + 2 );
|
||||
font += u8x8_pgm_read( font + 2 );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -125,8 +125,8 @@ void u8g2_update_dimension_r1(u8g2_t *u8g2)
|
|||
u8g2->user_y0 = 0;
|
||||
u8g2->user_y1 = u8g2->pixel_buf_width;
|
||||
|
||||
printf("x0=%d x1=%d y0=%d y1=%d\n",
|
||||
u8g2->user_x0, u8g2->user_x1, u8g2->user_y0, u8g2->user_y1);
|
||||
//printf("x0=%d x1=%d y0=%d y1=%d\n",
|
||||
// u8g2->user_x0, u8g2->user_x1, u8g2->user_y0, u8g2->user_y1);
|
||||
}
|
||||
|
||||
void u8g2_update_dimension_r2(u8g2_t *u8g2)
|
||||
|
|
|
@ -123,19 +123,22 @@ extern "C" {
|
|||
|
||||
#ifdef __GNUC__
|
||||
# define U8X8_NOINLINE __attribute__((noinline))
|
||||
# define U8X8_SECTION(name) __attribute__ ((section (name)))
|
||||
#else
|
||||
# define U8X8_SECTION(name)
|
||||
# define U8X8_NOINLINE
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && defined(__AVR__)
|
||||
# define U8X8_SECTION(name) __attribute__ ((section (name)))
|
||||
# define U8X8_FONT_SECTION(name) U8X8_SECTION(".progmem." name)
|
||||
# define u8x8_pgm_read(adr) pgm_read_byte_near(adr)
|
||||
#endif
|
||||
|
||||
#ifndef U8X8_SECTION
|
||||
# define U8X8_SECTION(name) __attribute__ ((section (name)))
|
||||
#ifndef U8X8_FONT_SECTION
|
||||
# define U8X8_FONT_SECTION(name)
|
||||
#endif
|
||||
|
||||
#ifndef u8x8_pgm_read
|
||||
# define u8x8_pgm_read(adr) (*(const uint8_t *)(adr))
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
CC = gcc
|
||||
|
||||
CFLAGS = -g -Wall -I../../../csrc/.
|
||||
CFLAGS = -g -Wall -Wextra -Wcast-qual -I../../../csrc/.
|
||||
|
||||
SRC = $(shell ls ../../../csrc/*.c) $(shell ls ../common/*.c ) main.c
|
||||
|
||||
|
|
Loading…
Reference in New Issue