I like it!π
Best posts made by Stoni99
Latest posts made by Stoni99
-
RE: Problems writing to SD Card
A third, newly ordered sd card works now. πIt is a Verbatin 16Gb Premium microSDHC. The m5stack seems to be pretty picky?!
-
RE: Problems writing to SD Card
I tried it on my M5Stack Core with a SanDisk 32GB Fat32 and a Noname 4GB Fat32. Even repeated formatting did not lead to success. Do you have another tip for me?
-
RE: Problems writing to SD Card
@jj said in Problems writing to SD Card:
@vsthose Hi Vsthose,
The following code should work provided you use a Micro SD / TF card that only has a few files on it.... too many and the display will run off the screen and you won't see the write to card and read back.
#include <M5Stack.h> //Micro SD / TF Card Test void listDir(fs::FS &fs, const char * dirname, uint8_t levels){ // Print blank line on screen M5.Lcd.printf(" \n "); M5.Lcd.printf(" \n "); Serial.printf("Listing directory: %s\n", dirname); M5.Lcd.printf("Listing directory: %s\n", dirname); File root = fs.open(dirname); if(!root){ Serial.println("Failed to open directory"); M5.Lcd.println("Failed to open directory"); return; } if(!root.isDirectory()){ Serial.println("Not a directory"); M5.Lcd.println("Not a directory"); return; } File file = root.openNextFile(); while(file){ if(file.isDirectory()){ Serial.print(" DIR : "); M5.Lcd.print(" DIR : "); Serial.println(file.name()); M5.Lcd.println(file.name()); if(levels){ listDir(fs, file.name(), levels -1); } } else { Serial.print(" FILE: "); M5.Lcd.print(" FILE: "); Serial.print(file.name()); M5.Lcd.print(file.name()); Serial.print(" SIZE: "); M5.Lcd.print(" SIZE: "); Serial.println(file.size()); M5.Lcd.println(file.size()); } file = root.openNextFile(); } } void readFile(fs::FS &fs, const char * path) { Serial.printf("Reading file: %s\n", path); M5.Lcd.printf("Reading file: %s\n", path); File file = fs.open(path); if(!file){ Serial.println("Failed to open file for reading"); M5.Lcd.println("Failed to open file for reading"); return; } Serial.print("Read from file: "); M5.Lcd.print("Read from file: "); while(file.available()){ int ch = file.read(); Serial.write(ch); M5.Lcd.write(ch); } } void writeFile(fs::FS &fs, const char * path, const char * message){ Serial.printf("Writing file: %s\n", path); M5.Lcd.printf("Writing file: %s\n", path); File file = fs.open(path, FILE_WRITE); if(!file){ Serial.println("Failed to open file for writing"); M5.Lcd.println("Failed to open file for writing"); return; } if(file.print(message)){ Serial.println("File written"); M5.Lcd.println("File written"); } else { Serial.println("Write failed"); M5.Lcd.println("Write failed"); } } // the setup routine runs once when M5Stack starts up void setup() { // initialize the M5Stack object M5.begin(); M5.startupLogo(); Wire.begin(); // Lcd display M5.Lcd.setBrightness(100); M5.Lcd.fillScreen(BLACK); M5.Lcd.setCursor(0, 10); M5.Lcd.setTextColor(WHITE); M5.Lcd.setTextSize(1); // Page Header M5.Lcd.fillScreen(BLACK); M5.Lcd.setCursor(0, 05); M5.Lcd.printf(" Testing Micro SD Card Functions:\r\n"); // digitalWrite(TFT_CS, 1); // Print blank line on screen M5.Lcd.printf(" \n "); M5.Lcd.printf(" \n "); listDir(SD, "/", 0); M5.Lcd.printf(""); M5.Lcd.printf(""); // Print blank line on screen M5.Lcd.printf(" \n "); M5.Lcd.printf(" \n "); writeFile(SD, "/hello.txt", "Hello world from M5Stack !!"); M5.Lcd.printf(""); M5.Lcd.printf(""); // Print blank line on screen M5.Lcd.printf(" \n "); M5.Lcd.printf(" \n "); // Print blank line on screen M5.Lcd.printf(" \n "); M5.Lcd.printf(" \n "); readFile(SD, "/hello.txt"); } void loop() { // put your main code here, to run repeatedly: M5.update(); }
I tested the example. unfortunately it doesn't work for me. there are no folders or many other files on the card. what am I doing wrong?
rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13516
load:0x40080400,len:3604
entry 0x400805f0
M5Stack initializing...OK
Listing directory: /
Failed to open directory
Writing file: /hello.txt
Failed to open file for writing
Reading file: /hello.txt
Failed to open file for reading -
update a single value without first deleting the entire display
I just want to update a single value in the display. Is this possible without first deleting the entire display?
-
RE: WiFi.setHostname("Name"); not working (Core Basic)
Unfortunately, a restart doesn't help either. maybe it's because of my older router.
-
RE: WiFi.setHostname("Name"); not working (Core Basic)
Unfortunately this doesn't work for me. I am doing something wrong?
......
String hostname = "newName";
......void initWiFi() {
WiFi.mode(WIFI_STA);
//WiFi.disconnect(); //Turn off all wifi connections.
//delay(100);
WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
WiFi.setHostname(hostname.c_str()); //define hostname (wifi.config muss davor stehen
WiFi.begin(ssid, password);
M5.Lcd.print("Call to " + String(ssid));
while (WiFi.status() != WL_CONNECTED) {
M5.Lcd.print('.');
delay(1000);
}
M5.Lcd.println(" ");
M5.Lcd.println(WiFi.localIP());
M5.Lcd.print("Signalstearke: ");
M5.Lcd.println(WiFi.RSSI());
server.begin();
delay(4000);
M5.Lcd.clear();
} -
WiFi.setHostname("Name"); not working (Core Basic)
I don't get an error message from the compiler, but the new name doesn't appear in the router
WiFi.mode(WIFI_STA);
WiFi.disconnect(); //Turn off all wifi connections.
delay(100);
WiFi.setHostname("M5StackCoreZaehler");
WiFi.begin(ssid, password);
M5.Lcd.print("Call to " + String(ssid));
while (WiFi.status() != WL_CONNECTED) {
M5.Lcd.print('.');
delay(1000);
}
M5.Lcd.println(" ");
M5.Lcd.println(WiFi.localIP());
M5.Lcd.print("Signalstearke: ");
M5.Lcd.println(WiFi.RSSI());
server.begin();
delay(4000);
M5.Lcd.clear(); -
back to the small standard font?
The standard font is very small. If i use "M5.Lcd.setFreeFont(FSS9)" within the code, how do I get back to the small standard font? I need smaller then 9pt.