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 49f6410

Browse files
refactor esp32 cam
1 parent 692de44 commit 49f6410

File tree

34 files changed

+2117
-112
lines changed

34 files changed

+2117
-112
lines changed
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
#include "eloquent.h"
22
#include "eloquent/networking/wifi.h"
33
#include "eloquent/vision/camera/esp32/webserver.h"
4-
// replace according to your own camera
5-
#include "eloquent/vision/camera/esp32/m5wide/jpeg/qqvga.h"
4+
5+
// replace 'm5wide' with your own model
6+
// possible values are 'aithinker', 'eye', 'm5stack', 'm5wide', 'wrover'
7+
#include "eloquent/vision/camera/m5wide.h"
68

79

810

911
void setup() {
1012
Serial.begin(115200);
13+
delay(2000);
14+
15+
camera.jpeg();
16+
// replace with desired resolution
17+
// possible values are qqvga, qvga, vga
18+
camera.qqvga();
1119

20+
// replace with your WiFi credentials
1221
while (!wifi.connectTo("Abc", "12345678"))
1322
Serial.println("Cannot connect to WiFi");
1423

1524
while (!camera.begin())
1625
Serial.println("Cannot connect to camera");
1726

18-
Serial.println("WiFi connected");
19-
Serial.println("Camera connected");
20-
2127
webServer.start();
2228
Serial.print("Camera web server started at http://");
2329
Serial.println(WiFi.localIP());
2430
}
2531

2632
void loop() {
27-
33+
// do nothing
2834
}

‎src/eloquent/math.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,5 +197,18 @@ namespace eloquent {
197197
float mapConstrain(float x, float l, float h, float m, float M) {
198198
return eloquent::math::map(eloquent::math::constrainRange(x, l, h), l, h, m, M);
199199
}
200+
201+
/**
202+
* Convert byte to hex string
203+
* @param b
204+
* @param str
205+
*/
206+
void byteToHex(uint8_t b, char *str) {
207+
const char alphabet[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
208+
209+
str[0] = alphabet[b >> 4];
210+
str[1] = alphabet[b & 0b1111];
211+
str[2] = '0円';
212+
}
200213
}
201214
}

‎src/eloquent/print.h

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,45 @@ namespace eloquent {
1212

1313
/**
1414
*
15-
* @tparam Stream
15+
* @tparam Printer
1616
* @param stream
1717
* @param fmt
1818
* @param ...
1919
*/
20-
template<typename Stream>
21-
void printf(Stream &stream, char *fmt, ...) {
22-
char buf[128];
20+
template<classPrinter>
21+
void printf(Printer &printer, char *fmt, ...) {
22+
char buf[256];
2323

2424
va_list args;
2525
va_start (args, fmt );
26-
vsnprintf(buf, 128, fmt, args);
26+
vsnprintf(buf, 256, fmt, args);
2727
va_end (args);
28-
stream.print(buf);
28+
printer.print(buf);
2929
}
3030

3131
/**
32-
*
33-
* @tparam Stream
34-
* @tparam bufferSize
35-
* @param stream
36-
* @param fmt
37-
* @param ...
32+
* Stop condition for print_all
33+
* @tparam Printer
34+
* @param printer
3835
*/
39-
template<typename Stream, size_t bufferSize>
40-
void printf(Stream &stream, char *fmt, ...) {
41-
char buf[bufferSize];
36+
template<class Printer>
37+
void print_all(Printer& printer) {
4238

43-
va_list args;
44-
va_start (args, fmt );
45-
vsnprintf(buf, bufferSize, fmt, args);
46-
va_end (args);
47-
stream.print(buf);
39+
}
40+
41+
/**
42+
* Print all arguments
43+
* @tparam Printer
44+
* @tparam T
45+
* @tparam Args
46+
* @param stream
47+
* @param first
48+
* @param args
49+
*/
50+
template<class Printer, typename T, typename... Args>
51+
void print_all(Printer& printer, T first, Args... args) {
52+
printer.print(first);
53+
print_all(printer, args...);
4854
}
4955
}
5056
}

‎src/eloquent/tinyml/voting/quorum.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace Eloquent {
1919
/**
2020
* Constructor
2121
*/
22-
Quorum() {
22+
Quorum() : _vote(-1) {
2323
clear();
2424
atLeastMajority();
2525
}
@@ -65,17 +65,26 @@ namespace Eloquent {
6565
quorum -= 1;
6666

6767
if (quorum == 0)
68-
return vote;
68+
return (_vote = vote);
6969
}
7070
}
7171

72-
return -1;
72+
return (_vote = -1);
73+
}
74+
75+
/**
76+
* Test if last vote was stable
77+
* @return
78+
*/
79+
bool isStable() {
80+
return _vote >= 0;
7381
}
7482

7583
protected:
7684
int8_t _votes[votes];
7785
uint16_t _i;
7886
uint16_t _quorum;
87+
int8_t _vote;
7988
};
8089
}
8190
}

‎src/eloquent/vision/.DS_Store

6 KB
Binary file not shown.

‎src/eloquent/vision/camera/.DS_Store

6 KB
Binary file not shown.

‎src/eloquent/vision/camera/aithinker.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// Created by Simone on 06/07/2022.
3+
//
4+
5+
#pragma once
6+
7+
#define PWDN_GPIO_NUM 32
8+
#define RESET_GPIO_NUM -1
9+
#define XCLK_GPIO_NUM 0
10+
#define SIOD_GPIO_NUM 26
11+
#define SIOC_GPIO_NUM 27
12+
13+
#define Y9_GPIO_NUM 35
14+
#define Y8_GPIO_NUM 34
15+
#define Y7_GPIO_NUM 39
16+
#define Y6_GPIO_NUM 36
17+
#define Y5_GPIO_NUM 21
18+
#define Y4_GPIO_NUM 19
19+
#define Y3_GPIO_NUM 18
20+
#define Y2_GPIO_NUM 5
21+
#define VSYNC_GPIO_NUM 25
22+
#define HREF_GPIO_NUM 23
23+
#define PCLK_GPIO_NUM 22
24+
25+
#include "./esp32.h"

‎src/eloquent/vision/camera/decoders.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//
2+
// Created by Simone on 06/07/2022.
3+
//
4+
5+
#pragma once
6+
7+
#include "./decoders/gray.h"

0 commit comments

Comments
(0)

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