diff --git a/openrtx/src/graphics/graphics_bw.c b/openrtx/src/graphics/graphics_bw.c index 8b9ad60d..c52bf705 100644 --- a/openrtx/src/graphics/graphics_bw.c +++ b/openrtx/src/graphics/graphics_bw.c @@ -197,11 +197,13 @@ static inline uint16_t get_line_size(GFXfont f, * @param alinment: enum representing the text alignment * @param line_size: the size of the current text line in pixels */ -static inline uint16_t get_reset_x(textAlign_t alignment, uint16_t line_size) { +static inline uint16_t get_reset_x(textAlign_t alignment, + uint16_t line_size, + uint16_t startx) { switch(alignment) { case TEXT_ALIGN_LEFT: - return 0; + return startx; case TEXT_ALIGN_CENTER: return (SCREEN_WIDTH - line_size)/2; case TEXT_ALIGN_RIGHT: @@ -220,7 +222,7 @@ void gfx_print(point_t start, const char *text, fontSize_t size, textAlign_t ali // Compute size of the first row in pixels uint16_t line_size = get_line_size(f, text, len); - uint16_t reset_x = get_reset_x(alignment, line_size); + uint16_t reset_x = get_reset_x(alignment, line_size, start.x); start.x = reset_x; /* For each char in the string */ @@ -249,7 +251,7 @@ void gfx_print(point_t start, const char *text, fontSize_t size, textAlign_t ali if (start.x + glyph.xAdvance > SCREEN_WIDTH) { // Compute size of the first row in pixels line_size = get_line_size(f, text, len); - start.x = reset_x = get_reset_x(alignment, line_size); + start.x = reset_x = get_reset_x(alignment, line_size, start.x); start.y += f.yAdvance; } diff --git a/openrtx/src/graphics/graphics_rgb565.c b/openrtx/src/graphics/graphics_rgb565.c index 775b0869..19229d59 100644 --- a/openrtx/src/graphics/graphics_rgb565.c +++ b/openrtx/src/graphics/graphics_rgb565.c @@ -196,11 +196,13 @@ static inline uint16_t get_line_size(GFXfont f, * @param alinment: enum representing the text alignment * @param line_size: the size of the current text line in pixels */ -static inline uint16_t get_reset_x(textAlign_t alignment, uint16_t line_size) { +static inline uint16_t get_reset_x(textAlign_t alignment, + uint16_t line_size, + uint16_t startx) { switch(alignment) { case TEXT_ALIGN_LEFT: - return 0; + return startx; case TEXT_ALIGN_CENTER: return (SCREEN_WIDTH - line_size)/2; case TEXT_ALIGN_RIGHT: @@ -219,7 +221,7 @@ void gfx_print(point_t start, const char *text, fontSize_t size, textAlign_t ali // Compute size of the first row in pixels uint16_t line_size = get_line_size(f, text, len); - uint16_t reset_x = get_reset_x(alignment, line_size); + uint16_t reset_x = get_reset_x(alignment, line_size, start.x); start.x = reset_x; /* For each char in the string */ @@ -248,7 +250,7 @@ void gfx_print(point_t start, const char *text, fontSize_t size, textAlign_t ali if (start.x + glyph.xAdvance > SCREEN_WIDTH) { // Compute size of the first row in pixels line_size = get_line_size(f, text, len); - start.x = reset_x = get_reset_x(alignment, line_size); + start.x = reset_x = get_reset_x(alignment, line_size, start.x); start.y += f.yAdvance; } diff --git a/openrtx/src/ui.c b/openrtx/src/ui.c index 831af042..3f08d6d8 100644 --- a/openrtx/src/ui.c +++ b/openrtx/src/ui.c @@ -185,11 +185,11 @@ layout_t _ui_calculateLayout() #endif // Calculate printing positions - point_t top_pos = {0, top_h - vertical_pad}; - point_t line1_pos = {0, top_h + line1_h - line_pad}; - point_t line2_pos = {0, top_h + line1_h + line2_h - line_pad}; - point_t line3_pos = {0, top_h + line1_h + line2_h + line3_h - line_pad}; - point_t bottom_pos = {0, top_h + line1_h + line2_h + line3_h + bottom_h - vertical_pad}; + point_t top_pos = {horizontal_pad, top_h - vertical_pad}; + point_t line1_pos = {horizontal_pad, top_h + line1_h - line_pad}; + point_t line2_pos = {horizontal_pad, top_h + line1_h + line2_h - line_pad}; + point_t line3_pos = {horizontal_pad, top_h + line1_h + line2_h + line3_h - line_pad}; + point_t bottom_pos = {horizontal_pad, top_h + line1_h + line2_h + line3_h + bottom_h - vertical_pad}; layout_t new_layout = {