Updated logging, binary search to find starting point.

This commit is contained in:
dario
2024-06-04 18:40:48 +02:00
parent a15b2398ab
commit 33e034a429
4 changed files with 56 additions and 24 deletions

View File

@@ -20,14 +20,15 @@ namespace sta
* @param endSector The index of the end sector (1 LSB = 4096 bytes).
*/
Logger(W25Qxx * flash, uint32_t startSector, uint32_t endSector);
/**
* @brief Write a new data point to the flash chip.
* @note If the total capacity of this logger was exceeded, it restarts at the first sector, overwriting its data.
*
* @param data The data to write to the flash chip.
* @param data The data to write to the flash chip.
* @return true if successful, false if the segment end was reached.
*/
void write(T data);
bool write(T data);
/**
* @brief Clear the flash memory used by the logger.
@@ -40,7 +41,7 @@ namespace sta
*
* @return size_t The number of data points.
*/
size_t occupied();
size_t count();
/**
* @brief Get the number of data points that can be written to the logger before an overflow occurs.
@@ -54,16 +55,18 @@ namespace sta
*
* @return size_t The number of data points.
*/
size_t length();
size_t capacity();
/**
* @brief Allows reading a single data point from the segment.
*
* @param idx The index of the segement.
* @return const T& The read data value.
* @return T The read data value.
*/
T operator[](std::size_t idx);
private:
void findLast();
W25Qxx * flash_;
uint32_t start_;
uint32_t end_;