-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* CamFlip, settings * Altitude sensor reading fix * CamFlip timeout, added voice line
- Loading branch information
Showing
13 changed files
with
162 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "Settings.h" | ||
#include <esp_log.h> | ||
#include <nvs_flash.h> | ||
|
||
static const char* TAG = "Settings"; | ||
|
||
Settings::Settings(){ | ||
nvs_flash_init(); | ||
|
||
auto err = nvs_open(NVSNamespace, NVS_READWRITE, &handle); | ||
ESP_ERROR_CHECK(err); | ||
load(); | ||
} | ||
|
||
SettingsStruct Settings::get(){ | ||
return settingsStruct; | ||
} | ||
|
||
void Settings::set(SettingsStruct& settings){ | ||
settingsStruct = settings; | ||
} | ||
|
||
void Settings::store(){ | ||
esp_err_t err = nvs_set_blob(handle, BlobName, &settingsStruct, sizeof(SettingsStruct)); | ||
|
||
if(err != ESP_OK){ | ||
ESP_LOGW(TAG, "NVS settings store error: %d", err); | ||
return; | ||
} | ||
|
||
err = nvs_commit(handle); | ||
if(err != ESP_OK){ | ||
ESP_LOGW(TAG, "NVS settings commit error: %d", err); | ||
} | ||
} | ||
|
||
void Settings::load(){ | ||
size_t out_size = sizeof(SettingsStruct); | ||
auto err = nvs_get_blob(handle, BlobName, &settingsStruct, &out_size); | ||
if(err != ESP_OK){ | ||
ESP_LOGI(TAG, "Settings not found, writing defaults"); | ||
store(); | ||
err = nvs_get_blob(handle, BlobName, &settingsStruct, &out_size); | ||
if(err != ESP_OK){ | ||
ESP_LOGE(TAG, "Couldn't access NVS settings: %d", err); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifndef PERSE_ROVER_SETTINGS_H | ||
#define PERSE_ROVER_SETTINGS_H | ||
|
||
#include <nvs.h> | ||
|
||
struct SettingsStruct { | ||
bool cameraHorizontalFlip = false; | ||
}; | ||
|
||
class Settings { | ||
public: | ||
Settings(); | ||
|
||
SettingsStruct get(); | ||
void set(SettingsStruct& settings); | ||
void store(); | ||
|
||
private: | ||
nvs_handle_t handle{}; | ||
SettingsStruct settingsStruct; | ||
|
||
static constexpr const char* NVSNamespace = "Rover"; | ||
static constexpr const char* BlobName = "Settings"; | ||
|
||
void load(); | ||
}; | ||
|
||
|
||
|
||
#endif //PERSE_ROVER_SETTINGS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.