-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
92 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/** | ||
* @file lv_helloworld.ino | ||
* @author Lewis He ([email protected]) | ||
* @license MIT | ||
* @copyright Copyright (c) 2024 Shenzhen Xin Yuan Electronic Technology Co., Ltd | ||
* @date 2024-01-27 | ||
*/ | ||
|
||
#include <LilyGo_RGBPanel.h> | ||
#include <LV_Helper.h> | ||
|
||
LilyGo_RGBPanel panel; | ||
|
||
static void btn_event_cb(lv_event_t *e) | ||
{ | ||
lv_event_code_t code = lv_event_get_code(e); | ||
lv_obj_t *btn = lv_event_get_target(e); | ||
if (code == LV_EVENT_CLICKED) { | ||
static uint8_t cnt = 0; | ||
cnt++; | ||
/*Get the first child of the button which is the label and change its text*/ | ||
lv_obj_t *label = lv_obj_get_child(btn, 0); | ||
lv_label_set_text_fmt(label, "Button: %d", cnt); | ||
Serial.printf("Button :%d\n", cnt); | ||
} | ||
} | ||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
|
||
|
||
// Initialize T-RGB, if the initialization fails, false will be returned. | ||
if (!panel.begin()) { | ||
while (1) { | ||
Serial.println("Error, failed to initialize T-RGB"); delay(1000); | ||
} | ||
} | ||
|
||
// Call lvgl initialization | ||
beginLvglHelper(panel); | ||
|
||
|
||
lv_obj_t *label = lv_label_create(lv_scr_act()); /*Add a label the current screen*/ | ||
lv_label_set_text(label, "Hello World"); /*Set label text*/ | ||
lv_obj_center(label); /*Set center alignment*/ | ||
|
||
|
||
lv_obj_t *btn = lv_btn_create(lv_scr_act()); /*Add a button the current screen*/ | ||
lv_obj_set_size(btn, 120, 50); /*Set its size*/ | ||
lv_obj_add_event_cb(btn, btn_event_cb, LV_EVENT_ALL, NULL); /*Assign a callback to the button*/ | ||
lv_obj_align_to(btn, label, LV_ALIGN_OUT_BOTTOM_MID, 0, 0); /*Set the label to it and align it in the center below the label*/ | ||
|
||
lv_obj_t *btn_label = lv_label_create(btn); /*Add a label to the button*/ | ||
lv_label_set_text(btn_label, "Button"); /*Set the labels text*/ | ||
lv_obj_center(btn_label); | ||
|
||
// Turn on the backlight and set it to the highest value, ranging from 0 to 16 | ||
panel.setBrightness(16); | ||
} | ||
|
||
|
||
void loop() | ||
{ | ||
// lvgl task processing should be placed in the loop function | ||
lv_timer_handler(); | ||
delay(2); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,13 +10,14 @@ | |
|
||
[platformio] | ||
|
||
src_dir = examples/lv_factory | ||
; src_dir = examples/lv_factory | ||
; src_dir = examples/lv_benchmark | ||
; src_dir = examples/lv_music | ||
; src_dir = examples/lv_images | ||
; src_dir = examples/lv_gif | ||
; src_dir = examples/lv_qrcode | ||
; src_dir = examples/TFT_eSPI_Sprite | ||
src_dir = examples/lv_helloworld | ||
|
||
; src_dir = examples/RGBPanel | ||
; src_dir = examples/Touchpad | ||
|
@@ -31,7 +32,6 @@ boards_dir = boards | |
|
||
[env:T-RGB] | ||
lib_extra_dirs = ${PROJECT_DIR} | ||
lib_ignore = lib_deps | ||
platform = [email protected] | ||
board = LilyGo-T-RGB | ||
framework = arduino | ||
|
@@ -48,10 +48,10 @@ build_flags = | |
-DLV_CONF_SUPPRESS_DEFINE_CHECK | ||
|
||
; Enable UARDUINO_USB_CDC_ON_BOOT will start printing and wait for terminal access during startup | ||
; -DARDUINO_USB_CDC_ON_BOOT=1 | ||
-DARDUINO_USB_CDC_ON_BOOT=1 | ||
|
||
; Enable UARDUINO_USB_CDC_ON_BOOT will turn off printing and will not block when using the battery | ||
-UARDUINO_USB_CDC_ON_BOOT | ||
; -UARDUINO_USB_CDC_ON_BOOT | ||
|
||
|
||
-DCORE_DEBUG_LEVEL=0 | ||
|