mirror of
https://github.com/scottbez1/smartknob.git
synced 2025-09-26 23:09:27 +08:00
Swap out SPIFFS for FFAT, which doesn't suffer from performance issues
This commit is contained in:
parent
d72621ae00
commit
68a2d89e71
@ -8,4 +8,4 @@ otadata, data, ota, 0xe000, 8K,
|
||||
ota_0, 0, ota_0, 0x10000, 1408K,
|
||||
ota_1, 0, ota_1, 0x170000, 1408K,
|
||||
uf2, app, factory,0x2d0000, 256K,
|
||||
spiffs, data, spiffs, 0x310000, 960K,
|
||||
ffat, data, fat, 0x310000, 960K,
|
|
@ -1,4 +1,4 @@
|
||||
#include <SPIFFS.h>
|
||||
#include <FFat.h>
|
||||
|
||||
#include "pb_decode.h"
|
||||
#include "pb_encode.h"
|
||||
@ -21,12 +21,12 @@ Configuration::~Configuration() {
|
||||
|
||||
bool Configuration::loadFromDisk() {
|
||||
SemaphoreGuard lock(mutex_);
|
||||
SPIFFSGuard spiffs(logger_);
|
||||
if (!spiffs.ok_) {
|
||||
FatGuard fatGuard(logger_);
|
||||
if (!fatGuard.mounted_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
File f = SPIFFS.open(CONFIG_PATH);
|
||||
File f = FFat.open(CONFIG_PATH);
|
||||
if (!f) {
|
||||
log("Failed to read config file");
|
||||
return false;
|
||||
@ -77,11 +77,11 @@ bool Configuration::saveToDisk() {
|
||||
return false;
|
||||
}
|
||||
|
||||
SPIFFSGuard spiffs(logger_);
|
||||
if (!spiffs.ok_) {
|
||||
FatGuard fatGuard(logger_);
|
||||
if (!fatGuard.mounted_) {
|
||||
return false;
|
||||
}
|
||||
File f = SPIFFS.open(CONFIG_PATH, FILE_WRITE);
|
||||
File f = FFat.open(CONFIG_PATH, FILE_WRITE);
|
||||
if (!f) {
|
||||
log("Failed to read config file");
|
||||
return false;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <SPIFFS.h>
|
||||
#include <FFat.h>
|
||||
#include <PacketSerial.h>
|
||||
|
||||
#include "proto_gen/smartknob.pb.h"
|
||||
@ -31,27 +31,32 @@ class Configuration {
|
||||
|
||||
void log(const char* msg);
|
||||
};
|
||||
class SPIFFSGuard {
|
||||
class FatGuard {
|
||||
public:
|
||||
SPIFFSGuard(Logger* logger) : logger_(logger) {
|
||||
if (!SPIFFS.begin(true)) {
|
||||
if (logger != nullptr) {
|
||||
logger->log("Failed to mount SPIFFS");
|
||||
FatGuard(Logger* logger) : logger_(logger) {
|
||||
if (!FFat.begin(true)) {
|
||||
if (logger_ != nullptr) {
|
||||
logger_->log("Failed to mount FFat");
|
||||
}
|
||||
return;
|
||||
}
|
||||
ok_ = true;
|
||||
if (logger_ != nullptr) {
|
||||
logger_->log("Mounted FFat");
|
||||
}
|
||||
mounted_ = true;
|
||||
}
|
||||
~SPIFFSGuard() {
|
||||
if (ok_) {
|
||||
SPIFFS.end();
|
||||
logger_->log("Unmounted SPIFFS");
|
||||
~FatGuard() {
|
||||
if (mounted_) {
|
||||
FFat.end();
|
||||
if (logger_ != nullptr) {
|
||||
logger_->log("Unmounted FFat");
|
||||
}
|
||||
}
|
||||
}
|
||||
SPIFFSGuard(SPIFFSGuard const&)=delete;
|
||||
SPIFFSGuard& operator=(SPIFFSGuard const&)=delete;
|
||||
FatGuard(FatGuard const&)=delete;
|
||||
FatGuard& operator=(FatGuard const&)=delete;
|
||||
|
||||
bool ok_ = false;
|
||||
bool mounted_ = false;
|
||||
|
||||
private:
|
||||
Logger* logger_;
|
||||
|
@ -22,7 +22,7 @@ static const float IDLE_CORRECTION_MAX_ANGLE_RAD = 5 * PI / 180;
|
||||
static const float IDLE_CORRECTION_RATE_ALPHA = 0.0005;
|
||||
|
||||
|
||||
MotorTask::MotorTask(const uint8_t task_core, Configuration& configuration) : Task("Motor", 3200, 1, task_core), configuration_(configuration) {
|
||||
MotorTask::MotorTask(const uint8_t task_core, Configuration& configuration) : Task("Motor", 4000, 1, task_core), configuration_(configuration) {
|
||||
queue_ = xQueueCreate(5, sizeof(Command));
|
||||
assert(queue_ != NULL);
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ build_flags =
|
||||
[env:view]
|
||||
extends = base_config
|
||||
board = esp32doit-devkit-v1
|
||||
board_build.partitions = default_ffat.csv
|
||||
lib_deps =
|
||||
${base_config.lib_deps}
|
||||
askuric/Simple FOC @ 2.2.0
|
||||
@ -130,7 +131,7 @@ build_flags =
|
||||
extends = base_config
|
||||
platform = espressif32@6.3.1
|
||||
board = adafruit_feather_esp32s3
|
||||
board_build.partitions = firmware/partitions-4MB-spiffs.csv
|
||||
board_build.partitions = firmware/partitions-4MB-fat.csv
|
||||
lib_deps =
|
||||
${base_config.lib_deps}
|
||||
askuric/Simple FOC@^2.3.0
|
||||
|
Loading…
Reference in New Issue
Block a user