mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-30 07:06:19 +08:00
Fix buf name error for "lv_port_disp_template.c" and optimize the arduino example (#2475)
* fix(buf) correct the name error * fix(format) make the indent become 4 space * fix(print) use lv_version_xxx to serial for debug * fix(arduino) optimize the code * fix(arduino) use lv_version_xxx to serial
This commit is contained in:
@@ -8,15 +8,15 @@
|
|||||||
|
|
||||||
#include <lv_demo.h>
|
#include <lv_demo.h>
|
||||||
|
|
||||||
TFT_eSPI tft = TFT_eSPI(); /* TFT instance */
|
|
||||||
|
|
||||||
/*Change to your screen resolution*/
|
/*Change to your screen resolution*/
|
||||||
static const uint32_t screenWidth = 480;
|
static const uint16_t screenWidth = 480;
|
||||||
static const uint32_t screenHeight = 320;
|
static const uint16_t screenHeight = 320;
|
||||||
|
|
||||||
static lv_disp_draw_buf_t draw_buf;
|
static lv_disp_draw_buf_t draw_buf;
|
||||||
static lv_color_t buf[ screenWidth * 10 ];
|
static lv_color_t buf[ screenWidth * 10 ];
|
||||||
|
|
||||||
|
TFT_eSPI tft = TFT_eSPI(screenWidth, screenHeight); /* TFT instance */
|
||||||
|
|
||||||
#if LV_USE_LOG != 0
|
#if LV_USE_LOG != 0
|
||||||
/* Serial debugging */
|
/* Serial debugging */
|
||||||
void my_print( lv_log_level_t level, const char * file, uint32_t line, const char * fn_name, const char * dsc )
|
void my_print( lv_log_level_t level, const char * file, uint32_t line, const char * fn_name, const char * dsc )
|
||||||
@@ -70,7 +70,11 @@ void my_touchpad_read( lv_indev_drv_t * indev_driver, lv_indev_data_t * data )
|
|||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
Serial.begin( 115200 ); /* prepare for possible serial debug */
|
Serial.begin( 115200 ); /* prepare for possible serial debug */
|
||||||
Serial.println( "Hello Arduino! (V8.0.X)" );
|
|
||||||
|
String LVGL_Arduino = "Hello Arduino! ";
|
||||||
|
LVGL_Arduino += String('V') + lv_version_major() + "." + lv_version_minor() + "." + lv_version_patch();
|
||||||
|
|
||||||
|
Serial.println( LVGL_Arduino );
|
||||||
Serial.println( "I am LVGL_Arduino" );
|
Serial.println( "I am LVGL_Arduino" );
|
||||||
|
|
||||||
lv_init();
|
lv_init();
|
||||||
@@ -110,7 +114,7 @@ void setup()
|
|||||||
#if 0
|
#if 0
|
||||||
/* Create simple label */
|
/* Create simple label */
|
||||||
lv_obj_t *label = lv_label_create( lv_scr_act() );
|
lv_obj_t *label = lv_label_create( lv_scr_act() );
|
||||||
lv_label_set_text( label, "Hello Arduino! (V8.0.X)" );
|
lv_label_set_text( label, LVGL_Arduino.c_str() );
|
||||||
lv_obj_align( label, LV_ALIGN_CENTER, 0, 0 );
|
lv_obj_align( label, LV_ALIGN_CENTER, 0, 0 );
|
||||||
#else
|
#else
|
||||||
/* Try an example from the lv_examples Arduino library
|
/* Try an example from the lv_examples Arduino library
|
||||||
|
|||||||
@@ -81,13 +81,13 @@ void lv_port_disp_init(void)
|
|||||||
/* Example for 2) */
|
/* Example for 2) */
|
||||||
static lv_disp_draw_buf_t draw_buf_dsc_2;
|
static lv_disp_draw_buf_t draw_buf_dsc_2;
|
||||||
static lv_color_t buf_2_1[MY_DISP_HOR_RES * 10]; /*A buffer for 10 rows*/
|
static lv_color_t buf_2_1[MY_DISP_HOR_RES * 10]; /*A buffer for 10 rows*/
|
||||||
static lv_color_t buf_2_1[MY_DISP_HOR_RES * 10]; /*An other buffer for 10 rows*/
|
static lv_color_t buf_2_2[MY_DISP_HOR_RES * 10]; /*An other buffer for 10 rows*/
|
||||||
lv_disp_draw_buf_init(&draw_buf_dsc_2, buf_2_1, buf_2_1, MY_DISP_HOR_RES * 10); /*Initialize the display buffer*/
|
lv_disp_draw_buf_init(&draw_buf_dsc_2, buf_2_1, buf_2_2, MY_DISP_HOR_RES * 10); /*Initialize the display buffer*/
|
||||||
|
|
||||||
/* Example for 3) also set disp_drv.full_refresh = 1 below*/
|
/* Example for 3) also set disp_drv.full_refresh = 1 below*/
|
||||||
static lv_disp_draw_buf_t draw_buf_dsc_3;
|
static lv_disp_draw_buf_t draw_buf_dsc_3;
|
||||||
static lv_color_t buf_3_1[MY_DISP_HOR_RES * MY_DISP_VER_RES]; /*A screen sized buffer*/
|
static lv_color_t buf_3_1[MY_DISP_HOR_RES * MY_DISP_VER_RES]; /*A screen sized buffer*/
|
||||||
static lv_color_t buf_3_1[MY_DISP_HOR_RES * MY_DISP_VER_RES]; /*An other screen sized buffer*/
|
static lv_color_t buf_3_2[MY_DISP_HOR_RES * MY_DISP_VER_RES]; /*An other screen sized buffer*/
|
||||||
lv_disp_draw_buf_init(&draw_buf_dsc_3, buf_3_1, buf_3_2, MY_DISP_VER_RES * LV_VER_RES_MAX); /*Initialize the display buffer*/
|
lv_disp_draw_buf_init(&draw_buf_dsc_3, buf_3_1, buf_3_2, MY_DISP_VER_RES * LV_VER_RES_MAX); /*Initialize the display buffer*/
|
||||||
|
|
||||||
/*-----------------------------------
|
/*-----------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user