| 
									
										
										
										
											2025-02-14 15:02:49 -05:00
										 |  |  | #include "display.h"
 | 
					
						
							| 
									
										
										
										
											2025-02-13 19:31:11 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "esp_log.h"
 | 
					
						
							|  |  |  | #include "lvgl.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void setup() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2025-02-14 15:02:49 -05:00
										 |  |  |   Display d; | 
					
						
							| 
									
										
										
										
											2025-02-13 19:31:11 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // UI function
 | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2025-02-14 15:50:35 -05:00
										 |  |  |     // Lock the mutex due to the LVGL APIs are not thread-safe
 | 
					
						
							|  |  |  |     ScopedLock lock(Display::lvgl_api_lock_); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ESP_LOGI(TAG, "Display LVGL Scroll Text"); | 
					
						
							| 
									
										
										
										
											2025-02-14 15:56:15 -05:00
										 |  |  |     lv_obj_t *scr = lv_display_get_screen_active(d.get()); | 
					
						
							| 
									
										
										
										
											2025-02-13 19:31:11 -05:00
										 |  |  |     lv_obj_t *label = lv_label_create(scr); | 
					
						
							|  |  |  |     // Circular scroll
 | 
					
						
							| 
									
										
										
										
											2025-02-14 15:56:15 -05:00
										 |  |  |     lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR); | 
					
						
							|  |  |  |     lv_label_set_text(label, "Hello hello hello hello hello hello hello."); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-13 19:31:11 -05:00
										 |  |  |     // Size of the screen
 | 
					
						
							|  |  |  |     // if you use rotation 90 or 270 use lv_display_get_vertical_resolution
 | 
					
						
							| 
									
										
										
										
											2025-02-14 15:56:15 -05:00
										 |  |  |     lv_obj_set_width(label, lv_display_get_horizontal_resolution(*d)); | 
					
						
							| 
									
										
										
										
											2025-02-13 19:31:11 -05:00
										 |  |  |     lv_obj_align(label, LV_ALIGN_TOP_MID, 0, 0); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void loop() { } |