diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-12-13 16:10:08 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-12-13 16:10:08 +1100 |
| commit | 64b106c13e18c33be0f2b0de532054e0ed3f731d (patch) | |
| tree | b54b1c90d941bc456b4d51e864970720bdf2d648 /src/drivers | |
| parent | 5a2f0b08e0e3f20cda977b510b680d5843ae7283 (diff) | |
| download | tangara-fw-64b106c13e18c33be0f2b0de532054e0ed3f731d.tar.gz | |
add a cool lua repl
Diffstat (limited to 'src/drivers')
| -rw-r--r-- | src/drivers/include/gpios.hpp | 2 | ||||
| -rw-r--r-- | src/drivers/spiffs.cpp | 35 |
2 files changed, 34 insertions, 3 deletions
diff --git a/src/drivers/include/gpios.hpp b/src/drivers/include/gpios.hpp index fe4b1c4c..a201c173 100644 --- a/src/drivers/include/gpios.hpp +++ b/src/drivers/include/gpios.hpp @@ -78,7 +78,7 @@ class IGpios { */ virtual auto Get(Pin) const -> bool = 0; - virtual auto IsLocked() const -> bool { return Get(Pin::kKeyLock); } + virtual auto IsLocked() const -> bool { return !Get(Pin::kKeyLock); } }; class Gpios : public IGpios { diff --git a/src/drivers/spiffs.cpp b/src/drivers/spiffs.cpp index 9a85c0d3..f03d2f68 100644 --- a/src/drivers/spiffs.cpp +++ b/src/drivers/spiffs.cpp @@ -14,7 +14,7 @@ namespace drivers { [[maybe_unused]] static constexpr char kTag[] = "spiffs"; -esp_err_t spiffs_mount() { +static auto mount_script_dir() -> esp_err_t { esp_vfs_spiffs_conf_t config{ .base_path = "/lua", .partition_label = "lua", @@ -26,10 +26,41 @@ esp_err_t spiffs_mount() { if (res == ESP_OK) { size_t total, used; esp_spiffs_info("lua", &total, &used); - ESP_LOGI(kTag, "spiffs mounted okay. %d / %d ", used / 1024, total / 1024); + ESP_LOGI(kTag, "lua scripts mounted okay. %d / %d ", used / 1024, + total / 1024); } return res; } +static auto mount_repl_dir() -> esp_err_t { + esp_vfs_spiffs_conf_t config{ + .base_path = "/repl", + .partition_label = "repl", + .max_files = 5, + .format_if_mount_failed = false, + }; + + esp_err_t res = esp_vfs_spiffs_register(&config); + if (res == ESP_OK) { + size_t total, used; + esp_spiffs_info("repl", &total, &used); + ESP_LOGI(kTag, "lua repl mounted okay. %d / %d ", used / 1024, + total / 1024); + } + + return res; +} + +esp_err_t spiffs_mount() { + esp_err_t res; + if ((res = mount_script_dir()) != ESP_OK) { + return res; + } + if ((res = mount_repl_dir()) != ESP_OK) { + return res; + } + return ESP_OK; +} + } // namespace drivers |
