From 55bde70b9651b411ac0135bd4704f5b6972ea799 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 10 Jan 2024 20:32:01 +1100 Subject: add accurate esp and samd versions + expose this info to lua --- src/drivers/samd.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/drivers/samd.cpp') diff --git a/src/drivers/samd.cpp b/src/drivers/samd.cpp index cf3b9c18..f12a18de 100644 --- a/src/drivers/samd.cpp +++ b/src/drivers/samd.cpp @@ -8,6 +8,7 @@ #include #include +#include #include "esp_err.h" #include "esp_log.h" @@ -37,23 +38,26 @@ Samd::Samd() { // Being able to interface with the SAMD properly is critical. To ensure we // will be able to, we begin by checking the I2C protocol version is // compatible, and throw if it's not. - uint8_t raw_res = 0; I2CTransaction transaction; transaction.start() .write_addr(kAddress, I2C_MASTER_WRITE) .write_ack(Registers::kSamdFirmwareVersion) .start() .write_addr(kAddress, I2C_MASTER_READ) - .read(&raw_res, I2C_MASTER_NACK) + .read(&version_, I2C_MASTER_NACK) .stop(); ESP_ERROR_CHECK(transaction.Execute(1)); - ESP_LOGI(kTag, "samd firmware rev: %u", raw_res); + ESP_LOGI(kTag, "samd firmware rev: %u", version_); UpdateChargeStatus(); UpdateUsbStatus(); } Samd::~Samd() {} +auto Samd::Version() -> std::string { + return std::to_string(version_); +} + auto Samd::GetChargeStatus() -> std::optional { return charge_status_; } -- cgit v1.2.3