Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: CI
on:
push:
branches: [ "master" ]
branches: [ "**" ]
pull_request:
branches: [ "master" ]
branches: [ "**" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "components/esp32-button"]
path = components/esp32-button
url = https://github.com/void-spark/esp32-button.git
[submodule "components/littlefs"]
path = components/littlefs
url = https://github.com/joltwallet/esp_littlefs.git
2 changes: 1 addition & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"${workspaceFolder}/sdk/idf/components/soc/esp32/include",
"${workspaceFolder}/sdk/idf/components/soc/include",
"${workspaceFolder}/sdk/idf/components/spi_flash/include",
"${workspaceFolder}/sdk/idf/components/spiffs/include",
"${workspaceFolder}/sdk/idf/components/littlefs/include",
"${workspaceFolder}/sdk/idf/components/tcp_transport/include",
"${workspaceFolder}/sdk/idf/components/ulp/ulp_common/include",
"${workspaceFolder}/sdk/idf/components/ulp/ulp_common/include/esp32",
Expand Down
1 change: 1 addition & 0 deletions components/littlefs
Submodule littlefs added at 827437
4 changes: 3 additions & 1 deletion main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
idf_component_register(SRC_DIRS "." "states"
INCLUDE_DIRS ".")
INCLUDE_DIRS "."
REQUIRES esp32-button driver littlefs esp_timer nvs_flash esp_adc
)
2 changes: 1 addition & 1 deletion main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ static void my_task(void *pvParameter) {
adc_init();
#endif

init_spiffs();
init_littlefs();

initUart();

Expand Down
32 changes: 18 additions & 14 deletions main/storage.cpp
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
#include <sys/stat.h>
#include "esp_log.h"
#include "esp_spiffs.h"
#include "esp_littlefs.h"
#include "storage.h"

static const char *TAG = "storage";

#define CALIBRATION_FILE "/spiffs/calibration.bin"
#define CALIBRATION_FILE "/littlefs/calibration.bin"

void init_spiffs() {
ESP_LOGI(TAG, "Initializing SPIFFS");
void init_littlefs() {
ESP_LOGI(TAG, "Initializing LittleFS");

esp_vfs_spiffs_conf_t spiffs_conf = {};
spiffs_conf.base_path = "/spiffs";
spiffs_conf.partition_label = NULL;
spiffs_conf.max_files = 5;
spiffs_conf.format_if_mount_failed = true;
esp_vfs_littlefs_conf_t conf = {
.base_path = "/littlefs",
.partition_label = "littlefs", // moet overeenkomen met je partitions.csv
.partition = NULL,
.format_if_mount_failed = true,
.read_only = false,
.dont_mount = false,
.grow_on_mount = true
};

ESP_ERROR_CHECK(esp_vfs_spiffs_register(&spiffs_conf));
ESP_ERROR_CHECK(esp_vfs_littlefs_register(&conf));

size_t total = 0, used = 0;
esp_err_t ret = esp_spiffs_info(spiffs_conf.partition_label, &total, &used);
if(ret != ESP_OK) {
ESP_LOGE(TAG, "Failed to get SPIFFS partition information (%s)", esp_err_to_name(ret));
esp_err_t ret = esp_littlefs_info(conf.partition_label, &total, &used);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Failed to get LittleFS partition information (%s)", esp_err_to_name(ret));
} else {
ESP_LOGI(TAG, "Partition size: total: %d, used: %d", total, used);
}
Expand Down Expand Up @@ -80,4 +84,4 @@ bool writeData(const char * path, void * source, size_t size) {
fclose(fp);

return true;
}
}
2 changes: 1 addition & 1 deletion main/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <sys/unistd.h>

void init_spiffs();
void init_littlefs();

// Is a calibration file stored?
bool calibrationFileExists();
Expand Down
2 changes: 1 addition & 1 deletion main/trip.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "storage.h"
#include "trip.h"

#define DISTANCE_FILE "/spiffs/distance.bin"
#define DISTANCE_FILE "/littleFS/distance.bin"

struct distancesStruct {
// Trip-1 in 10m increments
Expand Down
10 changes: 5 additions & 5 deletions partitions.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, , 0x4000,
phy_init, data, phy, , 0x1000,
factory, app, factory, , 1M,
spiffs, data, spiffs, , 1M,
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, , 0x4000,
phy_init, data, phy, , 0x1000,
factory, app, factory, , 1M,
littlefs, data, littlefs, , 1M,
2 changes: 1 addition & 1 deletion sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CONFIG_ION_CU3=y
# My chips are 4MB flash, once you use OTA this settings matters
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y

# Set up partitions for SPIFFS
# Set up partitions for littlefs
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"

Expand Down
6 changes: 3 additions & 3 deletions sdkconfig.supermini
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ CONFIG_ION_LIGHT=n
CONFIG_ION_LIGHT_PIN=1
CONFIG_ION_LIGHT_PIN_INVERTED=n

CONFIG_ION_RELAY=n
CONFIG_ION_RELAY=y
CONFIG_ION_RELAY_PIN=0
CONFIG_ION_RELAY_PIN_INVERTED=n

CONFIG_ESP32C3_DEFAULT_CPU_FREQ_160=y

CONFIG_ION_ADC=y
# ADC channel 1 is pin 4
CONFIG_ION_ADC_CHAN=4
# ADC channel 1 is pin 2
CONFIG_ION_ADC_CHAN=2

# The scale of the divider, times 1000, from APM power module
CONFIG_ION_DIVIDER_SCALE=10829
Expand Down