mirror of
https://github.com/luc-github/ESP3D.git
synced 2026-03-22 23:56:51 +01:00
### Maintenance page
* Add add tab color for mobile view
* Add spellcheck off / autocorect off in input
* Add disconnect button when authenticate enabled
* Add Invalid user or password message when authentication failed
### Board support
* Add ESP32 S2 support
* Add ESP32 S3 support
* Add ESP32 C3 support
### ESP commands
* Add command 701 to control GCODE streaming
* Remove command 901 as duplicate
* Update command 420 to add more details
* Use text as default output
* All json on all commands for formated output
### Core
* Add benchmak function to check transfer speed (for test only-not production)
* Merge code for ESP3DLib support
* Add better printer display support (M117 / Serial TFT)
* Use ESP32 analogWrite instead of emulated one
### Modules
* Display
* Refactor code
* Remove SPI ILI 9341 / 9488 support as not suitable
* Add ST7789 support (135x240 / 240x240)
* Filesystem
* Bug fixes due to esp core updates
* Better SD sharing mecanism
* Better global FS management
* FTP
* Add SD sharing support
* Better global FS management
* GCODE Host
* Add basic support for macro files
* Add ESP command support
* Use not blocking method to stream commands / handle response
* Notifications
* Add IFTTT notification service
* Add WebUI notification
* Add ESP3D display notification
* WebDav
* Add SD sharing support
* Add bug fix from https://github.com/d-a-v/ESPWebDAV
* Better global FS management
* Websocket
* Add function to handle zombies connections
* WiFi
* Fix connection to AP sometime fail
* Fix low signal not diplayed in ESP420 even connected
* Add AP Setup mode
### Libraries
* Update SDFat-2.0.6 to 2.1.2
* Update ESP32SSDP 1.1.1 to 1.2.0
* Update TFT_eSPI-1.4.11 to 2.4.61
* Update arduinoWebSockets-2.3.5 to 2.3.6
* Update esp8266-oled-ssd1306-4.0.0 to 4.3.0
* Remove lvgl support
### Tools
* Add I2C scanner script
* Add python script to simulate/stress printer serial communication
### PlatformIO
* Use latest 4.4.0 Espressif32 release (ESP32-arduino core 2.0.3)
* Add fix for Flash more than 4MB
* Add Esp32 S2/S3/C3 env
* Add ESP32-ST7789 / esp32-TTGO_T_Display env
150 lines
4.0 KiB
C++
150 lines
4.0 KiB
C++
/*
|
|
* Simple data logger.
|
|
*/
|
|
#include <SPI.h>
|
|
#include "SdFat.h"
|
|
|
|
// SD chip select pin. Be sure to disable any other SPI devices such as Enet.
|
|
const uint8_t chipSelect = SS;
|
|
|
|
// Interval between data records in milliseconds.
|
|
// The interval must be greater than the maximum SD write latency plus the
|
|
// time to acquire and write data to the SD to avoid overrun errors.
|
|
// Run the bench example to check the quality of your SD card.
|
|
const uint32_t SAMPLE_INTERVAL_MS = 1000;
|
|
|
|
// Log file base name. Must be six characters or less.
|
|
#define FILE_BASE_NAME "Data"
|
|
//------------------------------------------------------------------------------
|
|
// File system object.
|
|
SdFat sd;
|
|
|
|
// Log file.
|
|
SdFile file;
|
|
|
|
// Time in micros for next data record.
|
|
uint32_t logTime;
|
|
|
|
//==============================================================================
|
|
// User functions. Edit writeHeader() and logData() for your requirements.
|
|
|
|
const uint8_t ANALOG_COUNT = 4;
|
|
//------------------------------------------------------------------------------
|
|
// Write data header.
|
|
void writeHeader() {
|
|
file.print(F("micros"));
|
|
for (uint8_t i = 0; i < ANALOG_COUNT; i++) {
|
|
file.print(F(",adc"));
|
|
file.print(i, DEC);
|
|
}
|
|
file.println();
|
|
}
|
|
//------------------------------------------------------------------------------
|
|
// Log a data record.
|
|
void logData() {
|
|
uint16_t data[ANALOG_COUNT];
|
|
|
|
// Read all channels to avoid SD write latency between readings.
|
|
for (uint8_t i = 0; i < ANALOG_COUNT; i++) {
|
|
data[i] = analogRead(i);
|
|
}
|
|
// Write data to file. Start with log time in micros.
|
|
file.print(logTime);
|
|
|
|
// Write ADC data to CSV record.
|
|
for (uint8_t i = 0; i < ANALOG_COUNT; i++) {
|
|
file.write(',');
|
|
file.print(data[i]);
|
|
}
|
|
file.println();
|
|
}
|
|
//==============================================================================
|
|
// Error messages stored in flash.
|
|
#define error(msg) sd.errorHalt(F(msg))
|
|
//------------------------------------------------------------------------------
|
|
void setup() {
|
|
const uint8_t BASE_NAME_SIZE = sizeof(FILE_BASE_NAME) - 1;
|
|
char fileName[13] = FILE_BASE_NAME "00.csv";
|
|
|
|
Serial.begin(9600);
|
|
|
|
// Wait for USB Serial
|
|
while (!Serial) {
|
|
yield();
|
|
}
|
|
delay(1000);
|
|
|
|
Serial.println(F("Type any character to start"));
|
|
while (!Serial.available()) {
|
|
yield();
|
|
}
|
|
|
|
// Initialize at the highest speed supported by the board that is
|
|
// not over 50 MHz. Try a lower speed if SPI errors occur.
|
|
if (!sd.begin(chipSelect, SD_SCK_MHZ(50))) {
|
|
sd.initErrorHalt();
|
|
}
|
|
|
|
// Find an unused file name.
|
|
if (BASE_NAME_SIZE > 6) {
|
|
error("FILE_BASE_NAME too long");
|
|
}
|
|
while (sd.exists(fileName)) {
|
|
if (fileName[BASE_NAME_SIZE + 1] != '9') {
|
|
fileName[BASE_NAME_SIZE + 1]++;
|
|
} else if (fileName[BASE_NAME_SIZE] != '9') {
|
|
fileName[BASE_NAME_SIZE + 1] = '0';
|
|
fileName[BASE_NAME_SIZE]++;
|
|
} else {
|
|
error("Can't create file name");
|
|
}
|
|
}
|
|
if (!file.open(fileName, O_WRONLY | O_CREAT | O_EXCL)) {
|
|
error("file.open");
|
|
}
|
|
// Read any Serial data.
|
|
do {
|
|
delay(10);
|
|
} while (Serial.available() && Serial.read() >= 0);
|
|
|
|
Serial.print(F("Logging to: "));
|
|
Serial.println(fileName);
|
|
Serial.println(F("Type any character to stop"));
|
|
|
|
// Write data header.
|
|
writeHeader();
|
|
|
|
// Start on a multiple of the sample interval.
|
|
logTime = micros()/(1000UL*SAMPLE_INTERVAL_MS) + 1;
|
|
logTime *= 1000UL*SAMPLE_INTERVAL_MS;
|
|
}
|
|
//------------------------------------------------------------------------------
|
|
void loop() {
|
|
// Time for next record.
|
|
logTime += 1000UL*SAMPLE_INTERVAL_MS;
|
|
|
|
// Wait for log time.
|
|
int32_t diff;
|
|
do {
|
|
diff = micros() - logTime;
|
|
} while (diff < 0);
|
|
|
|
// Check for data rate too high.
|
|
if (diff > 10) {
|
|
error("Missed data record");
|
|
}
|
|
|
|
logData();
|
|
|
|
// Force data to SD and update the directory entry to avoid data loss.
|
|
if (!file.sync() || file.getWriteError()) {
|
|
error("write error");
|
|
}
|
|
|
|
if (Serial.available()) {
|
|
// Close file and stop.
|
|
file.close();
|
|
Serial.println(F("Done"));
|
|
while (true) {}
|
|
}
|
|
} |