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 5849d13

Browse files
RGBHistogram
1 parent 594cfa9 commit 5849d13

File tree

10 files changed

+420
-15
lines changed

10 files changed

+420
-15
lines changed

‎.DS_Store

0 Bytes
Binary file not shown.

‎.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ yarn-error.log
99
model.h
1010
tensorflow
1111
.idea/
12-
examples/.idea/
12+
examples/.idea/
13+
examples/Vision/Processing/RGBHistogramExample/main.cpp
14+
examples/Vision/Processing/RGBHistogramExample/a.out

‎EloquentArduino.h

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"type": "git",
77
"url": "https://github.com/eloquentarduino/EloquentArduino"
88
},
9-
"version": "1.1.8",
9+
"version": "1.1.10",
1010
"authors": {
1111
"name": "Simone Salerno",
1212
"url": "https://github.com/eloquentarduino"

‎library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=EloquentArduino
2-
version=1.1.8
2+
version=1.1.10
33
author=Simone Salerno <eloquentarduino@gmail.com>
44
maintainer=Simone Salerno <eloquentarduino@gmail.com>
55
sentence=An eloquent interface to common Arduino patterns, data structures and algorithms

‎src/.DS_Store

6 KB
Binary file not shown.

‎src/eloquentarduino/.DS_Store

6 KB
Binary file not shown.

‎src/eloquentarduino/modules/DS3231.h

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#pragma once
2+
3+
#include <RTClibExtended.h>
4+
5+
6+
namespace Eloquent {
7+
8+
/**
9+
* Utility wrapper around RTC_DS3231
10+
*/
11+
class DS3231 : public RTC_DS3231 {
12+
public:
13+
/**
14+
*
15+
*/
16+
void begin() {
17+
RTC_DS3231::begin();
18+
read();
19+
}
20+
21+
/**
22+
*
23+
*/
24+
void read() {
25+
current = now();
26+
27+
if (current.year() <= 2000 || current.year() > 2050) {
28+
RTC_DS3231::adjust(DateTime(__DATE__, __TIME__));
29+
current = now();
30+
}
31+
}
32+
33+
/**
34+
*
35+
* @param dt
36+
*/
37+
void adjust(const DateTime &dt) {
38+
RTC_DS3231::adjust(dt);
39+
read();
40+
}
41+
42+
/**
43+
*
44+
* @return
45+
*/
46+
String timestamp() {
47+
return String(current.unixtime());
48+
}
49+
50+
/**
51+
*
52+
* @return
53+
*/
54+
String date() {
55+
return pad(current.year()) + '-' + pad(current.month()) + '-' + pad(current.day());
56+
}
57+
58+
/**
59+
*
60+
* @return
61+
*/
62+
String time() {
63+
return pad(current.hour()) + ':' + pad(current.minute()) + ':' + pad(current.second());
64+
}
65+
66+
/**
67+
*
68+
* @return
69+
*/
70+
String datetime() {
71+
return date() + " " + time();
72+
}
73+
74+
private:
75+
DateTime current;
76+
77+
String pad(int n) {
78+
return String(n < 10 ? "0" : "") + String(n);
79+
}
80+
};
81+
82+
83+
DS3231 ds3231;
84+
}

‎src/eloquentarduino/modules/Wisol.h

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
#pragma once
2+
3+
#include <Arduino.h>
4+
5+
6+
namespace Eloquent {
7+
namespace Modules {
8+
9+
/**
10+
* Use Sigfox module with ease
11+
*/
12+
class Wisol {
13+
14+
public:
15+
static const int SOFTWARE_RESET = 0;
16+
static const int SLEEP = 1;
17+
static const int DEEP_SLEEP = 2;
18+
19+
/**
20+
* Construct Wisol from Stream (both Software or Hardware)
21+
*/
22+
Wisol(Stream *stream) {
23+
_stream = stream;
24+
}
25+
26+
/**
27+
* Check if module is connected
28+
*/
29+
bool available() {
30+
return getID().length() >= 6;
31+
}
32+
33+
/**
34+
* Test for connection (with retries)
35+
* @param retries
36+
* @param interval
37+
* @return
38+
*/
39+
bool ping(uint8_t retries = 3, uint16_t interval = 1000) {
40+
if (retries == 0)
41+
return false;
42+
43+
if (available())
44+
return true;
45+
46+
delay(interval);
47+
48+
return ping(retries - 1);
49+
}
50+
51+
/**
52+
* Dump module info (ID and PAC)
53+
*/
54+
String dumpInfo() {
55+
return String("ID :\t") + getID() + "\r\nPAC:\t" + getPAC();
56+
}
57+
58+
/**
59+
*
60+
*/
61+
void reset() {
62+
cmd("AT$P=0\r");
63+
}
64+
65+
/**
66+
*
67+
*/
68+
bool wakeup() {
69+
_stream->print('\n');
70+
71+
return cmd("AT").indexOf("OK") >= 0;
72+
}
73+
74+
/**
75+
*
76+
*/
77+
String getID() {
78+
return cmd("AT$I=10\r");
79+
}
80+
81+
/**
82+
*
83+
*/
84+
String getPAC() {
85+
return cmd("AT$I=11\r");
86+
}
87+
88+
/**
89+
*
90+
*/
91+
uint16_t getTemp() {
92+
String temp = cmd("AT$T?\r");
93+
94+
return temp.toInt();
95+
}
96+
97+
/**
98+
*
99+
*/
100+
String getVoltages() {
101+
String temp = cmd("AT$V?\r");
102+
103+
return temp;
104+
}
105+
106+
/**
107+
*
108+
*/
109+
bool setPowerMode(uint8_t mode) {
110+
return set("AT$P", mode);
111+
}
112+
113+
/**
114+
*
115+
*/
116+
bool setOutputPower(uint8_t power) {
117+
return set("ATS302", power);
118+
}
119+
120+
/**
121+
*
122+
*/
123+
bool enableSoftwareResetMode() {
124+
return setPowerMode(SOFTWARE_RESET);
125+
}
126+
127+
/**
128+
*
129+
*/
130+
bool enableSleepMode() {
131+
return setPowerMode(SLEEP);
132+
}
133+
134+
/**
135+
*
136+
*/
137+
bool enableDeepSleepMode() {
138+
return setPowerMode(DEEP_SLEEP);
139+
}
140+
141+
/**
142+
* Send command and get response
143+
*/
144+
String cmd(String cmd) {
145+
_stream->print(cmd);
146+
147+
return read();
148+
}
149+
150+
/**
151+
* Get response
152+
*/
153+
String read(uint16_t timeout = 2000) {
154+
uint32_t start = millis();
155+
String data = "";
156+
157+
if (timeout == 0)
158+
timeout = 2000;
159+
160+
while (millis() - start <= timeout && !_stream->available())
161+
delay(10);
162+
163+
while (millis() - start <= timeout && _stream->available()) {
164+
data += (char) _stream->read();
165+
}
166+
167+
data.trim();
168+
169+
return data;
170+
}
171+
172+
/**
173+
*
174+
* @param byte
175+
*/
176+
void printByte(uint8_t byte) {
177+
if (byte < 16)
178+
_stream->print(0);
179+
_stream->print(byte, HEX);
180+
}
181+
182+
/**
183+
* Send data.
184+
*/
185+
void sendNoAck(const void *data, uint8_t size, bool ack = false) {
186+
uint8_t *bytes = (uint8_t *) data;
187+
188+
_stream->print("AT$SF=");
189+
190+
for (uint8_t i = 0; i < size; ++i)
191+
printByte(bytes[i]);
192+
193+
if (ack)
194+
_stream->print(",1");
195+
196+
_stream->print("\r");
197+
}
198+
199+
bool send(const void *data, uint8_t size, bool ack = false) {
200+
sendNoAck(data, size, ack);
201+
202+
return read(30000).indexOf("OK") >= 0;
203+
}
204+
205+
206+
protected:
207+
Stream *_stream;
208+
209+
210+
/**
211+
* Set key=value
212+
*/
213+
bool set(const char *key, uint8_t mode) {
214+
_stream->print(key);
215+
_stream->print('=');
216+
_stream->print(mode);
217+
_stream->print('\r');
218+
219+
return this->read(3000) == "OK";
220+
}
221+
};
222+
}
223+
}

0 commit comments

Comments
(0)

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