fixed issue with utf8 output
This commit is contained in:
parent
901676cfc9
commit
4209ca2cdb
|
@ -120,9 +120,11 @@ static void u8g2_draw_hv_line_2dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u
|
|||
|
||||
y -= u8g2->tile_curr_row*8;
|
||||
|
||||
h = u8g2->pixel_buf_height;
|
||||
w = u8g2->pixel_buf_width;
|
||||
|
||||
h = u8g2->pixel_buf_height; // this must be the real buffer height
|
||||
w = u8g2->pixel_buf_width; // this could be replaced by u8g2->u8x8.display_info->pixel_width
|
||||
|
||||
|
||||
if ( dir == 0 )
|
||||
{
|
||||
if ( y >= h )
|
||||
|
|
|
@ -103,7 +103,7 @@ void u8g2_update_dimension_r0(u8g2_t *u8g2)
|
|||
u8g2_update_dimension_common(u8g2);
|
||||
|
||||
u8g2->user_x0 = 0;
|
||||
u8g2->user_x1 = u8g2->width; /* pixel_buf_width replaced with width */
|
||||
u8g2->user_x1 = u8g2->pixel_buf_width; /* pixel_buf_width replaced with width */
|
||||
|
||||
u8g2->user_y0 = u8g2->buf_y0;
|
||||
u8g2->user_y1 = u8g2->buf_y1;
|
||||
|
@ -123,7 +123,7 @@ void u8g2_update_dimension_r1(u8g2_t *u8g2)
|
|||
u8g2->user_x1 = u8g2->buf_y1;
|
||||
|
||||
u8g2->user_y0 = 0;
|
||||
u8g2->user_y1 = u8g2->width; /* pixel_buf_width replaced with width */
|
||||
u8g2->user_y1 = u8g2->height; /* pixel_buf_width replaced with height (which is the real pixel width) */
|
||||
|
||||
//printf("x0=%d x1=%d y0=%d y1=%d\n",
|
||||
// u8g2->user_x0, u8g2->user_x1, u8g2->user_y0, u8g2->user_y1);
|
||||
|
@ -154,7 +154,7 @@ void u8g2_update_dimension_r3(u8g2_t *u8g2)
|
|||
u8g2->user_x1 = u8g2->width - u8g2->buf_y0;
|
||||
|
||||
u8g2->user_y0 = 0;
|
||||
u8g2->user_y1 = u8g2->width; /* pixel_buf_width replaced with width */
|
||||
u8g2->user_y1 = u8g2->height; /* pixel_buf_width replaced with height (pixel_width) */
|
||||
|
||||
// printf("x0=%d x1=%d y0=%d y1=%d\n",
|
||||
// u8g2->user_x0, u8g2->user_x1, u8g2->user_y0, u8g2->user_y1);
|
||||
|
|
|
@ -228,7 +228,7 @@ struct u8x8_display_info_struct
|
|||
uint8_t default_x_offset; /* default x offset for the display */
|
||||
|
||||
/* pixel width is not used by the u8x8 procedures */
|
||||
/* instead it will be used by the u8g2 procedure, because the pixel dimension can */
|
||||
/* instead it will be used by the u8g2 procedures, because the pixel dimension can */
|
||||
/* not always be calculated from the tile_width/_height */
|
||||
/* the following conditions must be true: */
|
||||
/* pixel_width <= tile_width*8 */
|
||||
|
|
|
@ -115,7 +115,7 @@ static const u8x8_display_info_t u8x8_uc1701_display_info =
|
|||
/* i2c_bus_clock_100kHz = */ 37,
|
||||
/* data_setup_time_ns = */ 30,
|
||||
/* write_pulse_width_ns = */ 40,
|
||||
/* tile_width = */ 13,
|
||||
/* tile_width = */ 13, /* width of 13*8=104 pixel */
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ U8X8_IF_DEFAULT_NORMAL_OR_FLIP(0, 30),
|
||||
/* pixel_width = */ 102,
|
||||
|
|
|
@ -4,15 +4,16 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define CHGR_WIDTH 96
|
||||
//#define CHGR_WIDTH 96
|
||||
#define CHGR_WIDTH 102
|
||||
#define CHGR_HEIGHT 32
|
||||
unsigned char chgr_bitmap[CHGR_HEIGHT/2][CHGR_WIDTH/2];
|
||||
|
||||
unsigned char *chgr_bitmap_pos(unsigned x, unsigned y)
|
||||
{
|
||||
if ( x > CHGR_WIDTH )
|
||||
if ( x >= CHGR_WIDTH )
|
||||
return NULL;
|
||||
if ( y > CHGR_HEIGHT )
|
||||
if ( y >= CHGR_HEIGHT )
|
||||
return NULL;
|
||||
return &(chgr_bitmap[y/2][x/2]);
|
||||
}
|
||||
|
@ -146,8 +147,8 @@ static const u8x8_display_info_t u8x8_utf8_info =
|
|||
/* i2c_bus_clock_100kHz = */ 0,
|
||||
/* data_setup_time_ns = */ 0,
|
||||
/* write_pulse_width_ns = */ 0,
|
||||
/* tile_width = */ (CHGR_WIDTH)/8,
|
||||
/* tile_hight = */ (CHGR_HEIGHT)/8,
|
||||
/* tile_width = */ (CHGR_WIDTH+7)/8,
|
||||
/* tile_hight = */ (CHGR_HEIGHT+7)/8,
|
||||
#if U8X8_DEFAULT_FLIP_MODE == 0
|
||||
/* default_x_offset = */ 0,
|
||||
#else
|
||||
|
@ -219,7 +220,7 @@ void u8x8_Setup_Utf8(u8x8_t *u8x8)
|
|||
|
||||
void u8g2_SetupBuffer_Utf8(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
|
||||
{
|
||||
static uint8_t buf[CHGR_WIDTH*8];
|
||||
static uint8_t buf[CHGR_WIDTH*8]; // i guess this is to big. it should be (CHGR_WIDTH+7)/8
|
||||
|
||||
u8x8_Setup_Utf8(u8g2_GetU8x8(u8g2));
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
CC = gcc
|
||||
|
||||
CFLAGS = -g -W -Wall -Wextra -Wcast-qual -Wno-overlength-strings -Wno-unused-parameter -I../../../csrc/.
|
||||
|
||||
SRC = $(shell ls ../../../csrc/*.c) $(shell ls ../common/*.c ) main.c
|
||||
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
u8g2_utf8: $(OBJ)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) -o u8g2_utf8
|
||||
|
||||
clean:
|
||||
-rm $(OBJ) u8g2_utf8
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
this example was written to debug a problem with a display width, which
|
||||
is not multiple of 8.
|
||||
the display width is set to 102 for this purpose
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "u8g2.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
u8g2_t u8g2;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
u8g2_SetupBuffer_Utf8(&u8g2, U8G2_R1);
|
||||
|
||||
|
||||
u8g2_InitDisplay(&u8g2);
|
||||
u8g2_SetPowerSave(&u8g2, 0);
|
||||
|
||||
u8g2_SetFont(&u8g2, u8g2_font_6x13_tf);
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
|
||||
u8g2_FirstPage(&u8g2);
|
||||
do
|
||||
{
|
||||
|
||||
//u8g2_DrawFrame(&u8g2, 0, 0,
|
||||
// u8g2_GetDisplayWidth(&u8g2), u8g2_GetDisplayHeight(&u8g2));
|
||||
//u8g2_DrawHLine(&u8g2, 0, 0, u8g2_GetDisplayWidth(&u8g2));
|
||||
u8g2_DrawHLine(&u8g2, 0, u8g2_GetDisplayHeight(&u8g2)-1, u8g2_GetDisplayWidth(&u8g2));
|
||||
//u8g2_DrawHLine(&u8g2, 0, 32, 10);
|
||||
// u8g2_DrawStr(&u8g2, 10, 20, "Frame");
|
||||
//u8g2_DrawStr(&u8g2, u8g2_GetDisplayWidth(&u8g2)-9, 10, "Frame");
|
||||
//u8g2_DrawStr(&u8g2, u8g2_GetDisplayWidth(&u8g2)-8, 20, "Frame");
|
||||
//u8g2_DrawStr(&u8g2, u8g2_GetDisplayWidth(&u8g2)-7, 30, "Frame");
|
||||
} while( u8g2_NextPage(&u8g2) );
|
||||
|
||||
utf8_show();
|
||||
|
||||
printf("DisplayWidth = %d\n", u8g2_GetDisplayWidth(&u8g2));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue