Skip to content

Commit

Permalink
fix: smartflash get
Browse files Browse the repository at this point in the history
  • Loading branch information
LasaleFamine committed Jul 24, 2024
1 parent 4b69624 commit 0b7ffbb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=LualtekRAKRUI
version=0.3.9
version=0.3.10
author=Lualtek
maintainer=Lualtek <[email protected]>
sentence=Library for the Lualtek RAK RUI3 based board.
Expand Down
2 changes: 1 addition & 1 deletion src/DutyCycleHandler.cpp
Original file line number Diff line number Diff line change
@@ -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),
Expand Down
9 changes: 6 additions & 3 deletions src/SmartFlash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions src/SmartFlash.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <Arduino.h>

#define UPLINK_INTERVAL_OFFSET 0
#define CO2_MEASUREMENT_DELAY_OFFSET 1
#define CO2_ALTITUDE_OFFSET 2

class SmartFlash
{
Expand All @@ -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);
};
Expand Down

0 comments on commit 0b7ffbb

Please sign in to comment.