diff options
| author | ailurux <ailuruxx@gmail.com> | 2024-04-08 15:40:16 +1000 |
|---|---|---|
| committer | ailurux <ailuruxx@gmail.com> | 2024-04-08 15:40:16 +1000 |
| commit | f20ca9583af5312eea65cf144803d00be6e50602 (patch) | |
| tree | d6047ff952d6ad60a30ba038e6a5c72c64b8b0e7 /src/drivers | |
| parent | 01ae3fee30704577f4ea37ed7f2132990135163c (diff) | |
| parent | 96b62321c33ff5e146d52416dc5da3f0c240b4b0 (diff) | |
| download | tangara-fw-f20ca9583af5312eea65cf144803d00be6e50602.tar.gz | |
Merge branch 'main' of codeberg.org:cool-tech-zone/tangara-fw
Diffstat (limited to 'src/drivers')
| -rw-r--r-- | src/drivers/include/nvs.hpp | 4 | ||||
| -rw-r--r-- | src/drivers/include/samd.hpp | 4 | ||||
| -rw-r--r-- | src/drivers/nvs.cpp | 14 | ||||
| -rw-r--r-- | src/drivers/samd.cpp | 2 |
4 files changed, 21 insertions, 3 deletions
diff --git a/src/drivers/include/nvs.hpp b/src/drivers/include/nvs.hpp index f288f8e2..25396622 100644 --- a/src/drivers/include/nvs.hpp +++ b/src/drivers/include/nvs.hpp @@ -114,6 +114,9 @@ class NvsStorage { auto PrimaryInput() -> InputModes; auto PrimaryInput(InputModes) -> void; + auto DbAutoIndex() -> bool; + auto DbAutoIndex(bool) -> void; + explicit NvsStorage(nvs_handle_t); ~NvsStorage(); @@ -136,6 +139,7 @@ class NvsStorage { Setting<uint8_t> input_mode_; Setting<uint8_t> output_mode_; Setting<bluetooth::MacAndName> bt_preferred_; + Setting<uint8_t> db_auto_index_; util::LruCache<10, bluetooth::mac_addr_t, uint8_t> bt_volumes_; bool bt_volumes_dirty_; diff --git a/src/drivers/include/samd.hpp b/src/drivers/include/samd.hpp index ac265950..55ea513c 100644 --- a/src/drivers/include/samd.hpp +++ b/src/drivers/include/samd.hpp @@ -48,8 +48,8 @@ class Samd { // There is a compatible usb host attached, but USB MSC is not currently // in use by the SAMD. kAttachedIdle, - // The SAMD is currently exposing the SD card via USB MSC. - kAttachedMounted, + // The SAMD is currently writing to the SD card via USB MSC. + kAttachedBusy, }; auto GetUsbStatus() -> UsbStatus; diff --git a/src/drivers/nvs.cpp b/src/drivers/nvs.cpp index 28cb542c..33d92a9f 100644 --- a/src/drivers/nvs.cpp +++ b/src/drivers/nvs.cpp @@ -39,6 +39,7 @@ static constexpr char kKeyScrollSensitivity[] = "scroll"; static constexpr char kKeyLockPolarity[] = "lockpol"; static constexpr char kKeyDisplayCols[] = "dispcols"; static constexpr char kKeyDisplayRows[] = "disprows"; +static constexpr char kKeyDbAutoIndex[] = "dbautoindex"; static auto nvs_get_string(nvs_handle_t nvs, const char* key) -> std::optional<std::string> { @@ -173,6 +174,7 @@ NvsStorage::NvsStorage(nvs_handle_t handle) input_mode_(kKeyPrimaryInput), output_mode_(kKeyOutput), bt_preferred_(kKeyBluetoothPreferred), + db_auto_index_(kKeyDbAutoIndex), bt_volumes_(), bt_volumes_dirty_(false) {} @@ -194,6 +196,7 @@ auto NvsStorage::Read() -> void { input_mode_.read(handle_); output_mode_.read(handle_); bt_preferred_.read(handle_); + db_auto_index_.read(handle_); readBtVolumes(); } @@ -210,6 +213,7 @@ auto NvsStorage::Write() -> bool { input_mode_.write(handle_); output_mode_.write(handle_); bt_preferred_.write(handle_); + db_auto_index_.write(handle_); writeBtVolumes(); return nvs_commit(handle_) == ESP_OK; } @@ -370,6 +374,16 @@ auto NvsStorage::PrimaryInput(InputModes mode) -> void { input_mode_.set(static_cast<uint8_t>(mode)); } +auto NvsStorage::DbAutoIndex() -> bool { + std::lock_guard<std::mutex> lock{mutex_}; + return db_auto_index_.get().value_or(true); +} + +auto NvsStorage::DbAutoIndex(bool en) -> void { + std::lock_guard<std::mutex> lock{mutex_}; + db_auto_index_.set(static_cast<uint8_t>(en)); +} + class VolumesParseClient : public cppbor::ParseClient { public: VolumesParseClient(util::LruCache<10, bluetooth::mac_addr_t, uint8_t>& out) diff --git a/src/drivers/samd.cpp b/src/drivers/samd.cpp index b631b4fb..e47d9cfe 100644 --- a/src/drivers/samd.cpp +++ b/src/drivers/samd.cpp @@ -113,7 +113,7 @@ auto Samd::UpdateUsbStatus() -> void { usb_status_ = UsbStatus::kDetached; } usb_status_ = - (raw_res & 0b10) ? UsbStatus::kAttachedMounted : UsbStatus::kAttachedIdle; + (raw_res & 0b10) ? UsbStatus::kAttachedBusy : UsbStatus::kAttachedIdle; } auto Samd::ResetToFlashSamd() -> void { |
