mirror of
https://github.com/esp8266/Arduino.git
synced 2025-08-07 00:04:36 +03:00
Migrate from astyle to clang-format (#8464)
This commit is contained in:
committed by
Max Prokhorov
parent
46190b61f1
commit
19b7a29720
@@ -9,7 +9,7 @@
|
||||
|
||||
#ifndef STASSID
|
||||
#define STASSID "your-ssid"
|
||||
#define STAPSK "your-password"
|
||||
#define STAPSK "your-password"
|
||||
#endif
|
||||
|
||||
const char *ssid = STASSID;
|
||||
@@ -19,7 +19,7 @@ long timezone = 2;
|
||||
byte daysavetime = 1;
|
||||
|
||||
|
||||
void listDir(const char * dirname) {
|
||||
void listDir(const char *dirname) {
|
||||
Serial.printf("Listing directory: %s\n", dirname);
|
||||
|
||||
Dir root = LittleFS.openDir(dirname);
|
||||
@@ -33,7 +33,7 @@ void listDir(const char * dirname) {
|
||||
time_t cr = file.getCreationTime();
|
||||
time_t lw = file.getLastWrite();
|
||||
file.close();
|
||||
struct tm * tmstruct = localtime(&cr);
|
||||
struct tm *tmstruct = localtime(&cr);
|
||||
Serial.printf(" CREATION: %d-%02d-%02d %02d:%02d:%02d\n", (tmstruct->tm_year) + 1900, (tmstruct->tm_mon) + 1, tmstruct->tm_mday, tmstruct->tm_hour, tmstruct->tm_min, tmstruct->tm_sec);
|
||||
tmstruct = localtime(&lw);
|
||||
Serial.printf(" LAST WRITE: %d-%02d-%02d %02d:%02d:%02d\n", (tmstruct->tm_year) + 1900, (tmstruct->tm_mon) + 1, tmstruct->tm_mday, tmstruct->tm_hour, tmstruct->tm_min, tmstruct->tm_sec);
|
||||
@@ -41,7 +41,7 @@ void listDir(const char * dirname) {
|
||||
}
|
||||
|
||||
|
||||
void readFile(const char * path) {
|
||||
void readFile(const char *path) {
|
||||
Serial.printf("Reading file: %s\n", path);
|
||||
|
||||
File file = LittleFS.open(path, "r");
|
||||
@@ -51,13 +51,11 @@ void readFile(const char * path) {
|
||||
}
|
||||
|
||||
Serial.print("Read from file: ");
|
||||
while (file.available()) {
|
||||
Serial.write(file.read());
|
||||
}
|
||||
while (file.available()) { Serial.write(file.read()); }
|
||||
file.close();
|
||||
}
|
||||
|
||||
void writeFile(const char * path, const char * message) {
|
||||
void writeFile(const char *path, const char *message) {
|
||||
Serial.printf("Writing file: %s\n", path);
|
||||
|
||||
File file = LittleFS.open(path, "w");
|
||||
@@ -70,11 +68,11 @@ void writeFile(const char * path, const char * message) {
|
||||
} else {
|
||||
Serial.println("Write failed");
|
||||
}
|
||||
delay(2000); // Make sure the CREATE and LASTWRITE times are different
|
||||
delay(2000); // Make sure the CREATE and LASTWRITE times are different
|
||||
file.close();
|
||||
}
|
||||
|
||||
void appendFile(const char * path, const char * message) {
|
||||
void appendFile(const char *path, const char *message) {
|
||||
Serial.printf("Appending to file: %s\n", path);
|
||||
|
||||
File file = LittleFS.open(path, "a");
|
||||
@@ -90,7 +88,7 @@ void appendFile(const char * path, const char * message) {
|
||||
file.close();
|
||||
}
|
||||
|
||||
void renameFile(const char * path1, const char * path2) {
|
||||
void renameFile(const char *path1, const char *path2) {
|
||||
Serial.printf("Renaming file %s to %s\n", path1, path2);
|
||||
if (LittleFS.rename(path1, path2)) {
|
||||
Serial.println("File renamed");
|
||||
@@ -99,7 +97,7 @@ void renameFile(const char * path1, const char * path2) {
|
||||
}
|
||||
}
|
||||
|
||||
void deleteFile(const char * path) {
|
||||
void deleteFile(const char *path) {
|
||||
Serial.printf("Deleting file: %s\n", path);
|
||||
if (LittleFS.remove(path)) {
|
||||
Serial.println("File deleted");
|
||||
@@ -127,7 +125,7 @@ void setup() {
|
||||
Serial.println(WiFi.localIP());
|
||||
Serial.println("Contacting Time Server");
|
||||
configTime(3600 * timezone, daysavetime * 3600, "time.nist.gov", "0.pool.ntp.org", "1.pool.ntp.org");
|
||||
struct tm tmstruct ;
|
||||
struct tm tmstruct;
|
||||
delay(2000);
|
||||
tmstruct.tm_year = 0;
|
||||
getLocalTime(&tmstruct, 5000);
|
||||
@@ -158,9 +156,6 @@ void setup() {
|
||||
}
|
||||
readFile("/hello.txt");
|
||||
listDir("/");
|
||||
|
||||
|
||||
}
|
||||
|
||||
void loop() { }
|
||||
|
||||
void loop() {}
|
||||
|
@@ -44,9 +44,7 @@ void DoTest(FS *fs) {
|
||||
}
|
||||
|
||||
uint8_t data[256];
|
||||
for (int i = 0; i < 256; i++) {
|
||||
data[i] = (uint8_t) i;
|
||||
}
|
||||
for (int i = 0; i < 256; i++) { data[i] = (uint8_t)i; }
|
||||
|
||||
Serial.printf("Creating %dKB file, may take a while...\n", TESTSIZEKB);
|
||||
unsigned long start = millis();
|
||||
@@ -56,9 +54,7 @@ void DoTest(FS *fs) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < TESTSIZEKB; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
f.write(data, 256);
|
||||
}
|
||||
for (int j = 0; j < 4; j++) { f.write(data, 256); }
|
||||
}
|
||||
f.close();
|
||||
unsigned long stop = millis();
|
||||
@@ -72,9 +68,7 @@ void DoTest(FS *fs) {
|
||||
start = millis();
|
||||
f = fs->open("/testwrite.bin", "r");
|
||||
for (int i = 0; i < TESTSIZEKB; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
f.read(data, 256);
|
||||
}
|
||||
for (int j = 0; j < 4; j++) { f.read(data, 256); }
|
||||
}
|
||||
f.close();
|
||||
stop = millis();
|
||||
@@ -85,9 +79,7 @@ void DoTest(FS *fs) {
|
||||
f = fs->open("/testwrite.bin", "r");
|
||||
f.read();
|
||||
for (int i = 0; i < TESTSIZEKB; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
f.read(data + 1, 256);
|
||||
}
|
||||
for (int j = 0; j < 4; j++) { f.read(data + 1, 256); }
|
||||
}
|
||||
f.close();
|
||||
stop = millis();
|
||||
@@ -115,9 +107,7 @@ void DoTest(FS *fs) {
|
||||
Serial.printf("Writing 64K file in 1-byte chunks\n");
|
||||
start = millis();
|
||||
f = fs->open("/test1b.bin", "w");
|
||||
for (int i = 0; i < 65536; i++) {
|
||||
f.write((uint8_t*)&i, 1);
|
||||
}
|
||||
for (int i = 0; i < 65536; i++) { f.write((uint8_t *)&i, 1); }
|
||||
f.close();
|
||||
stop = millis();
|
||||
Serial.printf("==> Time to write 64KB in 1b chunks = %lu milliseconds = %s\n", stop - start, rate(start, stop, 65536));
|
||||
@@ -127,7 +117,7 @@ void DoTest(FS *fs) {
|
||||
f = fs->open("/test1b.bin", "r");
|
||||
for (int i = 0; i < 65536; i++) {
|
||||
char c;
|
||||
f.read((uint8_t*)&c, 1);
|
||||
f.read((uint8_t *)&c, 1);
|
||||
}
|
||||
f.close();
|
||||
stop = millis();
|
||||
|
Reference in New Issue
Block a user