Scrolling Text Field #12817
Unanswered
kevinasia82
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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