From 0b7ffbb583d03c22dfa31889e2cffc3509d224db Mon Sep 17 00:00:00 2001 From: LasaleFamine Date: Wed, 24 Jul 2024 11:39:03 +0200 Subject: [PATCH] fix: smartflash get --- library.json | 2 +- library.properties | 2 +- src/DutyCycleHandler.cpp | 2 +- src/SmartFlash.cpp | 9 ++++++--- src/SmartFlash.h | 3 +++ 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/library.json b/library.json index 327e3e6..2163ccf 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "lualtek-rakrui", - "version": "0.3.9", + "version": "0.3.10", "description": "An opinionated wrapper around RUI3 APIs", "repository": { "type": "git", diff --git a/library.properties b/library.properties index e2d20a1..cbf740c 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=LualtekRAKRUI -version=0.3.9 +version=0.3.10 author=Lualtek maintainer=Lualtek sentence=Library for the Lualtek RAK RUI3 based board. diff --git a/src/DutyCycleHandler.cpp b/src/DutyCycleHandler.cpp index 1533514..92e4bda 100644 --- a/src/DutyCycleHandler.cpp +++ b/src/DutyCycleHandler.cpp @@ -1,7 +1,7 @@ #include "DutyCycleHandler.h" #include "SmartFlash.h" -extern SmartFlash smartflash; +SmartFlash smartflash; DutyCycleHandler::DutyCycleHandler(lualtek_dowlink_command_dutycycle_index_t defaultDutyCycleIndex) : defaultDutyCycleIndex(defaultDutyCycleIndex), diff --git a/src/SmartFlash.cpp b/src/SmartFlash.cpp index dd35169..5cceb28 100644 --- a/src/SmartFlash.cpp +++ b/src/SmartFlash.cpp @@ -10,7 +10,8 @@ bool SmartFlash::saveUplinkIntervalIndex(uint8_t interval) uint8_t SmartFlash::getUplinkIntervalIndex() { - return readFromFlash(UPLINK_INTERVAL_OFFSET, &_intervalIndex, sizeof(_intervalIndex)); + readFromFlash(UPLINK_INTERVAL_OFFSET, &_intervalIndex, sizeof(_intervalIndex)); + return _intervalIndex; } bool SmartFlash::saveCO2MeasurementDelayIndex(uint8_t data) @@ -22,7 +23,8 @@ bool SmartFlash::saveCO2MeasurementDelayIndex(uint8_t data) uint8_t SmartFlash::getCO2MeasurementDelayIndex() { - return readFromFlash(_co2MeasurementDelayIndexOffset, &_co2MeasurementDelayIndex, sizeof(_co2MeasurementDelayIndex)); + readFromFlash(_co2MeasurementDelayIndexOffset, &_co2MeasurementDelayIndex, sizeof(_co2MeasurementDelayIndex)); + return _co2MeasurementDelayIndex; } bool SmartFlash::saveCO2AltitudeIndex(uint8_t data) @@ -34,7 +36,8 @@ bool SmartFlash::saveCO2AltitudeIndex(uint8_t data) uint8_t SmartFlash::getCO2AltitudeIndex() { - return readFromFlash(_co2AltitudeIndexOffset, &_co2AltitudeIndex, sizeof(_co2AltitudeIndex)); + readFromFlash(_co2AltitudeIndexOffset, &_co2AltitudeIndex, sizeof(_co2AltitudeIndex)); + return _co2AltitudeIndex; } bool SmartFlash::writeToFlash(uint32_t offset, uint8_t *data, size_t length) diff --git a/src/SmartFlash.h b/src/SmartFlash.h index 5c1b935..111775e 100644 --- a/src/SmartFlash.h +++ b/src/SmartFlash.h @@ -4,6 +4,8 @@ #include #define UPLINK_INTERVAL_OFFSET 0 +#define CO2_MEASUREMENT_DELAY_OFFSET 1 +#define CO2_ALTITUDE_OFFSET 2 class SmartFlash { @@ -28,6 +30,7 @@ class SmartFlash uint8_t _co2MeasurementDelayIndexOffset = 0; uint8_t _co2AltitudeIndex = 0; uint8_t _co2AltitudeIndexOffset = 0; + uint8_t flashData[16] = {0}; bool writeToFlash(uint32_t offset, uint8_t *data, size_t length); bool readFromFlash(uint32_t offset, uint8_t *data, size_t length); };