Added SDCard test

This commit is contained in:
lewishe
2022-08-30 14:00:40 +08:00
parent cb5f57fb9a
commit 69e48e46f3
4 changed files with 34 additions and 2 deletions

4
CHANGELOG.md Executable file → Normal file
View File

@@ -1,4 +1,8 @@
# Changelog
## (8.30.22)
- <examples/Shield/S7XG/S7xG_LoRa> Added SDCard test
## (8.19.2022)
- Update wifi event macro name <examples/LVGL/SimpleWatch>

View File

@@ -9,7 +9,7 @@ Ticker btnTicker;
uint32_t state = 0, prev_state = 0;
bool isInit = false;
lv_obj_t *btn2, *btn1, *btn3, *ta1, *gContainer;
bool sdOnline = false;
void createWin();
void stop_prev();
@@ -172,6 +172,7 @@ void pressed()
void setup(void)
{
uint32_t cardSize = 0;
Serial.begin(115200);
ttgo = TTGOClass::getWatch();
@@ -179,6 +180,18 @@ void setup(void)
ttgo->tft->fillScreen(TFT_BLACK);
ttgo->openBL();
if (ttgo->sdcard_begin()) {
Serial.println("SDCard begin SUCCESS!");
cardSize = SD.cardSize() / (1024 * 1024);
Serial.print("setupSDCard PASS . SIZE = ");
Serial.print(cardSize);
Serial.println(" MB");
sdOnline = true;
} else {
Serial.println("SDCard begin FAILED!");
}
ttgo->lvgl_begin();
//! Open s7xg chip power
@@ -200,6 +213,15 @@ void setup(void)
lv_label_set_text(label, "Begin S7xG");
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_t *label1 = lv_label_create(gContainer, NULL);
lv_label_set_text_fmt(label1, "SD Begin %s ", sdOnline ? "SUCCESS" : "FAILED");
lv_obj_align(label1, label, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
if (sdOnline) {
label = lv_label_create(gContainer, NULL);
lv_label_set_text_fmt(label, "SDCard:[%u] MB", cardSize);
lv_obj_align(label, label1, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
}
int len = 0;
int retry = 0;
do {

View File

@@ -1,5 +1,5 @@
// => Hardware select
// #define LILYGO_WATCH_2019_WITH_TOUCH // To use T-Watch2019 with touchscreen, please uncomment this line
#define LILYGO_WATCH_2019_WITH_TOUCH // To use T-Watch2019 with touchscreen, please uncomment this line
// #define LILYGO_WATCH_2019_NO_TOUCH // To use T-Watch2019 Not touchscreen , please uncomment this line
// #define LILYGO_WATCH_BLOCK // To use T-Watch Block , please uncomment this line

View File

@@ -15,6 +15,10 @@ Written by Lewis he //https://github.com/lewisxhe
#include <SPI.h>
#if defined(LILYGO_WATCH_HAS_S76_S78G)
#define LILYGO_WATCH_HAS_SDCARD
#endif
#ifdef LILYGO_WATCH_LVGL
#include <Ticker.h>
#endif
@@ -930,6 +934,8 @@ public:
}
#endif
#ifdef LILYGO_WATCH_HAS_SDCARD
SPIClass *sdhander = nullptr;