I am working with a 1024x100 display connected to an STM32F429 microcontroller. I have been able to rotate some text on my display in the way I needed, but I would like to see if there is a better way I could do it with less memory. By default, LVGL draws the text on my display rotated 90 degrees from how I want it. Currently, I am just using a canvas that is 100x100 so I can draw my text to the canvas in the default direction and then rotate it 90 degrees to the way I want it. My text could fit in something that is only 15x100, but I can’t figure out how to make LVGL change the direction the text is drawn in without rotating the entire canvas. I was only able to attach a single image, so I will attach an example of the default orientation of the text. I want the text to be perpendicular to the default orientation.
int main(void)
{
HAL_Init();
/* Configure the system clock to 180 MHz */
SystemClock_Config();
lv_init();
tft_init();
lv_obj_t * scr = lv_disp_get_scr_act(NULL); /*Get the current screen*/
lv_color_t textCanvasBuf[100*100];
lv_obj_t * textCanvas;
static lv_style_t style;
lv_style_copy(&style, &lv_style_plain);
style.body.radius = 0;
style.body.border.width = 0;
style.body.border.color = LV_COLOR_TRANSP;
style.body.shadow.color = LV_COLOR_TRANSP;
style.body.shadow.width = 0;
style.line.width = 0;
style.line.color = LV_COLOR_BLACK;
style.text.color = LV_COLOR_BLACK;
textCanvas = lv_canvas_create(lv_scr_act(), NULL);
while (1)
{
HAL_Delay(10);
lv_task_handler();
memset(textCanvasBuf, 0xFF, sizeof(textCanvasBuf));
lv_canvas_set_buffer(textCanvas, textCanvasBuf, TEXT_CANVAS_WIDTH,
TEXT_CANVAS_HEIGHT, LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED);
lv_obj_set_pos(textCanvas, 80, 0);
lv_canvas_draw_text(textCanvas, 0, 0, TEXT_CANVAS_HEIGHT, &lv_style_scr, "Some test text",
LV_LABEL_ALIGN_CENTER);
lv_color_t cbuf_tmp[100 * 100];
memcpy(cbuf_tmp, textCanvasBuf, sizeof(cbuf_tmp));
memset(textCanvasBuf, 0xFF, sizeof(textCanvasBuf));
lv_img_dsc_t img;
img.data = (void *)cbuf_tmp;
img.header.cf = LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED;
img.header.w = 100;
img.header.h = 100;
lv_canvas_fill_bg(textCanvas, LV_COLOR_LIME);
lv_canvas_rotate(textCanvas, &img, 270, 0, 100, 0, 0);
}
}
Default orientation: