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

Conversation

arcao
Copy link
Contributor

@arcao arcao commented Feb 11, 2017

  • Renaming all set* functions to put
  • Added functions for float, double and bool

Test code:

#include <Preferences.h>

Preferences preferences;

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

  preferences.begin("my-app", false);
  preferences.clear();

  preferences.putChar("char", -8);
  preferences.putUChar("uchar", 8);
  preferences.putShort("short", -16);
  preferences.putUShort("ushort", 16);
  preferences.putInt("int", -32);
  preferences.putUInt("uint", 32);
  preferences.putLong("long", -32);
  preferences.putULong("ulong", 32);
  preferences.putLong64("int64_t", -64);
  preferences.putULong64("uint64_t", 64);

  preferences.putFloat("float", 12.34);
  preferences.putDouble("double", 12.34);

  preferences.putBool("bool", true);

  preferences.putString("char*", "char*");
  preferences.putString("String", String("String"));

  Serial.println(preferences.getChar("char"));
  Serial.println(preferences.getUChar("uchar"));
  Serial.println(preferences.getShort("short"));
  Serial.println(preferences.getUShort("ushort"));
  Serial.println(preferences.getInt("int"));
  Serial.println(preferences.getUInt("uint"));
  Serial.println(preferences.getLong("long"));
  Serial.println(preferences.getULong("ulong"));
  Serial.println((long int)preferences.getLong64("int64_t"));
  Serial.println((unsigned long int)preferences.getULong64("uint64_t"));

  Serial.println(preferences.getFloat("float"));
  Serial.println(preferences.getDouble("double"));

  Serial.println(preferences.getBool("bool"));

  Serial.println(preferences.getString("char*", ""));
  Serial.println(preferences.getString("String", String()));

  // Close the Preferences
  preferences.end();
}

void loop() {}

Test output:

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0x00
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0008,len:8
load:0x3fff0010,len:1760
load:0x40078000,len:6668
load:0x40080000,len:252
entry 0x40080034

-8
8
-16
16
-32
32
-32
32
-64
64
12.34
12.34
1
char*
String

* Renaming all set* functions to put
* Added functions for float, double and bool
* added type to put* function names
* for (u)int64_t used functions name with *(U)Long64
* added functions for long and unsigned long (same like int a unsigned int)
@me-no-dev me-no-dev merged commit f9ba8e9 into espressif:master Feb 11, 2017
@arcao arcao deleted the feature-preferences branch February 12, 2017 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants