From 64b106c13e18c33be0f2b0de532054e0ed3f731d Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 13 Dec 2023 16:10:08 +1100 Subject: add a cool lua repl --- src/drivers/spiffs.cpp | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'src/drivers/spiffs.cpp') 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 -- cgit v1.2.3