Scrolling Text Field #12817
Replies: 2 comments
The marquee is created wronglyYour ESP32/LVGL setup is perfect. The problem is the way you're trying to create the marquee. That is a circular character rotation, not a normal news-ticker scroll. Also, LV_LABEL_LONG_CLIP doesn't make LVGL automatically scroll the label. The much simpler solution is to let LVGL do the scrolling itself. LVGL has a built-in label mode specifically for this: Though code is actually doing several things correctly, two different concepts are being mixed together: changing the text and scrolling the text. |
|
Hello @kevinasia82 You don't actually need to build the scrolling logic yourself. LVGL has this built in as a feature of the label widget, so instead of tracking Two things make it work: lv_label_set_long_mode(your_label, LV_LABEL_LONG_SCROLL_CIRCULAR); // turn on scrolling
lv_obj_set_width(your_label, 300); // set a FIXED width, after the line aboveReplace The one thing that trips almost everyone up here: by default, a label's width auto-expands to fit its text ( Since your project uses SquareLine Studio (I can see
Once that's set, you can delete your Sources
|
Uh oh!
There was an error while loading. Please reload this page.
I am quite new to ESP32 and not an engineer but understood (with help of AI). I am trying to build a news ticker but I can just not get the text scrolling in my text box. Below is what tired (I will integrate the relevant code into bigger project later on). I just want my text to scroll in my text box. Any help would be fantastic....
#include <Arduino.h>
#include <lvgl.h>
#include <Wire.h>
#include "esp_lcd_panel_io.h"
#include "esp_lcd_panel_vendor.h"
#include "esp_lcd_panel_ops.h"
#include "esp_lcd_panel_rgb.h"
// Wrap SquareLine C headers so the C++ compiler links them correctly
extern "C" {
#include "ui.h"
}
// --- SCREEN SETTINGS ---
#define LCD_WIDTH 800
#define LCD_HEIGHT 480
#define I2C_SDA 15
#define I2C_SCL 16
#define LCD_HSYNC 40
#define LCD_VSYNC 41
#define LCD_DE 42
#define LCD_PCLK 39
static lv_disp_draw_buf_t draw_buf;
static lv_color_t *buf1;
static lv_color_t *buf2;
esp_lcd_panel_handle_t panel_handle = NULL;
String global_headline = " *** The company, called Infoassa, had advertised at least six events at its premises over the last four months. Checks by CNA found that the most recent event on Aug 7 never took place. *** ";
int scroll_index = 0;
unsigned long last_scroll_tick = 0;
void initCrowPanelBacklight() {
Wire.begin(I2C_SDA, I2C_SCL);
delay(50);
Wire.beginTransmission(0x30);
Wire.write(0x10);
Wire.endTransmission();
delay(50);
Wire.beginTransmission(0x30);
Wire.write(0x00);
Wire.endTransmission();
}
void my_disp_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p) {
if (panel_handle != NULL) {
esp_lcd_panel_draw_bitmap(panel_handle, area->x1, area->y1, area->x2 + 1, area->y2 + 1, color_p);
}
lv_disp_flush_ready(disp_drv);
}
void updateTickerText() {
if (global_headline.length() > 0) {
// Shift characters circularly for a smooth scrolling effect
String shifted = global_headline.substring(scroll_index) + global_headline.substring(0, scroll_index);
}
void setup() {
Serial.begin(115200);
delay(2000);
Serial.println("\n--- SYSTEM BOOT (FINAL FULLY-REVIEWED MARQUEE) ---");
}
void loop() {
lv_timer_handler();
delay(5);
}
All reactions