Created
May 28, 2025 23:14
-
-
Save stajkowski/ccceaee8e4ec7df386b23679c22293dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD | |
* | |
* SPDX-License-Identifier: CC0-1.0 | |
*/ | |
#include "waveshare_rgb_lcd_port.h" | |
void test_screen(); | |
void app_main() | |
{ | |
waveshare_esp32_s3_rgb_lcd_init(); // Initialize the Waveshare ESP32-S3 RGB LCD | |
// wavesahre_rgb_lcd_bl_on(); //Turn on the screen backlight | |
// wavesahre_rgb_lcd_bl_off(); //Turn off the screen backlight | |
ESP_LOGI(TAG, "Display LVGL demos"); | |
// Lock the mutex due to the LVGL APIs are not thread-safe | |
if (lvgl_port_lock(-1)) { | |
// lv_demo_stress(); | |
// lv_demo_benchmark(); | |
// lv_demo_music(); | |
// lv_demo_widgets(); | |
// example_lvgl_demo_ui(); | |
test_screen(); | |
// Release the mutex | |
lvgl_port_unlock(); | |
} | |
} | |
static lv_obj_t * meter; | |
static void set_value(void * indic, int32_t v) | |
{ | |
lv_meter_set_indicator_end_value(meter, indic, v); | |
} | |
void test_screen() | |
{ | |
static lv_style_t style; | |
lv_style_init(&style); | |
lv_style_set_flex_flow(&style, LV_FLEX_FLOW_ROW); | |
lv_style_set_flex_main_place(&style, LV_FLEX_ALIGN_START); | |
lv_style_set_layout(&style, LV_LAYOUT_FLEX); | |
lv_obj_t * cont = lv_obj_create(lv_scr_act()); | |
lv_obj_set_size(cont, 800, 480); | |
lv_obj_align(cont, LV_ALIGN_TOP_LEFT, 0, 0); | |
lv_obj_add_style(cont, &style, 0); | |
lv_obj_set_style_pad_all(cont, 40, 0); | |
meter = lv_meter_create(cont); | |
lv_obj_set_size(meter, 300, 300); | |
/*Remove the circle from the middle*/ | |
lv_obj_remove_style(meter, NULL, LV_PART_INDICATOR); | |
/*Add a scale first*/ | |
lv_meter_scale_t * scale = lv_meter_add_scale(meter); | |
lv_meter_set_scale_ticks(meter, scale, 11, 2, 10, lv_palette_main(LV_PALETTE_GREY)); | |
lv_meter_set_scale_major_ticks(meter, scale, 1, 2, 30, lv_color_hex3(0xeee), 10); | |
lv_meter_set_scale_range(meter, scale, 0, 100, 270, 90); | |
/*Add a three arc indicator*/ | |
lv_meter_indicator_t * indic1 = lv_meter_add_arc(meter, scale, 10, lv_palette_main(LV_PALETTE_RED), 0); | |
lv_meter_indicator_t * indic2 = lv_meter_add_arc(meter, scale, 10, lv_palette_main(LV_PALETTE_GREEN), -10); | |
lv_meter_indicator_t * indic3 = lv_meter_add_arc(meter, scale, 10, lv_palette_main(LV_PALETTE_BLUE), -20); | |
/*Create an animation to set the value*/ | |
lv_anim_t a; | |
lv_anim_init(&a); | |
lv_anim_set_exec_cb(&a, set_value); | |
lv_anim_set_values(&a, 0, 100); | |
lv_anim_set_repeat_delay(&a, 100); | |
lv_anim_set_playback_delay(&a, 100); | |
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE); | |
lv_anim_set_time(&a, 2000); | |
lv_anim_set_playback_time(&a, 500); | |
lv_anim_set_var(&a, indic1); | |
lv_anim_start(&a); | |
lv_anim_set_time(&a, 1000); | |
lv_anim_set_playback_time(&a, 1000); | |
lv_anim_set_var(&a, indic2); | |
lv_anim_start(&a); | |
lv_anim_set_time(&a, 1000); | |
lv_anim_set_playback_time(&a, 2000); | |
lv_anim_set_var(&a, indic3); | |
lv_anim_start(&a); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment