Rotating a text label
When a label is constructed, it’s text follows a standard direction. It is possible to rotate the label, but how?
MCU and board
STM32F205RET (128K SRAM, 512K Flash) in a custom board, with gcc-arm(1) , GNU make(1) , and STM32 HAL .
LVGL version
7.11.0
What do you want to achieve?
I want to display a text label in the usual way, but add one or two source code lines to rotate it ninety degrees.
What have you tried so far?
Canvas
I tried using a canvas transform, but because my display is monochrome (OLED SSD1306) and buffer LV_IMG_CF_INDEXED_1BIT the canvas draw functions such as lv_canvas_draw_text(3) appear to fail.
Style
I tried adding a style to my text label, but it did not work. Maybe styles in 1-bit displays are defective just like the canvas draw functions?
Code to reproduce
I’m using the following source code block as a starting point. Please tell me how to modify this to rotate the text by ninety degrees?
// Create a label to rotate
lv_obj_t *pLabel = lv_label_create(lv_scr_act(), NULL);
lv_label_set_long_mode(pLabel, LV_LABEL_LONG_EXPAND);
lv_obj_set_width(pLabel, lv_obj_get_height(lv_scr_act()));
lv_label_set_text(pLabel, "Bodacious");
// Add a rotated style to the label
static lv_style_t style_label;
lv_style_init(&style_label);
lv_style_set_transform_angle(&style_label, LV_STATE_DEFAULT, 900);
lv_obj_add_style(pLabel, LV_LABEL_PART_MAIN, &style_label);