Description
I want to scroll a very long multiple line dynamic text (information) circularly in vertical direction on OLED. I have created a label and set the text accordingly. I am able to scroll the label circularly in vertical direction (upward) but the behavior is not consistent, sometimes the label scrolls horizontally as well as vertically in downward direction. How can I get the circular scrolling of label in vertical upward direction consistently for dynamic text?
What MCU/Processor/Board and compiler are you using?
Processor - AM335x
OLED display - SSD1306 (64x128)
compiler - ARM toolchain - gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf
What LVGL version are you using?
v8.2
What do you want to achieve?
I want to achieve the circular scrolling of label in vertical upward direction consistently for dynamic text.
What have you tried so far?
I have tried the following text input to function lvglSetAndScrollTextVertically.
- input - “aaaaaaaaaaaaa\n bbbbbb\n bbbbbbbbbbbbbbbb\n ccccccccccccc\n
cccccc\n dddddddddddddddddd\n eeeeee\n eeeeeeeeeeeee\n ffffff\n” - input - “Max Rate : $0\nUnit Price : $0.0\nActivation Fee : $0.0\nParking Fee : $0.0\n
Version : None\nTotal power : 0\n”
As the text input is dynamic I am unable to get circular scrolling work consistently.
Code to reproduce
/**
* Macros
*/
/* Animation duration (in milliseconds) */
#define LV_ANIMATION_DURATION 40000
#define LV_OBJ_SIZE_XOFFSET 126
#define LV_OBJ_SIZE_YOFFSET 8
#define LV_OBJ_ALIGN_XOFFSET 0
#define LV_OBJ_ALIGN_YOFFSET 8
/* Animation delay (in milliseconds) */
#define LV_ANIMATION_DELAY 1000
/* Scrolling delay (in milliseconds) */
#define LV_ANIMATION_REPEAT_DELAY 185
#### Scrolling function ##########
void lvglSetAndScrollTextVertically (lv_obj_t *dispLabel, char *dispText)
{
static lv_anim_t animation_template;
static lv_style_t label_style;
lv_anim_init(&animation_template);
/* Set animation duration (in milliseconds) */
lv_anim_set_time(&animation_template, LV_ANIMATION_DURATION);
/*Wait 1 second to start the first scroll*/
lv_anim_set_delay(&animation_template, LV_ANIMATION_DELAY);
/*Repeat the scroll after the label scrolls back to the initial position*/
lv_anim_set_repeat_delay(&animation_template, LV_ANIMATION_REPEAT_DELAY);
/*Initialize the label style with the animation template*/
lv_style_init(&label_style);
lv_style_set_anim(&label_style, &animation_template);
/*Circular scroll*/
lv_label_set_long_mode(dispLabel, LV_LABEL_LONG_SCROLL_CIRCULAR);
printf("\n ########data#########\n %s \n", dispText);
//lv_obj_set_width(dispLabel, 16);
lv_obj_set_size(dispLabel, LV_OBJ_SIZE_XOFFSET, LV_OBJ_SIZE_YOFFSET);
lv_label_set_text(dispLabel, dispText);
lv_obj_align(dispLabel, LV_ALIGN_CENTER, LV_OBJ_ALIGN_XOFFSET, LV_OBJ_ALIGN_YOFFSET);
lv_obj_set_style_text_font(dispLabel, &lv_font_montserrat_10, LV_PART_MAIN);
/*Add the style to the label*/
lv_obj_add_style(dispLabel, &label_style, LV_STATE_DEFAULT);
}