Skip to content

Commit 8f43672

Browse files
committed
add state value for ascii encoding offset in case it is needed
1 parent be84144 commit 8f43672

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

cpp/arduino/PinHistory.h

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,13 @@ class PinHistory {
5858
}
5959

6060
public:
61-
PinHistory() {}
61+
unsigned int asciiEncodingOffsetIn;
62+
unsigned int asciiEncodingOffsetOut;
63+
64+
PinHistory() {
65+
asciiEncodingOffsetIn = 0; // default is sensible
66+
asciiEncodingOffsetOut = 1; // default is sensible
67+
}
6268

6369
void reset(T val) {
6470
clear();
@@ -108,11 +114,19 @@ class PinHistory {
108114

109115
// convert the queue of incoming data to a string as if it was Serial comms
110116
// start from offset, consider endianness
111-
String incomingToAscii (unsigned int offset, bool bigEndian) const { return q2a(qIn, offset, bigEndian); }
117+
String incomingToAscii(unsigned int offset, bool bigEndian) const { return q2a(qIn, offset, bigEndian); }
118+
119+
// convert the queue of incoming data to a string as if it was Serial comms
120+
// start from offset, consider endianness
121+
String incomingToAscii(bool bigEndian) const { return incomingToAscii(asciiEncodingOffsetIn, bigEndian); }
122+
123+
// convert the pin history to a string as if it was Serial comms
124+
// start from offset, consider endianness
125+
String toAscii(unsigned int offset, bool bigEndian) const { return q2a(qOut, offset, bigEndian); }
112126

113127
// convert the pin history to a string as if it was Serial comms
114128
// start from offset, consider endianness
115-
String toAscii (unsigned int offset, bool bigEndian) const { return q2a(qOut, offset, bigEndian); }
129+
String toAscii(bool bigEndian) const { return toAscii(asciiEncodingOffsetOut, bigEndian); }
116130

117131
// copy elements to an array, up to a given length
118132
// return the number of elements moved

0 commit comments

Comments
 (0)