Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a2c8920

Browse filesBrowse files
authored
Updated preferences and FAQ documentation (added SPIFFS) (espressif#8150)
* Updated preferences.rst * Added into FAQ info about SPIFFS failed mount
1 parent 6075151 commit a2c8920
Copy full SHA for a2c8920

File tree

Expand file treeCollapse file tree

2 files changed

+48
-18
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+48
-18
lines changed

‎docs/source/faq.rst

Copy file name to clipboardExpand all lines: docs/source/faq.rst
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,20 @@ How to compile libs with different debug level?
1515
-----------------------------------------------
1616

1717
The short answer is ``esp32-arduino-lib-builder/configs/defconfig.common:44``. A guide explaining the process can be found here <guides/core_debug>
18+
19+
SPIFFS mount failed
20+
-------------------
21+
When you come across and error like this:
22+
23+
.. code-block:: shell
24+
25+
E (588) SPIFFS: mount failed, -10025
26+
[E][SPIFFS.cpp:47] begin(): Mounting SPIFFS failed! Error: -1
27+
28+
Try enforcing format on fail in your code by adding ``true`` in the ``begin`` method such as this:
29+
30+
.. code-block:: c++
31+
32+
SPIFFS.begin(true);
33+
34+
See the method prototype for reference: ``bool begin(bool formatOnFail=false, const char * basePath="/spiffs", uint8_t maxOpenFiles=10, const char * partitionLabel=NULL);``

‎docs/source/tutorials/preferences.rst

Copy file name to clipboardExpand all lines: docs/source/tutorials/preferences.rst
+31-18Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,9 @@ Like so:
233233

234234
.. code-block:: arduino
235235
236-
String myString = myPreferences.getString("myStringKey");
236+
float myFloat = myPreferences.getFloat("pi");
237237
238-
This will retrieve the String value from the namespace key ``"myStringKey"`` and assign it to the String type variable ``myString``.
238+
This will retrieve the float value from the namespace key ``"pi"`` and assign it to the float type variable ``myFloat``.
239239

240240

241241
Summary
@@ -277,9 +277,10 @@ When started, the system has no way of knowing which of the above conditions is
277277
// not the complete setup(), but in setup(), include this...
278278
279279
stcPrefs.begin("STCPrefs", RO_MODE); // Open our namespace (or create it
280-
// if it doesn't exist) in in RO mode.
280+
// if it doesn't exist) in RO mode.
281281
282-
bool tpInit = stcPrefs.isKey("nvsInit"); // Test for the existence of the "already initialized" key.
282+
bool tpInit = stcPrefs.isKey("nvsInit"); // Test for the existence
283+
// of the "already initialized" key.
283284
284285
if (tpInit == false) {
285286
// If tpInit is 'false', the key "nvsInit" does not yet exist therefore this
@@ -289,13 +290,15 @@ When started, the system has no way of knowing which of the above conditions is
289290
290291
291292
// The .begin() method created the "STCPrefs" namespace and since this is our
292-
// first-time run we will create our keys and store the initial "factory default" values.
293+
// first-time run we will create
294+
// our keys and store the initial "factory default" values.
293295
stcPrefs.putUChar("curBright", 10);
294296
stcPrefs.putString("talChan", "one");
295297
stcPrefs.putLong("talMax", -220226);
296298
stcPrefs.putBool("ctMde", true);
297299
298-
stcPrefs.putBool("nvsInit", true); // Create the "already initialized" key and store a value.
300+
stcPrefs.putBool("nvsInit", true); // Create the "already initialized"
301+
// key and store a value.
299302
300303
// The "factory defaults" are created and stored so...
301304
stcPrefs.end(); // Close the namespace in RW mode and...
@@ -456,10 +459,12 @@ This is best explained with an example. Here the ``Bytes`` methods are used to s
456459
Serial.begin(115200);
457460
delay(250);
458461
459-
mySketchPrefs.begin("myPrefs", RW_MODE); // open (or create) the namespace "myPrefs" in RW mode
462+
mySketchPrefs.begin("myPrefs", RW_MODE); // open (or create) the namespace
463+
// "myPrefs" in RW mode
460464
mySketchPrefs.clear(); // delete any previous keys in this namespace
461465
462-
// Create an array of test values. We're using hex numbers throughout to better show how the bytes move around.
466+
// Create an array of test values. We're using hex numbers
467+
// throughout to better show how the bytes move around.
463468
int16_t myArray[] = { 0x1112, 0x2122, 0x3132, 0x4142, 0x5152, 0x6162, 0x7172 };
464469
465470
Serial.println("Printing myArray...");
@@ -468,22 +473,28 @@ This is best explained with an example. Here the ``Bytes`` methods are used to s
468473
}
469474
Serial.println("\r\n");
470475
471-
// In the next statement, the second sizeof() needs to match the data type of the elements of myArray
472-
Serial.print("The number of elements in myArray is: "); Serial.println( sizeof(myArray) / sizeof(int16_t) );
473-
Serial.print("But the size of myArray in bytes is: "); Serial.println( sizeof(myArray) );
476+
// In the next statement, the second sizeof() needs
477+
// to match the data type of the elements of myArray
478+
Serial.print("The number of elements in myArray is: ");
479+
Serial.println( sizeof(myArray) / sizeof(int16_t) );
480+
Serial.print("But the size of myArray in bytes is: ");
481+
Serial.println( sizeof(myArray) );
474482
Serial.println("");
475483
476-
Serial.println("Storing myArray into the Preferences namespace \"myPrefs\" against the key \"myPrefsBytes\".");
484+
Serial.println(
485+
"Storing myArray into the Preferences namespace \"myPrefs\" against the key \"myPrefsBytes\".");
477486
// Note: in the next statement, to store the entire array, we must use the
478487
// size of the arrray in bytes, not the number of elements in the array.
479488
mySketchPrefs.putBytes( "myPrefsBytes", myArray, sizeof(myArray) );
480-
Serial.print("The size of \"myPrefsBytes\" is (in bytes): "); Serial.println( mySketchPrefs.getBytesLength("myPrefsBytes") );
489+
Serial.print("The size of \"myPrefsBytes\" is (in bytes): ");
490+
Serial.println( mySketchPrefs.getBytesLength("myPrefsBytes") );
481491
Serial.println("");
482492
483-
int16_t myIntBuffer[20] = {}; // No magic about 20. Just making a buffer (array) big enough.
493+
int16_t myIntBuffer[20] = {}; // No magic about 20. Just making a buffer (array) big enough.
484494
Serial.println("Retrieving the value of myPrefsBytes into myIntBuffer.");
485495
Serial.println(" - Note the data type of myIntBuffer matches that of myArray");
486-
mySketchPrefs.getBytes( "myPrefsBytes", myIntBuffer, mySketchPrefs.getBytesLength("myPrefsBytes") );
496+
mySketchPrefs.getBytes("myPrefsBytes", myIntBuffer,
497+
mySketchPrefs.getBytesLength("myPrefsBytes"));
487498
488499
Serial.println("Printing myIntBuffer...");
489500
// In the next statement, sizeof() needs to match the data type of the elements of myArray
@@ -492,9 +503,11 @@ This is best explained with an example. Here the ``Bytes`` methods are used to s
492503
}
493504
Serial.println("\r\n");
494505
495-
Serial.println("We can see how the data from myArray is actually stored in the namespace as follows.");
496-
uint8_t myByteBuffer[40] = {}; // No magic about 40. Just making a buffer (array) big enough.
497-
mySketchPrefs.getBytes( "myPrefsBytes", myByteBuffer, mySketchPrefs.getBytesLength("myPrefsBytes") );
506+
Serial.println(
507+
"We can see how the data from myArray is actually stored in the namespace as follows.");
508+
uint8_t myByteBuffer[40] = {}; // No magic about 40. Just making a buffer (array) big enough.
509+
mySketchPrefs.getBytes("myPrefsBytes", myByteBuffer,
510+
mySketchPrefs.getBytesLength("myPrefsBytes"));
498511
499512
Serial.println("Printing myByteBuffer...");
500513
for (int i = 0; i < mySketchPrefs.getBytesLength("myPrefsBytes"); i++) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.