Test.ino
#include <lvgl.h>
// uncomment a library for display driver
#define USE_TFT_ESPI_LIBRARY
// #define USE_ARDUINO_GFX_LIBRARY
#include "lv_xiao_round_screen.h"
#include "lv_hardware_test.h"
void setup()
{
Serial.begin( 115200 ); //prepare for possible serial debug
Serial.println( "XIAO round screen - LVGL_Arduino" );
// Map SPI port to 'new' pins
#define SS 28
#define MOSI 3
#define MISO 4
#define SCK 2
Serial.println("--------------");
Serial.println(SS);
Serial.println(MOSI); // master out, slave in
Serial.println(MISO); // master in, slave out
Serial.println(SCK); // clock
Serial.println("--------------");
lv_init();
lv_xiao_disp_init();
lv_xiao_touch_init();
lv_hardware_test();
}
void loop()
{
lv_timer_handler(); //let the GUI do its work
delay( 5 );
}
lv_hardware_test.h
#include <SD.h>
#define NUM_ADC_SAMPLE 20
#define RP2040_VREF 3300 // The actual voltage on 3V3 pin. (unit: mV)
static lv_obj_t *slider_label;
static void event_handler(lv_event_t * e)
{
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t * obj = lv_event_get_target(e);
if(code == LV_EVENT_VALUE_CHANGED) {
LV_LOG_USER("State: %s\n", lv_obj_has_state(obj, LV_STATE_CHECKED) ? "On" : "Off");
}
}
static void hardware_polled_cb(lv_timer_t * timer) {
lv_obj_t *tf_state = (lv_obj_t *)timer->user_data;
if(SD.begin(A1)){
lv_obj_add_state(tf_state, LV_STATE_CHECKED);
lv_obj_t * test_label = lv_label_create(lv_scr_act());
lv_label_set_text(test_label, "Success");
lv_obj_set_pos(test_label, 90, 110);
delay(4000);
SD.end();
} else {
lv_obj_clear_state(tf_state, LV_STATE_CHECKED);
lv_obj_t * test_label = lv_label_create(lv_scr_act());
lv_label_set_text(test_label, "Failure");
lv_obj_set_pos(test_label, 90, 110);
}
}
void lv_hardware_test(void)
{
lv_obj_t * tf_label = lv_label_create(lv_scr_act());
lv_label_set_text(tf_label, "tf-card");
lv_obj_set_pos(tf_label, 90, 130);
lv_obj_t * tf_state = lv_switch_create(lv_scr_act());
lv_obj_set_pos(tf_state, 90, 150);
lv_obj_add_state(tf_state, LV_STATE_CHECKED | LV_STATE_DISABLED);
lv_obj_add_event_cb(tf_state, event_handler, LV_EVENT_ALL, NULL);
lv_timer_create(hardware_polled_cb, 7000, tf_state);
analogReadResolution(12);
#if defined(ARDUINO_SEEED_XIAO_NRF52840_SENSE) || defined(ARDUINO_SEEED_XIAO_NRF52840)
analogReference(AR_INTERNAL2V4); // 0.6V ref 1/4 Gain
#endif
}
I’m using a modified hardware test example, just using the SD card components, added a “success/failure” condition label.
The compiler output (verbose compile) doesn’t have much, pretty much just the libraries used and file locations.