Skip to content

Commit

Permalink
Added simple example
Browse files Browse the repository at this point in the history
  • Loading branch information
drkr committed Jan 21, 2019
1 parent 01b4696 commit 0210b57
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
41 changes: 41 additions & 0 deletions examples/simpleFlashNVS.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <Arduino.h>
#include "ArduinoNvs.h"

/**
* Arduino NVS is a port for a non-volatile storage (NVS, flash) library for ESP32 to the Arduino Platform.
* It wraps main NVS functionality into the Arduino-styled C++ class.
*/

void setup() {
NVS.begin();
}

void loop() {
bool res;
/*** Int ***/
// write to flash
const uint64_t ui64_set = 0x1122334455667788;
res = NVS.setInt("longInt", ui64_set);
// read from flash
uint64_t uui64 = NVS.getInt("longInt");


/*** String ***/
// write to flash
const String st_set = "`simple plain string`";
res = NVS.setString("st", st_set);
// read from flash
String st = NVS.getString("st");


/*** BLOB ***/
//write to flash
uint8_t blolb_set[] = {1,2,3,99,100, 0xEE, 0xFE, 0xEE};
res = NVS.setBlob("blob", blolb_set, sizeof(blolb_set));
// read from flash
size_t blobLength = NVS.getBlobSize("blob");
uint8_t blob[blobLength];
res = NVS.getBlob("blob", blob, sizeof(blob));

delay(1000);
}
7 changes: 6 additions & 1 deletion examples/example.ino → examples/uart-controlled.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#include <Arduino.h>
#include "ArduinoNvs.h"

/**
* Arduino NVS is a port for a non-volatile storage (NVS, flash) library for ESP32 to the Arduino Platform.
* It wraps main NVS functionality into the Arduino-styled C++ class.
*/

using namespace std;

#define PRINT(...) Serial.print(__VA_ARGS__)
Expand Down Expand Up @@ -64,7 +69,7 @@ void loop() {
DEBUG("6. nvss: ui64 %llu", uui64);
} break;
case '7': {
uint64_t ii64 = nvss.getInt("i64");
int64_t ii64 = nvss.getInt("i64");
DEBUG("7. nvss: i64 %lli", ii64);
} break;
case 'w': {
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "git",
"url": "https://github.com/rpolitex/ArduinoNvs"
},
"version": "1.0",
"version": "2.1",
"authors": [
{
"name": "dRKr",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ArduinoNvs
version=1.1
version=2.1
author=dRKr <info@sinai.io>
maintainer=SinaiRnD <www: www.sinai.io>
sentence=Arduino wrapper for ESP32 NVS (Non-volatile storage)
Expand Down

0 comments on commit 0210b57

Please sign in to comment.