Skip to content

Update esp8266 framework to most recent version (2.5.3, core 2.7.1) #158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions ESP8266WirelessPrintAsync/ESP8266WirelessPrintAsync.ino
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ inline String getUploadedFilename() {
}

void handlePrint() {
static FileWrapper gcodeFile;
static File gcodeFile;
static float prevM73Completion, prevM532Completion;

if (isPrinting) {
Expand Down Expand Up @@ -293,7 +293,7 @@ void handlePrint() {
}

void handleUpload(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) {
static FileWrapper file;
static File file;

if (!index) {
lcd("Receiving...");
Expand Down Expand Up @@ -487,15 +487,15 @@ bool detectPrinter() {
}

void initUploadedFilename() {
FileWrapper dir = storageFS.open("/");
File dir = storageFS.open("/");
if (dir) {
FileWrapper file = dir.openNextFile();
File file = dir.openNextFile();
while (file && file.isDirectory()) {
file.close();
file = dir.openNextFile();
}
if (file) {
uploadedFullname = "/" + file.name();
uploadedFullname = "/" + String(file.name()) ;
uploadedFileSize = file.size();
file.close();
}
Expand Down Expand Up @@ -624,7 +624,7 @@ void setup() {
server.on("/download", HTTP_GET, [](AsyncWebServerRequest * request) {
AsyncWebServerResponse *response = request->beginResponse("application/x-gcode", uploadedFileSize, [](uint8_t *buffer, size_t maxLen, size_t index) -> size_t {
static size_t downloadBytesLeft;
static FileWrapper downloadFile;
static File downloadFile;

if (!index) {
downloadFile = storageFS.open(uploadedFullname);
Expand Down
148 changes: 0 additions & 148 deletions ESP8266WirelessPrintAsync/FileWrapper.cpp

This file was deleted.

63 changes: 0 additions & 63 deletions ESP8266WirelessPrintAsync/FileWrapper.h

This file was deleted.

22 changes: 9 additions & 13 deletions ESP8266WirelessPrintAsync/StorageFS.cpp
Original file line number Diff line number Diff line change
@@ -1,40 +1,36 @@
#include "StorageFS.h"

#if defined(ESP8266)
SdFat SD;
#endif
StorageFS storageFS;

bool StorageFS::hasSD,
StorageFS::hasSPIFFS;
unsigned int StorageFS::maxPathLength;


FileWrapper StorageFS::open(const String path, const char *openMode) {
FileWrapper file;
File StorageFS::open(const String path, const char *openMode) {
File file;

if (openMode == NULL || openMode[0] == '\0')
return file;

if (hasSD) {
#if defined(ESP8266)
file.sdFile = SD.open(path.c_str(), openMode[0] == 'w' ? (O_WRITE | O_CREAT | O_TRUNC) : FILE_READ);
if (file && file.sdFile.isDirectory())
file.sdFile.rewindDirectory();
file = SD.open(path.c_str(), openMode);
if (file && file.isDirectory())
file.rewindDirectory();
#elif defined(ESP32)
file.sdFile = SD.open(path, openMode);
file = SD.open(path, openMode);
#endif
}
else if (hasSPIFFS) {
#if defined(ESP8266)
if (path.endsWith("/")) {
file.fsDir = SPIFFS.openDir(path);
file.fsDirType = FileWrapper::DirSource;
file = SPIFFS.open(path, "r");
}
else
file.fsFile = SPIFFS.open(path, openMode);
file = SPIFFS.open(path, openMode);
#elif defined(ESP32)
file.fsFile = SPIFFS.open(path, openMode);
file = SPIFFS.open(path, openMode);
#endif
}

Expand Down
21 changes: 15 additions & 6 deletions ESP8266WirelessPrintAsync/StorageFS.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
#pragma once

#include "FileWrapper.h"

#if defined(ESP8266)
extern SdFat SD;
#include <SDFS.h>
#include <Arduino.h>
#define SD SDFS
#endif

#if defined(ESP32)
#include <SD.h>
#include <SPIFFS.h>
#include <SPI.h>
#endif

class StorageFS {
Expand All @@ -13,12 +20,14 @@ class StorageFS {
static unsigned int maxPathLength;

public:
inline static void begin(const bool fastSD) {
inline static void begin(const bool fastSD, int sdpin=SS) {
#if defined(ESP8266)
hasSD = SD.begin(SS, fastSD ? SD_SCK_MHZ(50) : SPI_HALF_SPEED); // https://github.com/esp8266/Arduino/issues/1853
SDFSConfig cfg(sdpin, fastSD ? SD_SCK_MHZ(50) : SPI_HALF_SPEED );
SDFS.setConfig(cfg);
hasSD = SDFS.begin(); // https://github.com/esp8266/Arduino/issues/1853
#elif defined(ESP32)
SPI.begin(14, 2, 15, 13); // TTGO-T1 V1.3 internal microSD slot
hasSD = SD.begin(SS, SPI, fastSD ? 50000000 : 4000000);
hasSD = SD.begin(sdpin, SPI, fastSD ? 50000000 : 4000000);
#endif
if (hasSD)
maxPathLength = 255;
Expand Down Expand Up @@ -56,7 +65,7 @@ class StorageFS {
return maxPathLength;
}

static FileWrapper open(const String path, const char *openMode = "r");
static File open(const String path, const char *openMode = "r");
static void remove(const String filename);
};

Expand Down
3 changes: 1 addition & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ src_dir = ESP8266WirelessPrintAsync
[common]
framework = arduino
lib_deps =
https://github.com/greiman/SdFat#3b79f38
https://github.com/me-no-dev/ESPAsyncWebServer#95dedf7
https://github.com/me-no-dev/ESPAsyncTCP#7e9ed22
https://github.com/me-no-dev/AsyncTCP#90715ae6
Expand All @@ -31,7 +30,7 @@ lib_deps =
[base:esp8266]
; corresponds to https://github.com/platformio/platform-espressif8266/releases/tag/v2.0.0
; see https://github.com/esp8266/Arduino/releases/tag/2.5.0
platform = espressif8266@2.0.0
platform = espressif8266@2.5.3
framework = ${common.framework}
lib_deps = ${common.lib_deps}

Expand Down