Skip to content

Refactoring EPS32NVS library to Preferences library #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 11, 2017
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
56 changes: 0 additions & 56 deletions libraries/ESP32NVS/examples/StartCounter/StartCounter.ino

This file was deleted.

41 changes: 0 additions & 41 deletions libraries/ESP32NVS/keywords.txt

This file was deleted.

56 changes: 56 additions & 0 deletions libraries/Preferences/examples/StartCounter/StartCounter.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
ESP32 start counter example with Preferences library

This simple example demonstrate using Preferences library to store how many times
was ESP32 module started. Preferences library is wrapper around Non-volatile
storage on ESP32 processor.

created for arduino-esp32 09 Feb 2017
by Martin Sloup (Arcao)
*/

#include <Preferences.h>

Preferences preferences;

void setup() {
Serial.begin(115200);
Serial.println();

// Open Preferences with my-app namespace. Each application module, library, etc.
// has to use namespace name to prevent key name collisions. We will open storage in
// RW-mode (second parameter has to be false).
// Note: Namespace name is limited to 15 chars
preferences.begin("my-app", false);

// Remove all preferences under opened namespace
//preferences.clear();

// Or remove the counter key only
//preferences.remove("counter");

// Get a counter value, if key is not exist return default value 0
// Note: Key name is limited to 15 chars too
unsigned int counter = preferences.getUInt("counter", 0);

// Increase counter
counter++;

// Print counter to a Serial
Serial.printf("Current counter value: %u\n", counter);

// Store counter to the Preferences
preferences.putUInt("counter", counter);

// Close the Preferences
preferences.end();

// Wait 10 seconds
Serial.println("Restarting in 10 seconds...");
delay(10000);

// Restart ESP
ESP.restart();
}

void loop() {}
54 changes: 54 additions & 0 deletions libraries/Preferences/keywords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#######################################
# Syntax Coloring Map NVS
#######################################

#######################################
# Datatypes (KEYWORD1)
#######################################

Preferences KEYWORD1

#######################################
# Methods and Functions (KEYWORD2)
#######################################
begin KEYWORD2
end KEYWORD2

clear KEYWORD2
delete KEYWORD2

putChar KEYWORD2
putUChar KEYWORD2
putShort KEYWORD2
putUShort KEYWORD2
putInt KEYWORD2
putUInt KEYWORD2
putLong KEYWORD2
putULong KEYWORD2
putLong64 KEYWORD2
putULong64 KEYWORD2
putFloat KEYWORD2
putDouble KEYWORD2
putBool KEYWORD2
putString KEYWORD2
putBytes KEYWORD2

getChar KEYWORD2
getUChar KEYWORD2
getShort KEYWORD2
getUShort KEYWORD2
getInt KEYWORD2
getUInt KEYWORD2
getLong KEYWORD2
getULong KEYWORD2
getLong64 KEYWORD2
getULong64 KEYWORD2
getFloat KEYWORD2
getDouble KEYWORD2
getBool KEYWORD2
getString KEYWORD2
getBytes KEYWORD2

#######################################
# Constants (LITERAL1)
#######################################
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name=ESP32NVS
name=Preferences
version=1.0
author=Hristo Gochkov
maintainer=Hristo Gochkov <hristo@espressif.com>
sentence=Provides frendly access to ESP32's Non-Volatile Storage
sentence=Provides friendly access to ESP32's Non-Volatile Storage
paragraph=
category=Data Storage
url=
Expand Down
Loading