Skip to content

Commit 5ea52e7

Browse files
author
mikee47
committed
Update documentation
1 parent d962ce3 commit 5ea52e7

File tree

4 files changed

+20
-26
lines changed

4 files changed

+20
-26
lines changed

array.rst

+1-17
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,9 @@ Supports arrays of simple types, such as char, int, double, or POD structures (i
1515
DEFINE_FSTR_ARRAY(myDoubleArray, double,
1616
PI, 53.0, 100, 1e8, 47
1717
);
18-
Serial.print("My double array: ");
19-
myDoubleArray.printTo(Serial);
20-
Serial.println();
18+
Serial << F("My double array: ") << myDoubleArray << endl;
2119

2220

23-
.. note::
24-
25-
Objects do not inherit from Printable because it is a virtual base class.
26-
27-
Therefore, statements like ``Serial.println(myDoubleArray)`` are not supported.
28-
29-
This also avoids ambiguity between implicit WString conversions.
30-
31-
There are some Print helper functions in the library you can use::
32-
33-
FSTR::println(Serial, myDoubleArray);
34-
35-
These are templated so will handle both simple data types and Objects.
36-
3721
You can share Arrays between translation units by declaring it in a header::
3822

3923
DECLARE_FSTR_ARRAY(table);

map.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ We can now do this::
6464
{
6565
auto value = intmap[key];
6666
if(value) {
67-
Serial.printf("Found '%u' in map, containing %u chars\n", value.key(), value.content().length());
68-
Serial.println(value.printer());
67+
Serial << _F("Found '") << value.key() << _F("' in map, containing ") << value.content.length() << _F(" chars") << endl;
68+
Serial << value << endl;
6969
} else {
70-
Serial.printf("Couldn't find '%u' in map\n", key);
70+
Serial << _F("Couldn't find '") << key << _F("'' in map") << endl;
7171
}
7272
}
7373

@@ -97,11 +97,11 @@ We can now do this::
9797
auto& value = fileMap[fileName];
9898
if(value) {
9999
// Found
100-
Serial.printf("Found '%s' in fileMap\n", String(value.key()).c_str());
100+
Serial << _F("Found '") << value.key() << _F("' in fileMap") << endl;
101101
auto stream = new FlashMemoryStream(value);
102102
response.sendDataStream(stream, ContentType::fromFullFileName(fileName));
103103
} else {
104-
Serial.printf("File '%s' not found\n", fileName.c_str());
104+
Serial << _F("File '") << fileName << _F("' not found") << endl;
105105
}
106106
}
107107

string.rst

+13-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Within a function::
2828
DEFINE_FSTR_LOCAL(myFlashString, "This is my flash string");
2929

3030
Serial.println(myFlashString);
31-
Serial.printf("myFlashString has %u chars and occupies %u bytes\n", myFlashString.length(), myFlashString.size());
31+
Serial << F("myFlashString has ") << myFlashString.length() << F(" chars and occupies ") << myFlashString.size() << F(" bytes") << endl;
3232

3333
To use Strings across translation units, we do this in the header::
3434

@@ -41,6 +41,8 @@ And in a source file::
4141
You can generally use a Flash String anywhere you can use a regular Wiring String as it has
4242
an implicit *::String()* operator. Note that ``WString`` is used within the library for disambiguation.
4343

44+
See also :cpp:class:`CStringArray`.
45+
4446

4547
Inline Strings
4648
--------------
@@ -73,8 +75,17 @@ This is equivalent to::
7375
FS("A Flash String").printTo(Serial);
7476
Serial.println();
7577

76-
:cpp:func:`FSTR::String::printTo` uses no heap and imposes no restriction on the string length.
78+
.. note::
79+
80+
Sming contains general streaming support via :cpp:class:`Print`, so FlashString objects can
81+
be printed like this::
7782

83+
Serial.println(myFlashString);
84+
Serial << myFlashString << endl;
85+
86+
This is implemented via non-virtual `printTo` overrides.
87+
88+
:cpp:func:`FSTR::String::printTo` uses no heap and imposes no restriction on the string length.
7889

7990

8091
Nested Inline Strings

table.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ Each row is a fixed size. The :cpp:class:`FSTR::TableRow` class template is prov
3333
{0.1, 0.2, 0.3},
3434
{0.6, 0.7, 0.8}
3535
);
36-
table.printTo(Serial);
37-
table.println();
36+
Serial.println(table);
3837

3938

4039
If you want to create a table with rows of different sizes or types, use a :doc:`Vector <vector>`.

0 commit comments

Comments
 (0)