Hi There,
I'm working with E-Ink display connected with nRF52 chip. I have a base library to display images and works very well.
Now I'm trying to use GFX library to support text drawing. Using the default rotation (0 degrees) seems to work fine. When I try with 90 or 270 degrees, the text rotates but doesn't fill the whole screen (only few characters), instead the text jumps to next line.
I have tried different font sizes and the result is the same.
I attach the images for reference, any help will be appreciated. Thanks in advance!
Jhon
=======
Details:
- MCU: nRF52832
- SDK: v15.30
Text rotation 0 degrees:
Text rotation 90 degrees:
My code to talk with GFX library.
#include <stdio.h> #include <string.h> #include "app_error.h" #include "app_util_platform.h" #include "app_error.h" #include "nrf_lcd.h" #include "nrf_gfx.h" #include "nrf_log.h" #include "nrf_delay.h" #include "epaper_screen.h" #define PAPER_PIXEL_WIDTH 176 #define PAPER_PIXEL_HEIGHT 264 ret_code_t paper_init(void); void paper_uninit(void); void paper_pixel_draw(uint16_t x, uint16_t y, uint32_t color); void paper_rect_draw(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint32_t color); void paper_display(void); void paper_rotation_set(nrf_lcd_rotation_t rotation); void paper_display_invert(bool invert); static lcd_cb_t lcd_cb = { .state = NRFX_DRV_STATE_UNINITIALIZED, .height = PAPER_PIXEL_HEIGHT, .width = PAPER_PIXEL_WIDTH, .rotation = NRF_LCD_ROTATE_90 }; static const nrf_lcd_t lcd = { .lcd_init = paper_init, .lcd_uninit = paper_uninit, .lcd_pixel_draw = paper_pixel_draw, .lcd_rect_draw = paper_rect_draw, .lcd_display = paper_display, .lcd_rotation_set = paper_rotation_set, .lcd_display_invert = paper_display_invert, .p_lcd_cb = &lcd_cb }; //extern const nrf_gfx_font_desc_t orkney_8ptFontInfo; //static const nrf_gfx_font_desc_t * p_font = &orkney_8ptFontInfo; extern const nrf_gfx_font_desc_t orkney_24ptFontInfo; static const nrf_gfx_font_desc_t * p_font = &orkney_24ptFontInfo; //extern const nrf_gfx_font_desc_t HelveticaNB_120ptFontInfo; //static const nrf_gfx_font_desc_t * p_font = &HelveticaNB_120ptFontInfo; #define PAPER_BYTE_WIDTH ((PAPER_PIXEL_WIDTH % 8 == 0) ? PAPER_PIXEL_WIDTH / 8 : PAPER_PIXEL_WIDTH / 8 + 1) #define PAPER_BYTE_HEIGHT PAPER_PIXEL_HEIGHT #define PAPER_BUFLEN PAPER_BYTE_WIDTH * PAPER_BYTE_HEIGHT //static uint8_t paper_buffer[PAPER_BUFLEN]; static uint8_t* paper_buffer = NULL; ret_code_t paper_init(void) { paper_buffer = (uint8_t*)malloc(PAPER_BUFLEN*sizeof(uint8_t)); memset(paper_buffer, 0x00, PAPER_BUFLEN*sizeof(uint8_t)); epaper_Display_Init(); return NRF_SUCCESS; } void paper_uninit(void) { epaper_Display_DeInit(); } #define SWAP(a,b) { int16_t t = a; a = b; b = t;} void paper_pixel_draw(uint16_t x, uint16_t y, uint32_t color) { ASSERT(x < PAPER_PIXEL_WIDTH); ASSERT(y < PAPER_PIXEL_HEIGHT); switch (lcd.p_lcd_cb->rotation) { case 1: SWAP(x, y); x = PAPER_PIXEL_WIDTH - x - 1; break; case 2: x = PAPER_PIXEL_WIDTH - x - 1; y = PAPER_PIXEL_HEIGHT - y - 1; break; case 3: SWAP(x, y); y = PAPER_PIXEL_HEIGHT - y - 1; break; } int bitn = y * PAPER_PIXEL_WIDTH + x; int byten = bitn / 8; bitn = 8 - bitn % 8 - 1; if (color == 0) paper_buffer[byten] |= 1UL << (bitn); else paper_buffer[byten] &= ~(1UL << (bitn)); } void paper_rect_draw(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint32_t color) { ASSERT(x + width < PAPER_PIXEL_WIDTH); ASSERT(y + height < PAPER_PIXEL_HEIGHT); for (uint16_t _x = x; _x < x + width; _x++) { for (uint16_t _y = y; _y < y + height; _y++) { paper_pixel_draw(_x, _y, color); } } } void paper_display(void) { epaper_PartialScreen_Display(0, 0, 176, 264, paper_buffer, 5808); } void paper_rotation_set(nrf_lcd_rotation_t rotation) { UNUSED_PARAMETER(rotation); } void paper_display_invert(bool invert) { UNUSED_PARAMETER(invert); } ///////////////////////// /* Aplication functions*/ ///////////////////////// void gui_interface_init(void) { APP_ERROR_CHECK(nrf_gfx_init(&lcd)); } void gui_interface_print_text(uint16_t x, uint16_t y, const uint8_t* text) { nrf_gfx_point_t text_start = NRF_GFX_POINT(x, y); APP_ERROR_CHECK(nrf_gfx_print(&lcd, &text_start, 0, text, p_font, true)); } void gui_interface_display(void) { nrf_gfx_display(&lcd); }