summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-11-12 19:14:09 +1100
committerjacqueline <me@jacqueline.id.au>2023-11-12 19:14:09 +1100
commit8a0a167adbf3d9b6f8b6f16aaf20ca39ad5549de (patch)
tree02b6cf23f591915747ec2994381854a79979c4a0 /src/drivers
parent8471046a95ab9e00f7d42b56dbbc9ce3e5b424b9 (diff)
downloadtangara-fw-8a0a167adbf3d9b6f8b6f16aaf20ca39ad5549de.tar.gz
Convert the main menu screen to lua lol
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/CMakeLists.txt4
-rw-r--r--src/drivers/include/spiffs.hpp15
-rw-r--r--src/drivers/spiffs.cpp35
3 files changed, 52 insertions, 2 deletions
diff --git a/src/drivers/CMakeLists.txt b/src/drivers/CMakeLists.txt
index b2b5bfdd..7d1e048d 100644
--- a/src/drivers/CMakeLists.txt
+++ b/src/drivers/CMakeLists.txt
@@ -5,7 +5,7 @@
idf_component_register(
SRCS "touchwheel.cpp" "i2s_dac.cpp" "gpios.cpp" "adc.cpp" "storage.cpp" "i2c.cpp"
"spi.cpp" "display.cpp" "display_init.cpp" "samd.cpp" "relative_wheel.cpp" "wm8523.cpp"
- "nvs.cpp" "bluetooth.cpp" "haptics.cpp"
+ "nvs.cpp" "bluetooth.cpp" "haptics.cpp" "spiffs.cpp"
INCLUDE_DIRS "include"
- REQUIRES "esp_adc" "fatfs" "result" "lvgl" "span" "tasks" "nvs_flash" "bt" "tinyfsm")
+ REQUIRES "esp_adc" "fatfs" "result" "lvgl" "span" "tasks" "nvs_flash" "bt" "tinyfsm" "spiffs")
target_compile_options(${COMPONENT_LIB} PRIVATE ${EXTRA_WARNINGS})
diff --git a/src/drivers/include/spiffs.hpp b/src/drivers/include/spiffs.hpp
new file mode 100644
index 00000000..04478590
--- /dev/null
+++ b/src/drivers/include/spiffs.hpp
@@ -0,0 +1,15 @@
+/*
+ * Copyright 2023 jacqueline <me@jacqueline.id.au>
+ *
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+#pragma once
+
+#include "esp_err.h"
+
+namespace drivers {
+
+esp_err_t spiffs_mount();
+
+} // namespace drivers
diff --git a/src/drivers/spiffs.cpp b/src/drivers/spiffs.cpp
new file mode 100644
index 00000000..9a85c0d3
--- /dev/null
+++ b/src/drivers/spiffs.cpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2023 jacqueline <me@jacqueline.id.au>
+ *
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+#include "spiffs.hpp"
+
+#include "esp_err.h"
+#include "esp_log.h"
+#include "esp_spiffs.h"
+
+namespace drivers {
+
+[[maybe_unused]] static constexpr char kTag[] = "spiffs";
+
+esp_err_t spiffs_mount() {
+ esp_vfs_spiffs_conf_t config{
+ .base_path = "/lua",
+ .partition_label = "lua",
+ .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("lua", &total, &used);
+ ESP_LOGI(kTag, "spiffs mounted okay. %d / %d ", used / 1024, total / 1024);
+ }
+
+ return res;
+}
+
+} // namespace drivers