diff --git a/include/sta/drivers/w25qxx.hpp b/include/sta/drivers/w25qxx.hpp index 364ed62..b6d04ad 100644 --- a/include/sta/drivers/w25qxx.hpp +++ b/include/sta/drivers/w25qxx.hpp @@ -2,9 +2,7 @@ #define STA_SENSORS_W25Q128_HPP #include -//#include #include - #include #include diff --git a/include/sta/utils/logger.hpp b/include/sta/utils/logger.hpp index deed7a0..6a7e747 100644 --- a/include/sta/utils/logger.hpp +++ b/include/sta/utils/logger.hpp @@ -20,14 +20,17 @@ namespace sta * @param endSector The index of the end sector (1 LSB = 4096 bytes). */ Logger(W25Qxx * flash, uint32_t startSector, uint32_t endSector); - - void findLast(); + /** + * @brief Write a new data point to the flash chip as long as the segment's limit wasn't reached. + * + * @param data A pointer to the data to write to the flash chip. + * @return true if successful, false if the segment end was reached. + */ bool write(T* data); /** - * @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. + * @brief Write a new data point to the flash chip as long as the segment's limit wasn't reached. * * @param data The data to write to the flash chip. * @return true if successful, false if the segment end was reached. @@ -68,17 +71,22 @@ namespace sta * @return T The ith element stored in the flash storage. */ T get(std::size_t i); + private: + /** + * @brief Find the first sector in the segment that was not written yet. + * + */ + void findLast(); /** - * @brief Get the ith element stored in the flash storage. + * @brief A method that checks if a page is empty * - * @param i The index of the element to read. - * @return T The ith element stored in the flash storage. + * @param buffer A buffer of size 256 containing data from a page. + * @return true if the page is empty, false otherwise. */ - T operator[](std::size_t i); - private: bool searchCriterion(uint8_t * buffer); + private: W25Qxx * flash_; uint32_t start_; uint32_t end_; diff --git a/include/sta/utils/logger.tpp b/include/sta/utils/logger.tpp index 5bc4ee4..6d8bbb5 100644 --- a/include/sta/utils/logger.tpp +++ b/include/sta/utils/logger.tpp @@ -200,12 +200,6 @@ namespace sta return *reinterpret_cast(buffer); } } - - template - T Logger::operator[](std::size_t i) - { - return this->get(i); - } } // namespace sta #endif // STA_UTILS_LOGGER_TPP