Amend back button handling, add "use as sleep screen" feature

This commit is contained in:
jpirnay
2026-04-06 10:34:48 +02:00
parent ecac7ebdc7
commit 4ff9a10de1
5 changed files with 74 additions and 2 deletions
+2
View File
@@ -442,5 +442,7 @@ STR_UPTIME: "Uptime"
STR_CHARGING: "Charging"
STR_GATHERING_DATA: "Gathering data..."
STR_READING: "Reading..."
STR_SET_SLEEP_SCREEN: "Set Sleep"
STR_SLEEP_SCREEN_SET: "Sleep screen updated!"
STR_WEATHER_MOON_INFO: "Moon"
STR_WEATHER_SUN_INFO: "Sun"
+30
View File
@@ -7,6 +7,7 @@
#include <SdFat.h>
#include <cassert>
#include <new>
#define SDCard SDCardManager::getInstance()
@@ -138,6 +139,35 @@ bool HalStorage::openFileForWrite(const char* moduleName, const String& path, Ha
bool HalStorage::removeDir(const char* path) { HAL_STORAGE_WRAPPED_CALL(removeDir, path); }
bool HalStorage::copyFile(const char* moduleName, const std::string& srcPath, const char* dstPath) {
HalFile src, dst;
if (!openFileForRead(moduleName, srcPath, src)) return false;
if (!openFileForWrite(moduleName, dstPath, dst)) {
src.close();
return false;
}
constexpr size_t BUF_SIZE = 4096;
auto* buf = new (std::nothrow) uint8_t[BUF_SIZE];
if (!buf) {
dst.close();
src.close();
return false;
}
bool ok = true;
while (src.available()) {
const auto bytesRead = src.read(buf, BUF_SIZE);
if (bytesRead <= 0) break;
if (dst.write(buf, bytesRead) != static_cast<size_t>(bytesRead)) {
ok = false;
break;
}
}
delete[] buf;
dst.close();
src.close();
return ok;
}
// HalFile implementation
// Allow doing file operations while ensuring thread safety via HalStorage's mutex.
// Please keep the list below in sync with the HalFile.h header
+1
View File
@@ -44,6 +44,7 @@ class HalStorage {
bool openFileForWrite(const char* moduleName, const std::string& path, HalFile& file);
bool openFileForWrite(const char* moduleName, const String& path, HalFile& file);
bool removeDir(const char* path);
bool copyFile(const char* moduleName, const std::string& srcPath, const char* dstPath);
uint64_t sdTotalBytes() const;
uint64_t sdUsedBytes();