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

Sign up
Appearance settings

Commit b5e8c9d

Browse files
starting migration
1 parent 4cd08fd commit b5e8c9d

File tree

3 files changed

+136
-0
lines changed

3 files changed

+136
-0
lines changed

‎src/EloquentArduino.h

Whitespace-only changes.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#pragma once
2+
3+
4+
namespace eloquent {
5+
namespace data {
6+
7+
template<typename T>
8+
class VariableWatcher {
9+
public:
10+
11+
/**
12+
* Update current value
13+
* @param current
14+
*/
15+
void update(T current) {
16+
_old = _current;
17+
_current = current;
18+
}
19+
20+
/**
21+
* Test if value changed
22+
* @return
23+
*/
24+
bool changed() {
25+
return _current != _old;
26+
}
27+
28+
protected:
29+
T _old;
30+
T _current;
31+
};
32+
}
33+
}

‎src/eloquentarduino/io/print.h

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#pragma once
2+
3+
#if defined(Stream_h)
4+
5+
namespace eloquent {
6+
namespace io {
7+
8+
9+
//#include "black_magic.h"
10+
11+
//#define serialprint(...) EVAL(MAP(Serial.print, __VA_ARGS__))
12+
13+
//#define _FCSV(f, x) f.print(x); f.print('\t');
14+
//#define fcsv(f, ...) EVAL(MAP(Serial.print, __VA_ARGS__)) f.print('\n');
15+
//#define fcsv(f, ...) EVAL(MAP_WITH_ARG(_FCSV, f, __VA_ARGS__)) f.print('\n');
16+
//#define csv(...) fcsv(Serial, __VA_ARGS__);
17+
18+
19+
/**
20+
* Stop condition
21+
* @param stream
22+
*/
23+
void fprint_all(Stream* stream) {}
24+
25+
/**
26+
* @tparam T
27+
* @tparam Args
28+
* @param stream
29+
* @param first
30+
* @param args
31+
*/
32+
template<typename T, typename... Args>
33+
void fprint_all(Stream* stream, T first, Args... args) {
34+
stream->print(first);
35+
fprint_all(stream, args...);
36+
}
37+
38+
/**
39+
* @tparam Args
40+
* @param args
41+
*/
42+
template<typename... Args>
43+
void print_all(Args... args) {
44+
fprint_all(&Serial, args...);
45+
}
46+
47+
48+
/**
49+
* Stop condition
50+
* @param stream
51+
*/
52+
void printf_csv(Stream* stream) {
53+
stream->print('\n');
54+
}
55+
56+
/**
57+
*
58+
* @tparam T
59+
* @tparam Args
60+
* @param stream
61+
* @param first
62+
* @param args
63+
*/
64+
template<typename T, typename... Args>
65+
void printf_csv(Stream* stream, T first, Args... args) {
66+
stream->print(first);
67+
stream->print('\t');
68+
printf_csv(stream, args...);
69+
}
70+
71+
/**
72+
*
73+
* @tparam Args
74+
* @param args
75+
*/
76+
template<typename... Args>
77+
void print_csv(Args... args) { printf_csv(&Serial, args...); }
78+
79+
80+
/**
81+
*
82+
*/
83+
template<typename T>
84+
void fprint_array(Stream *stream, T *array, uint16_t length, char separator=',') {
85+
for (uint16_t i = 0; i < length; i++) {
86+
stream->print(array[i]);
87+
stream->print(i == length - 1 ? '\n' : separator);
88+
}
89+
}
90+
91+
92+
/**
93+
*
94+
*/
95+
template<typename T>
96+
void print_array(T *array, uint16_t length, char separator=',') {
97+
fprint_array(&Serial, array, length, separator);
98+
}
99+
100+
}
101+
}
102+
103+
#endif

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /