-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d91241
commit efc3e88
Showing
8 changed files
with
95 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name=LualtekRAKRUI | ||
version=0.3.5 | ||
version=0.3.6 | ||
author=Lualtek | ||
maintainer=Lualtek <[email protected]> | ||
sentence=Library for the Lualtek RAK RUI3 based board. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include "SmartFlash.h" | ||
|
||
SmartFlash::SmartFlash() {} | ||
|
||
bool SmartFlash::saveUplinkIntervalIndex(uint8_t interval) | ||
{ | ||
_intervalIndex = interval; | ||
return writeToFlash(UPLINK_INTERVAL_OFFSET, &interval, sizeof(_intervalIndex)); | ||
} | ||
|
||
uint8_t SmartFlash::getUplinkIntervalIndex() | ||
{ | ||
return readFromFlash(UPLINK_INTERVAL_OFFSET, &_intervalIndex, sizeof(_intervalIndex)); | ||
} | ||
|
||
bool SmartFlash::saveCO2MeasurementDelay(uint8_t data) | ||
{ | ||
_co2MeasurementDelay = data; | ||
_co2MeasurementDelayOffset = UPLINK_INTERVAL_OFFSET + sizeof(_intervalIndex); | ||
return writeToFlash(_co2MeasurementDelayOffset, &data, sizeof(_co2MeasurementDelay)); | ||
} | ||
|
||
uint8_t SmartFlash::getCO2MeasurementDelay() | ||
{ | ||
return readFromFlash(_co2MeasurementDelayOffset, &_co2MeasurementDelay, sizeof(_co2MeasurementDelay)); | ||
} | ||
|
||
bool SmartFlash::saveCO2Altitude(uint8_t data) | ||
{ | ||
_co2Altitude = data; | ||
_co2AltitudeOffset = _co2MeasurementDelayOffset + sizeof(_co2MeasurementDelay); | ||
return writeToFlash(_co2AltitudeOffset, &data, sizeof(_co2Altitude)); | ||
} | ||
|
||
bool SmartFlash::writeToFlash(uint32_t offset, uint8_t *data, size_t length) | ||
{ | ||
return api.system.flash.set(offset, data, length); | ||
} | ||
|
||
bool SmartFlash::readFromFlash(uint32_t offset, uint8_t *data, size_t length) | ||
{ | ||
return api.system.flash.get(offset, data, length); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef _SMARTFLASH_H_ | ||
#define _SMARTFLASH_H_ | ||
|
||
#include <Arduino.h> | ||
|
||
#define UPLINK_INTERVAL_OFFSET 0 | ||
|
||
class SmartFlash | ||
{ | ||
public: | ||
SmartFlash(); | ||
|
||
// Save and retrieve uplink interval | ||
bool saveUplinkIntervalIndex(uint8_t interval); | ||
uint8_t getUplinkIntervalIndex(); | ||
|
||
// Save and retrieve CO2 sensor data | ||
bool saveCO2MeasurementDelay(uint8_t data); | ||
uint8_t getCO2MeasurementDelay(); | ||
|
||
bool saveCO2Altitude(uint8_t data); | ||
uint8_t getCO2Altitude(); | ||
|
||
private: | ||
uint8_t _intervalIndex = 0; | ||
uint8_t _co2MeasurementDelay = 0; | ||
uint8_t _co2MeasurementDelayOffset = 0; | ||
uint8_t _co2Altitude = 0; | ||
uint8_t _co2AltitudeOffset = 0; | ||
bool writeToFlash(uint32_t offset, uint8_t *data, size_t length); | ||
bool readFromFlash(uint32_t offset, uint8_t *data, size_t length); | ||
}; | ||
|
||
#endif // SMARTFLASH_H |