@@ -0,0 +1,75 @@ | |||
0xEA, 0x0C, 0xD2, 0x04, 0xE1, 0x9D, 0xC4, 0x18, 0xF6, 0xC1, | |||
0x40, 0xA7, 0x08, 0x35, 0x3D, 0x67, 0x1A, 0xB5, 0x23, 0x81, | |||
0x4C, 0x96, 0x42, 0xFD, 0x43, 0xDA, 0x99, 0x71, 0x68, 0xF1, | |||
0xEA, 0x1E, 0xB9, 0xE4, 0xD0, 0xBB, 0x05, 0xAC, 0xF7, 0x5E, | |||
0x38, 0x0B, 0x31, 0x66, 0x0D, 0x8A, 0x1B, 0x6F, 0x29, 0x2B, | |||
0xEC, 0x8C, 0xED, 0xAD, 0x03, 0xE2, 0x44, 0xBA, 0xB3, 0xA1, | |||
0xB8, 0x85, 0xFC, 0xF6, 0xFB, 0xD1, 0x12, 0x63, 0x7E, 0x86, | |||
0x5A, 0x22, 0x6F, 0xEF, 0x55, 0xD4, 0x27, 0x3F, 0xCC, 0xE9, | |||
0x9A, 0x60, 0xC5, 0xD0, 0xF8, 0x29, 0x0B, 0x06, 0x2C, 0x9B, | |||
0xDC, 0x95, 0xDD, 0xA6, 0x22, 0x65, 0x3F, 0xCC, 0x7E, 0x6C, | |||
0xD3, 0x77, 0x26, 0x23, 0x9C, 0x5C, 0xD3, 0x8E, 0xB2, 0xBD, | |||
0xD1, 0xC8, 0xEA, 0xC1, 0x87, 0x2A, 0x67, 0x5B, 0xA4, 0x66, | |||
0x32, 0x60, 0x79, 0x6D, 0xE4, 0xCC, 0x6B, 0x4D, 0xA4, 0x26, | |||
0x7E, 0x06, 0x12, 0x6E, 0x3B, 0xB5, 0x55, 0x05, 0x42, 0x37, | |||
0x75, 0x2C, 0x89, 0xB7, 0x94, 0xA7, 0x28, 0x97, 0x4A, 0x2E, | |||
0x0B, 0x90, 0xFD, 0x66, 0xE8, 0xD4, 0x7C, 0xC6, 0x09, 0xFA, | |||
0x1D, 0xED, 0x54, 0x43, 0x27, 0x65, 0x49, 0xF5, 0x17, 0x03, | |||
0x1F, 0x4E, 0x6F, 0x06, 0xA7, 0x67, 0x90, 0x9D, 0xC5, 0xFA, | |||
0x61, 0xF4, 0x3C, 0x8B, 0x27, 0xB6, 0xDF, 0x92, 0x4E, 0x15, | |||
0xB2, 0xDF, 0xAE, 0xA6, 0xF3, 0x01, 0xB1, 0x56, 0x32, 0x99, | |||
0xB0, 0xEA, 0x35, 0x0B, 0xA6, 0x89, 0x62, 0x05, 0xA4, 0xC0, | |||
0x23, 0x0C, 0x5B, 0x43, 0x66, 0xB3, 0x03, 0x61, 0x9A, 0x2F, | |||
0x98, 0x02, 0x84, 0x3B, 0x0A, 0xBB, 0xFB, 0x03, 0x0E, 0x45, | |||
0x4D, 0x1C, 0xB7, 0xAF, 0x23, 0xE0, 0x15, 0xEA, 0xE5, 0xC1, | |||
0x92, 0x2D, 0x0E, 0x19, 0x7C, 0xFA, 0xFA, 0x5E, 0xA7, 0xBB, | |||
0xD8, 0x8F, 0x87, 0x4E, 0x8A, 0x99, 0x1C, 0x6A, 0x5D, 0x49, | |||
0xA8, 0xFE, 0x38, 0x84, 0x85, 0x44, 0x01, 0xCB, 0x78, 0xF9, | |||
0x6D, 0xA3, 0xD2, 0x95, 0x4A, 0xB5, 0xF7, 0xF0, 0xF9, 0x10, | |||
0xA6, 0x4B, 0xCF, 0xBE, 0x4A, 0x46, 0x21, 0x57, 0x40, 0xCB, | |||
0x91, 0xDD, 0x7A, 0xA3, 0xA9, 0x48, 0x40, 0x27, 0x98, 0x65, | |||
0xFE, 0xDC, 0x8A, 0x6B, 0xF3, 0xBB, 0x04, 0x37, 0x65, 0x09, | |||
0xFB, 0x09, 0x95, 0x62, 0xE6, 0x5B, 0x53, 0x82, 0x82, 0x70, | |||
0x3D, 0x23, 0x6C, 0xAD, 0x23, 0x84, 0xE8, 0x9F, 0xF2, 0x00, | |||
0xE0, 0x68, 0x34, 0xA8, 0xC5, 0x0C, 0xC0, 0x4A, 0xB6, 0x4A, | |||
0xD8, 0xA6, 0xB6, 0x4A, 0xF8, 0xF8, 0x75, 0x60, 0xD2, 0xE4, | |||
0x0B, 0xF9, 0x0C, 0xA6, 0xA1, 0x9C, 0xF5, 0x2E, 0x17, 0x2C, | |||
0x29, 0x8A, 0x21, 0x24, 0xEA, 0xDB, 0x95, 0xE7, 0x75, 0x25, | |||
0xAF, 0x3B, 0xC2, 0x16, 0x0E, 0x69, 0x36, 0x8F, 0x80, 0xB4, | |||
0x1A, 0x01, 0xEF, 0x0B, 0x1B, 0x09, 0x74, 0x86, 0x3C, 0xFB, | |||
0x0D, 0xF5, 0x1A, 0x01, 0x56, 0xE4, 0xA0, 0x32, 0xB0, 0x40, | |||
0x36, 0xAB, 0x40, 0x80, 0x4C, 0x39, 0x05, 0x1D, 0x43, 0xC7, | |||
0x76, 0x82, 0x51, 0x80, 0x1E, 0x13, 0xF9, 0x76, 0x44, 0xD9, | |||
0xEA, 0xB9, 0x14, 0x98, 0x72, 0x2E, 0x46, 0xC6, 0x63, 0x1D, | |||
0xB9, 0xF6, 0xD5, 0xA6, 0x75, 0xBB, 0xB2, 0x0B, 0x34, 0xA8, | |||
0x8D, 0x6E, 0x1F, 0xFF, 0xCE, 0xDA, 0x20, 0xD6, 0xEE, 0xB8, | |||
0x7B, 0xBB, 0x35, 0x35, 0xFA, 0x65, 0xBA, 0xE3, 0x62, 0xAB, | |||
0xC2, 0x64, 0x77, 0x10, 0x9D, 0xC0, 0x4F, 0xCD, 0xCF, 0xFB, | |||
0x97, 0xF4, 0x23, 0x47, 0xD7, 0x2E, 0xC9, 0xF9, 0x5E, 0x3C, | |||
0x68, 0x4E, 0x92, 0x5F, 0x06, 0x40, 0x95, 0xA1, 0x30, 0xFA, | |||
0xF1, 0xFC, 0xDC, 0xFB, 0x45, 0xF7, 0x24, 0x8D, 0xEF, 0x4D, | |||
0x49, 0xD0, 0xFE, 0x77, 0x34, 0x6D, 0x8D, 0xDB, 0x59, 0x11, | |||
0x86, 0xE2, 0x37, 0xD3, 0x2F, 0xD0, 0xB7, 0x08, 0x1E, 0x95, | |||
0xCB, 0x51, 0xD5, 0x02, 0x4C, 0x28, 0xF8, 0xAA, 0x7B, 0x7D, | |||
0x61, 0xFA, 0xCA, 0xE3, 0x66, 0x04, 0x9D, 0x95, 0x78, 0x7B, | |||
0x33, 0xD2, 0xEF, 0x77, 0xDB, 0xB3, 0xD7, 0xE5, 0x48, 0xDF, | |||
0x9A, 0x6E, 0x99, 0x21, 0x59, 0xFE, 0x99, 0xFC, 0x12, 0x8F, | |||
0x44, 0xC2, 0xB7, 0xA6, 0x46, 0xE3, 0x8A, 0x6B, 0x84, 0x23, | |||
0x08, 0x6C, 0x2F, 0xAB, 0x77, 0x78, 0x4D, 0x02, 0x6B, 0xCD, | |||
0x06, 0xDD, 0x24, 0xC1, 0x24, 0xDB, 0x36, 0xF3, 0x48, 0x5D, | |||
0xF4, 0x57, 0x73, 0xDD, 0x7F, 0xAA, 0xA2, 0x66, 0xE5, 0x37, | |||
0xEB, 0xFD, 0x1C, 0x7C, 0x40, 0x89, 0x03, 0x19, 0xDC, 0x61, | |||
0x9C, 0xC2, 0xD7, 0xB5, 0x83, 0xFA, 0x3A, 0x64, 0x23, 0xDE, 0xB2, 0x6A, | |||
0x90, 0xDF, 0x43, 0x60, 0xAC, 0x88, 0x3D, 0xBA, 0x35, 0x1D, | |||
0x34, 0x66, 0x38, 0x97, 0x01, 0xB9, 0x83, 0x9F, 0x3D, 0x74, | |||
0x12, 0x8C, 0x61, 0x2B, 0x91, 0x4A, 0x9B, 0x4B, 0x95, 0x40, | |||
0xC7, 0x11, 0x4F, 0x59, 0xF3, 0xCE, 0x56, 0x3B, 0x96, 0x42, | |||
0xC9, 0x4E, 0xE1, 0x77, 0xB0, 0x81, 0xB3, 0x2C, 0x3C, 0xB2, | |||
0x05, 0x1C, 0x3A, 0x66, 0xF5, 0xE0, 0x4F, 0xEE, 0x5B, 0xC8, | |||
0xD6, 0x52, 0x97, 0x9F, 0x1B, 0x80, 0x44, 0x53, 0xD7, 0x5D, | |||
0x8A, 0xB9, 0xA2, 0xDD, 0x99, 0xB4, 0xFA, 0xFB, 0xB9, 0xAA, | |||
0xA0, 0xA8, 0x11, 0xFA, 0xCF, 0xF5, 0xB6, 0xDF, 0xB4, 0xD7, | |||
0x56, 0x11, 0xD1, 0xE1, 0xF0, 0x45, 0xA0, 0x6C, 0xA1, 0xAE, | |||
0x92, 0xD7, 0x6F, 0xD0, 0x18, 0xF7, 0x73, 0x07, 0x15, 0xDC, | |||
0xEE, 0x37, 0xD8, 0xB1, 0x72, 0x2C, 0xAC, 0x57, 0x99, 0x57, | |||
0xD5, 0x59, 0xC7, 0xE8, 0x |
@@ -0,0 +1,15 @@ | |||
#ifndef __FILESYS_H | |||
#define __FILESYS_H | |||
#include <LittleFS.h> | |||
bool mount_fs(); | |||
bool format_fs(); | |||
void listDir(const char * dirname); | |||
void readFile(const char * path); | |||
void writeFile(const char * path, const char * message); | |||
void appendFile(const char * path, const char * message); | |||
void renameFile(const char * path1, const char * path2); | |||
void deleteFile(const char * path); | |||
#endif // __FILESYS_H |
@@ -0,0 +1,132 @@ | |||
#include "filesys.h" | |||
// listDir("/"); | |||
// deleteFile("/hello.txt"); | |||
// writeFile("/hello.txt", "Hello "); | |||
// appendFile("/hello.txt", "World!\n"); | |||
// readFile("/hello.txt"); | |||
// listDir("/"); | |||
FSInfo fsinfo; | |||
void listDir(const char * dirname) { | |||
Serial.printf("Listing directory: %s\n", dirname); | |||
Dir root = LittleFS.openDir(dirname); | |||
while (root.next()) { | |||
File file = root.openFile("r"); | |||
Serial.print(" FILE: "); | |||
Serial.print(root.fileName()); | |||
Serial.print(" SIZE: "); | |||
Serial.print(file.size()); | |||
time_t cr = file.getCreationTime(); | |||
time_t lw = file.getLastWrite(); | |||
file.close(); | |||
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); | |||
} | |||
} | |||
void readFile(const char * path) { | |||
Serial.printf("Reading file: %s\n", path); | |||
File file = LittleFS.open(path, "r"); | |||
if (!file) { | |||
Serial.println("Failed to open file for reading"); | |||
return; | |||
} | |||
Serial.print("Read from file: "); | |||
while (file.available()) { | |||
Serial.write(file.read()); | |||
} | |||
file.close(); | |||
} | |||
void writeFile(const char * path, const char * message) { | |||
Serial.printf("Writing file: %s\n", path); | |||
File file = LittleFS.open(path, "w"); | |||
if (!file) { | |||
Serial.println("Failed to open file for writing"); | |||
return; | |||
} | |||
if (file.print(message)) { | |||
Serial.println("File written"); | |||
} else { | |||
Serial.println("Write failed"); | |||
} | |||
delay(2000); // Make sure the CREATE and LASTWRITE times are different | |||
file.close(); | |||
} | |||
void appendFile(const char * path, const char * message) { | |||
Serial.printf("Appending to file: %s\n", path); | |||
File file = LittleFS.open(path, "a"); | |||
if (!file) { | |||
Serial.println("Failed to open file for appending"); | |||
return; | |||
} | |||
if(file.print(message)) { | |||
Serial.println("Message appended"); | |||
} else { | |||
Serial.println("Append failed"); | |||
} | |||
file.close(); | |||
} | |||
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"); | |||
} else { | |||
Serial.println("Rename failed"); | |||
} | |||
} | |||
void deleteFile(const char * path) { | |||
Serial.printf("Deleting file: %s\n", path); | |||
if (LittleFS.remove(path)) { | |||
Serial.println("File deleted"); | |||
} else { | |||
Serial.println("Delete failed"); | |||
} | |||
} | |||
bool mount_fs() { | |||
if(!LittleFS.begin()) { | |||
Serial.println("[ERROR] LittleFS.info(), reset ..."); | |||
return false; | |||
} | |||
if(!LittleFS.info(fsinfo)) { | |||
Serial.println("[ERROR] LittleFS.info(), reset ..."); | |||
return false; | |||
} | |||
printf("Filesystem opened: \n"); | |||
printf("\ttotalBytes:\t%d\n", fsinfo.totalBytes); | |||
printf("\tusedBytes:\t%d\n", fsinfo.usedBytes); | |||
printf("\tblockSize:\t%d\n", fsinfo.blockSize); | |||
printf("\tpageSize:\t%d\n", fsinfo.pageSize); | |||
printf("\tmaxOpenFiles:\t%d\n", fsinfo.maxOpenFiles); | |||
printf("\tmaxPathLength:\t%d\n", fsinfo.maxPathLength); | |||
printf("\n"); | |||
return true; | |||
} | |||
bool format_fs() { | |||
printf("Formatting FS ! \n"); | |||
return LittleFS.format(); | |||
} | |||
@@ -19,6 +19,7 @@ extern "C" { | |||
#include <WiFiUdp.h> | |||
#include <ArduinoOTA.h> | |||
#include "filesys.h" | |||
#include <ESP8266WebServer.h> | |||
#include <WiFiClient.h> | |||
@@ -83,7 +84,6 @@ void handleNotFound() { | |||
void setup_webserver() { | |||
server.on("/", handleRootGz); | |||
server.on("/style.css", handleCssGz); | |||
server.on("/favicon.png", handleFaviconGz); | |||
@@ -171,6 +171,11 @@ void setup() { | |||
Serial.println(F("Booting ....")); | |||
mount_fs(); | |||
//format_fs(); | |||
listDir(""); | |||
readFile("/test.txt"); | |||
pinMode(NODEMCU_LED, OUTPUT); | |||
pinMode(ESP12_LED, OUTPUT); | |||
@@ -214,10 +219,6 @@ void setup() { | |||
setup_pwm_pca9685(); | |||
} | |||
uint32_t t; | |||
#define SP_US(_str,_a) Serial.print(_str); Serial.print(" took: "); Serial.print(_a); Serial.println("µs") | |||
#define TIMEIF_US(_str,_f, _l) t=micros(); _f; t=micros()-t; if(t > _l) { SP_US(_str, t); } | |||
uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval, uint8_t factor){ | |||
static uint8_t lastled = 255; | |||
static uint8_t current_pwm = 0; | |||
@@ -300,11 +301,11 @@ void ledsequence(uint8_t direction, uint8_t onoff, uint8_t factor){ | |||
} | |||
} | |||
uint32_t t; | |||
#define SP_US(_str,_a) Serial.print(_str); Serial.print(" took: "); Serial.print(_a); Serial.println("us") | |||
#define TIMEIF_US(_str,_f, _l) t=micros(); _f; t=micros()-t; if(t > _l) { SP_US(_str, t); } | |||
void loop() { | |||
if(millis() - dimmtimer > 2){ | |||
//ledsequence(direction, onoff, 4); | |||
dimmtimer = millis(); | |||
@@ -316,4 +317,5 @@ void loop() { | |||
} | |||
TIMEIF_US("OTA", ArduinoOTA.handle(), 1000); | |||
TIMEIF_US("HTTP", server.handleClient(), 1000); | |||
} |