Compare commits
6 Commits
12575174ec
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| d49cdb8a0e | |||
| bbddb40147 | |||
| bb581cb18f | |||
| aa53b5aca1 | |||
| 77ee263d78 | |||
| 9a82880086 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -3,3 +3,7 @@
|
|||||||
.vscode/c_cpp_properties.json
|
.vscode/c_cpp_properties.json
|
||||||
.vscode/launch.json
|
.vscode/launch.json
|
||||||
.vscode/ipch
|
.vscode/ipch
|
||||||
|
src/.vscode/c_cpp_properties.json
|
||||||
|
.vscode/extensions.json
|
||||||
|
.vscode/extensions.json
|
||||||
|
platformio.ini
|
||||||
|
|||||||
14
.vscode/extensions.json
vendored
14
.vscode/extensions.json
vendored
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||||
// for the documentation about the extensions.json format
|
// for the documentation about the extensions.json format
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
"platformio.platformio-ide"
|
"platformio.platformio-ide"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +1,39 @@
|
|||||||
|
|
||||||
This directory is intended for project header files.
|
This directory is intended for project header files.
|
||||||
|
|
||||||
A header file is a file containing C declarations and macro definitions
|
A header file is a file containing C declarations and macro definitions
|
||||||
to be shared between several project source files. You request the use of a
|
to be shared between several project source files. You request the use of a
|
||||||
header file in your project source file (C, C++, etc) located in `src` folder
|
header file in your project source file (C, C++, etc) located in `src` folder
|
||||||
by including it, with the C preprocessing directive `#include'.
|
by including it, with the C preprocessing directive `#include'.
|
||||||
|
|
||||||
```src/main.c
|
```src/main.c
|
||||||
|
|
||||||
#include "header.h"
|
#include "header.h"
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Including a header file produces the same results as copying the header file
|
Including a header file produces the same results as copying the header file
|
||||||
into each source file that needs it. Such copying would be time-consuming
|
into each source file that needs it. Such copying would be time-consuming
|
||||||
and error-prone. With a header file, the related declarations appear
|
and error-prone. With a header file, the related declarations appear
|
||||||
in only one place. If they need to be changed, they can be changed in one
|
in only one place. If they need to be changed, they can be changed in one
|
||||||
place, and programs that include the header file will automatically use the
|
place, and programs that include the header file will automatically use the
|
||||||
new version when next recompiled. The header file eliminates the labor of
|
new version when next recompiled. The header file eliminates the labor of
|
||||||
finding and changing all the copies as well as the risk that a failure to
|
finding and changing all the copies as well as the risk that a failure to
|
||||||
find one copy will result in inconsistencies within a program.
|
find one copy will result in inconsistencies within a program.
|
||||||
|
|
||||||
In C, the usual convention is to give header files names that end with `.h'.
|
In C, the usual convention is to give header files names that end with `.h'.
|
||||||
It is most portable to use only letters, digits, dashes, and underscores in
|
It is most portable to use only letters, digits, dashes, and underscores in
|
||||||
header file names, and at most one dot.
|
header file names, and at most one dot.
|
||||||
|
|
||||||
Read more about using header files in official GCC documentation:
|
Read more about using header files in official GCC documentation:
|
||||||
|
|
||||||
* Include Syntax
|
* Include Syntax
|
||||||
* Include Operation
|
* Include Operation
|
||||||
* Once-Only Headers
|
* Once-Only Headers
|
||||||
* Computed Includes
|
* Computed Includes
|
||||||
|
|
||||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
||||||
|
|||||||
92
lib/README
92
lib/README
@@ -1,46 +1,46 @@
|
|||||||
|
|
||||||
This directory is intended for project specific (private) libraries.
|
This directory is intended for project specific (private) libraries.
|
||||||
PlatformIO will compile them to static libraries and link into executable file.
|
PlatformIO will compile them to static libraries and link into executable file.
|
||||||
|
|
||||||
The source code of each library should be placed in a an own separate directory
|
The source code of each library should be placed in a an own separate directory
|
||||||
("lib/your_library_name/[here are source files]").
|
("lib/your_library_name/[here are source files]").
|
||||||
|
|
||||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||||
|
|
||||||
|--lib
|
|--lib
|
||||||
| |
|
| |
|
||||||
| |--Bar
|
| |--Bar
|
||||||
| | |--docs
|
| | |--docs
|
||||||
| | |--examples
|
| | |--examples
|
||||||
| | |--src
|
| | |--src
|
||||||
| | |- Bar.c
|
| | |- Bar.c
|
||||||
| | |- Bar.h
|
| | |- Bar.h
|
||||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||||
| |
|
| |
|
||||||
| |--Foo
|
| |--Foo
|
||||||
| | |- Foo.c
|
| | |- Foo.c
|
||||||
| | |- Foo.h
|
| | |- Foo.h
|
||||||
| |
|
| |
|
||||||
| |- README --> THIS FILE
|
| |- README --> THIS FILE
|
||||||
|
|
|
|
||||||
|- platformio.ini
|
|- platformio.ini
|
||||||
|--src
|
|--src
|
||||||
|- main.c
|
|- main.c
|
||||||
|
|
||||||
and a contents of `src/main.c`:
|
and a contents of `src/main.c`:
|
||||||
```
|
```
|
||||||
#include <Foo.h>
|
#include <Foo.h>
|
||||||
#include <Bar.h>
|
#include <Bar.h>
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
PlatformIO Library Dependency Finder will find automatically dependent
|
PlatformIO Library Dependency Finder will find automatically dependent
|
||||||
libraries scanning project source files.
|
libraries scanning project source files.
|
||||||
|
|
||||||
More information about PlatformIO Library Dependency Finder
|
More information about PlatformIO Library Dependency Finder
|
||||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
- https://docs.platformio.org/page/librarymanager/ldf.html
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
; PlatformIO Project Configuration File
|
; PlatformIO Project Configuration File
|
||||||
;
|
;
|
||||||
; Build options: build flags, source filter
|
; Build options: build flags, source filter
|
||||||
; Upload options: custom upload port, speed and extra flags
|
; Upload options: custom upload port, speed and extra flags
|
||||||
; Library options: dependencies, extra library storages
|
; Library options: dependencies, extra library storages
|
||||||
; Advanced options: extra scripting
|
; Advanced options: extra scripting
|
||||||
;
|
;
|
||||||
; Please visit documentation for the other options and examples
|
; Please visit documentation for the other options and examples
|
||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[env:esp32cam]
|
[env:esp32cam]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
board = esp32cam
|
board = esp32cam
|
||||||
framework = arduino
|
framework = arduino
|
||||||
monitor_port = COM[13678]
|
monitor_port = /dev/ttyUSB0
|
||||||
monitor_speed = 115200
|
monitor_speed = 460800
|
||||||
lib_deps =
|
monitor_rts = 0
|
||||||
enviromonitor/BME280_Light@0.0.0-alpha+sha.600667f3a6
|
monitor_dtr = 0
|
||||||
|
lib_deps =
|
||||||
|
enviromonitor/BME280_Light@0.0.0-alpha+sha.600667f3a6
|
||||||
|
|||||||
50
read.sh
50
read.sh
@@ -1,50 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
host="172.16.1.254"
|
|
||||||
topic="esp32/strecha"
|
|
||||||
url="https://meranie.bh.ttx.sk/upload/"
|
|
||||||
|
|
||||||
while true
|
|
||||||
do
|
|
||||||
while true
|
|
||||||
do
|
|
||||||
echo "measure"
|
|
||||||
|
|
||||||
input=
|
|
||||||
while [[ $input = "" ]]; do
|
|
||||||
read input
|
|
||||||
done
|
|
||||||
read t h p <<< $input
|
|
||||||
|
|
||||||
IFS="="
|
|
||||||
read v k <<< $t
|
|
||||||
echo $k > /dev/tty
|
|
||||||
t=$k
|
|
||||||
|
|
||||||
read v k <<< $h
|
|
||||||
echo $k > /dev/tty
|
|
||||||
h=$k
|
|
||||||
|
|
||||||
read v k <<< $p
|
|
||||||
echo $k > /dev/tty
|
|
||||||
p=$k
|
|
||||||
|
|
||||||
unset IFS
|
|
||||||
|
|
||||||
break
|
|
||||||
done </dev/ttyUSB0 >/dev/ttyUSB0
|
|
||||||
|
|
||||||
echo mosquitio_pub -h $host -t $topic/temperature -m N:$t
|
|
||||||
echo mosquitio_pub -h $host -t $topic/humidity -m N:$h
|
|
||||||
echo mosquitio_pub -h $host -t $topic/pressure -m N:$p
|
|
||||||
|
|
||||||
echo "capture" > /dev/ttyUSB0
|
|
||||||
echo "rb" > /dev/ttyUSB0
|
|
||||||
rb --ymodem </dev/ttyUSB0 >/dev/ttyUSB0
|
|
||||||
|
|
||||||
echo "free" > /dev/ttyUSB0
|
|
||||||
|
|
||||||
curl -v -F filename=camera.jpg -F upload=@camera.jpg $url
|
|
||||||
rm camera.jpg
|
|
||||||
sleep 300
|
|
||||||
done
|
|
||||||
51
src/ascii.txt
Normal file
51
src/ascii.txt
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
## Font attributes ##
|
||||||
|
# off
|
||||||
|
off = '\x1b[0m' # off
|
||||||
|
default = '\x1b[39m' # default foreground
|
||||||
|
DEFAULT = '\x1b[49m' # default background
|
||||||
|
#
|
||||||
|
bd = '\x1b[1m' # bold
|
||||||
|
ft = '\x1b[2m' # faint
|
||||||
|
st = '\x1b[3m' # standout
|
||||||
|
ul = '\x1b[4m' # underlined
|
||||||
|
bk = '\x1b[5m' # blink
|
||||||
|
rv = '\x1b[7m' # reverse
|
||||||
|
hd = '\x1b[8m' # hidden
|
||||||
|
nost = '\x1b[23m' # no standout
|
||||||
|
noul = '\x1b[24m' # no underlined
|
||||||
|
nobk = '\x1b[25m' # no blink
|
||||||
|
norv = '\x1b[27m' # no reverse
|
||||||
|
# colors
|
||||||
|
black = '\x1b[30m'
|
||||||
|
BLACK = '\x1b[40m'
|
||||||
|
red = '\x1b[31m'
|
||||||
|
RED = '\x1b[41m'
|
||||||
|
green = '\x1b[32m'
|
||||||
|
GREEN = '\x1b[42m'
|
||||||
|
yellow = '\x1b[33m'
|
||||||
|
YELLOW = '\x1b[43m'
|
||||||
|
blue = '\x1b[34m'
|
||||||
|
BLUE = '\x1b[44m'
|
||||||
|
magenta = '\x1b[35m'
|
||||||
|
MAGENTA = '\x1b[45m'
|
||||||
|
cyan = '\x1b[36m'
|
||||||
|
CYAN = '\x1b[46m'
|
||||||
|
white = '\x1b[37m'
|
||||||
|
WHITE = '\x1b[47m'
|
||||||
|
# light colors
|
||||||
|
dgray = '\x1b[90m'
|
||||||
|
DGRAY = '\x1b[100m'
|
||||||
|
lred = '\x1b[91m'
|
||||||
|
LRED = '\x1b[101m'
|
||||||
|
lgreen = '\x1b[92m'
|
||||||
|
LGREEN = '\x1b[102m'
|
||||||
|
lyellow = '\x1b[93m'
|
||||||
|
LYELLOW = '\x1b[103m'
|
||||||
|
lblue = '\x1b[94m'
|
||||||
|
LBLUE = '\x1b[104m'
|
||||||
|
lmagenta = '\x1b[95m'
|
||||||
|
LMAGENTA = '\x1b[105m'
|
||||||
|
lcyan = '\x1b[96m'
|
||||||
|
LCYAN = '\x1b[106m'
|
||||||
|
lgray = '\x1b[97m'
|
||||||
|
LGRAY = '\x1b[107m'
|
||||||
496
src/main.cpp
496
src/main.cpp
@@ -1,215 +1,283 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <XModem.h>
|
#include <XModem.h>
|
||||||
#include "esp_camera.h"
|
#include "esp_camera.h"
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "soc/soc.h" // Disable brownour problems
|
#include "soc/soc.h" // Disable brownour problems
|
||||||
#include "soc/rtc_cntl_reg.h" // Disable brownour problems
|
#include "soc/rtc_cntl_reg.h" // Disable brownour problems
|
||||||
#include "driver/rtc_io.h"
|
#include "driver/rtc_io.h"
|
||||||
#include <EEPROM.h> // read and write from flash memory
|
#include <EEPROM.h> // read and write from flash memory
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <BME280_t.h> // import BME280 template library
|
#include <BME280_t.h> // import BME280 template library
|
||||||
|
|
||||||
char bufout[10];
|
char bufout[10];
|
||||||
BME280<> BMESensor;
|
BME280<> BMESensor;
|
||||||
|
|
||||||
// define the number of bytes you want to access
|
// define the number of bytes you want to access
|
||||||
#define EEPROM_SIZE 1
|
#define EEPROM_SIZE 1
|
||||||
|
|
||||||
// Pin definition for CAMERA_MODEL_AI_THINKER
|
// Pin definition for CAMERA_MODEL_AI_THINKER
|
||||||
#define PWDN_GPIO_NUM 32
|
#define PWDN_GPIO_NUM 32
|
||||||
#define RESET_GPIO_NUM -1
|
#define RESET_GPIO_NUM -1
|
||||||
#define XCLK_GPIO_NUM 0
|
#define XCLK_GPIO_NUM 0
|
||||||
#define SIOD_GPIO_NUM 26
|
#define SIOD_GPIO_NUM 26
|
||||||
#define SIOC_GPIO_NUM 27
|
#define SIOC_GPIO_NUM 27
|
||||||
|
|
||||||
#define Y9_GPIO_NUM 35
|
#define Y9_GPIO_NUM 35
|
||||||
#define Y8_GPIO_NUM 34
|
#define Y8_GPIO_NUM 34
|
||||||
#define Y7_GPIO_NUM 39
|
#define Y7_GPIO_NUM 39
|
||||||
#define Y6_GPIO_NUM 36
|
#define Y6_GPIO_NUM 36
|
||||||
#define Y5_GPIO_NUM 21
|
#define Y5_GPIO_NUM 21
|
||||||
#define Y4_GPIO_NUM 19
|
#define Y4_GPIO_NUM 19
|
||||||
#define Y3_GPIO_NUM 18
|
#define Y3_GPIO_NUM 18
|
||||||
#define Y2_GPIO_NUM 5
|
#define Y2_GPIO_NUM 5
|
||||||
#define VSYNC_GPIO_NUM 25
|
#define VSYNC_GPIO_NUM 25
|
||||||
#define HREF_GPIO_NUM 23
|
#define HREF_GPIO_NUM 23
|
||||||
#define PCLK_GPIO_NUM 22
|
#define PCLK_GPIO_NUM 22
|
||||||
|
|
||||||
int pictureNumber = 0;
|
int pictureNumber = 0;
|
||||||
camera_fb_t * fb = NULL;
|
camera_fb_t * fb = NULL;
|
||||||
XModem xmodem(&Serial, ModeYModem);
|
XModem xmodem(&Serial, ModeYModem);
|
||||||
|
|
||||||
typedef void (*action_func_t)(char *aLine);
|
typedef void (*action_func_t)(char *aLine);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char command[7+1]; // max 7 characters plus '\0' terminator
|
char command[7+1]; // max 7 characters plus '\0' terminator
|
||||||
action_func_t action;
|
action_func_t action;
|
||||||
} command_action_t;
|
} command_action_t;
|
||||||
|
|
||||||
|
|
||||||
void toLower(char *s) {
|
void toLower(char *s) {
|
||||||
while (*s) {
|
while (*s) {
|
||||||
if (isupper(*s)) {
|
if (isupper(*s)) {
|
||||||
*s += 0x20;
|
*s += 0x20;
|
||||||
}
|
}
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_commands(char *aLine);
|
void print_commands(char *aLine);
|
||||||
|
|
||||||
void reboot_esp32(char *aLine)
|
void reboot_esp32(char *aLine)
|
||||||
{
|
{
|
||||||
Serial.println("[OK] GOING TO REBOOT");
|
Serial.println("[OK] GOING TO REBOOT");
|
||||||
delay(1000);
|
delay(1000);
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
void recv_ymodem(char *aLine)
|
void set_speed(char *aLine)
|
||||||
{
|
{
|
||||||
xmodem.sendFile(fb->buf, fb->len, "camera.jpg");
|
char *speed = aLine + strlen(aLine) + 1;
|
||||||
}
|
Serial.updateBaudRate(atol(speed));
|
||||||
|
Serial.printf("[OK] SETTING SPEED %s",speed);
|
||||||
void capture_image(char *aLine)
|
}
|
||||||
{
|
|
||||||
fb = esp_camera_fb_get();
|
|
||||||
Serial.println("[OK] CAPTURED IMAGE");
|
void capture_image(char *aLine)
|
||||||
}
|
{
|
||||||
|
fb = esp_camera_fb_get();
|
||||||
void free_image(char *aLine)
|
Serial.println("[OK] CAPTURED IMAGE");
|
||||||
{
|
}
|
||||||
esp_camera_fb_return(fb);
|
|
||||||
Serial.println("[OK] FREE CAPTURED IMAGE");
|
void free_image(char *aLine)
|
||||||
}
|
{
|
||||||
|
esp_camera_fb_return(fb);
|
||||||
void print_measurement(char *aLine)
|
Serial.println("[OK] FREE CAPTURED IMAGE");
|
||||||
{
|
}
|
||||||
BMESensor.refresh(); // read current sensor dat
|
|
||||||
Serial.printf("temperature=%.2f humidity=%.2f pressure=%.2f\n",BMESensor.temperature,BMESensor.humidity,BMESensor.pressure / 100.0F);
|
void recv_ymodem(char *aLine)
|
||||||
return;
|
{
|
||||||
}
|
xmodem.sendFile(fb->buf, fb->len, "camera.jpg");
|
||||||
|
Serial.println("[OK] SEND IMAGE");
|
||||||
const command_action_t commands[] = {
|
free_image(aLine);
|
||||||
// Name of command user types, function that implements the command.
|
}
|
||||||
{"reboot", reboot_esp32},
|
|
||||||
{"capture", capture_image},
|
void print_measurement(char *aLine)
|
||||||
{"free", free_image},
|
{
|
||||||
{"measure", print_measurement},
|
BMESensor.refresh(); // read current sensor dat
|
||||||
{"rb", recv_ymodem},
|
Serial.printf("temperature=%.2f humidity=%.2f pressure=%.2f\n",BMESensor.temperature,BMESensor.humidity,BMESensor.pressure / 100.0F);
|
||||||
{"help", print_commands},
|
return;
|
||||||
{"?", print_commands},
|
}
|
||||||
};
|
|
||||||
|
void set_brightness(char *aLine)
|
||||||
void print_commands(char *aLine) {
|
{
|
||||||
Serial.print(commands[0].command);
|
char *str = aLine + strlen(aLine) + 1;
|
||||||
for (size_t i = 1; i < sizeof(commands)/sizeof(commands[0]); i++) {
|
sensor_t * s = esp_camera_sensor_get();
|
||||||
Serial.print(','); Serial.print(commands[i].command);
|
s->set_brightness(s, atol(str)); // -2 to 2
|
||||||
}
|
Serial.print("[OK] SETTING BRIGHTNESS ");
|
||||||
Serial.println();
|
Serial.println(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_saturation(char *aLine)
|
||||||
void execute(char *aLine) {
|
{
|
||||||
if (aLine == NULL || *aLine == '\0') return;
|
char *str = aLine + strlen(aLine) + 1;
|
||||||
char *cmd = strtok(aLine, " \t");
|
sensor_t * s = esp_camera_sensor_get();
|
||||||
if (cmd == NULL || *cmd == '\0') return;
|
s->set_saturation(s, atol(str)); // -2 to 2
|
||||||
toLower(cmd);
|
Serial.print("[OK] SETTING SATURATION ");
|
||||||
for (size_t i = 0; i < sizeof(commands)/sizeof(commands[0]); i++) {
|
Serial.println(str);;
|
||||||
if (strcmp(cmd, commands[i].command) == 0) {
|
}
|
||||||
commands[i].action(aLine);
|
|
||||||
return;
|
void set_contrast(char *aLine)
|
||||||
}
|
{
|
||||||
}
|
char *str = aLine + strlen(aLine) + 1;
|
||||||
Serial.println("command not found");
|
sensor_t * s = esp_camera_sensor_get();
|
||||||
}
|
s->set_contrast(s, atol(str)); // -2 to 2
|
||||||
|
Serial.print("[OK] SETTING CONTRAST ");
|
||||||
|
Serial.println(str);
|
||||||
void setup() {
|
}
|
||||||
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector
|
|
||||||
|
const command_action_t commands[] = {
|
||||||
Serial.begin(115200);
|
// Name of command user types, function that implements the command.
|
||||||
while (!Serial) {
|
{"reboot", reboot_esp32},
|
||||||
; // wait for serial port to connect. Needed for Leonardo only
|
{"bright",set_brightness},
|
||||||
}
|
{"satur",set_saturation},
|
||||||
|
{"contr",set_contrast},
|
||||||
camera_config_t config;
|
{"speed", set_speed},
|
||||||
config.ledc_channel = LEDC_CHANNEL_0;
|
{"capture", capture_image},
|
||||||
config.ledc_timer = LEDC_TIMER_0;
|
{"free", free_image},
|
||||||
config.pin_d0 = Y2_GPIO_NUM;
|
{"measure", print_measurement},
|
||||||
config.pin_d1 = Y3_GPIO_NUM;
|
{"rb", recv_ymodem},
|
||||||
config.pin_d2 = Y4_GPIO_NUM;
|
{"help", print_commands},
|
||||||
config.pin_d3 = Y5_GPIO_NUM;
|
{"?", print_commands},
|
||||||
config.pin_d4 = Y6_GPIO_NUM;
|
};
|
||||||
config.pin_d5 = Y7_GPIO_NUM;
|
|
||||||
config.pin_d6 = Y8_GPIO_NUM;
|
void print_commands(char *aLine) {
|
||||||
config.pin_d7 = Y9_GPIO_NUM;
|
Serial.print(commands[0].command);
|
||||||
config.pin_xclk = XCLK_GPIO_NUM;
|
for (size_t i = 1; i < sizeof(commands)/sizeof(commands[0]); i++) {
|
||||||
config.pin_pclk = PCLK_GPIO_NUM;
|
Serial.print(','); Serial.print(commands[i].command);
|
||||||
config.pin_vsync = VSYNC_GPIO_NUM;
|
}
|
||||||
config.pin_href = HREF_GPIO_NUM;
|
Serial.println();
|
||||||
config.pin_sscb_sda = SIOD_GPIO_NUM;
|
}
|
||||||
config.pin_sscb_scl = SIOC_GPIO_NUM;
|
|
||||||
config.pin_pwdn = PWDN_GPIO_NUM;
|
|
||||||
config.pin_reset = RESET_GPIO_NUM;
|
void execute(char *aLine) {
|
||||||
config.xclk_freq_hz = 20000000;
|
if (aLine == NULL || *aLine == '\0') return;
|
||||||
config.pixel_format = PIXFORMAT_JPEG;
|
char *cmd = strtok(aLine, " \t");
|
||||||
|
if (cmd == NULL || *cmd == '\0') return;
|
||||||
if(psramFound()){
|
toLower(cmd);
|
||||||
config.frame_size = FRAMESIZE_UXGA; // FRAMESIZE_ + QVGA|CIF|VGA|SVGA|XGA|SXGA|UXGA
|
for (size_t i = 0; i < sizeof(commands)/sizeof(commands[0]); i++) {
|
||||||
config.jpeg_quality = 10;
|
if (strcmp(cmd, commands[i].command) == 0) {
|
||||||
config.fb_count = 2;
|
commands[i].action(aLine);
|
||||||
} else {
|
return;
|
||||||
config.frame_size = FRAMESIZE_SVGA;
|
}
|
||||||
config.jpeg_quality = 12;
|
}
|
||||||
config.fb_count = 1;
|
Serial.println("command not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init Camera
|
|
||||||
esp_err_t err = esp_camera_init(&config);
|
void setup() {
|
||||||
if (err != ESP_OK) {
|
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector
|
||||||
Serial.printf("Camera init failed with error 0x%x", err);
|
|
||||||
return;
|
Serial.begin(460800);
|
||||||
}
|
while (!Serial) {
|
||||||
|
; // wait for serial port to connect. Needed for Leonardo only
|
||||||
// Take Picture with Camera
|
}
|
||||||
fb = esp_camera_fb_get();
|
|
||||||
if(!fb) {
|
camera_config_t config;
|
||||||
Serial.println("Camera capture failed");
|
config.ledc_channel = LEDC_CHANNEL_0;
|
||||||
return;
|
config.ledc_timer = LEDC_TIMER_0;
|
||||||
}
|
config.pin_d0 = Y2_GPIO_NUM;
|
||||||
esp_camera_fb_return(fb);
|
config.pin_d1 = Y3_GPIO_NUM;
|
||||||
|
config.pin_d2 = Y4_GPIO_NUM;
|
||||||
Wire.begin(14,15);
|
config.pin_d3 = Y5_GPIO_NUM;
|
||||||
|
config.pin_d4 = Y6_GPIO_NUM;
|
||||||
BMESensor.begin();
|
config.pin_d5 = Y7_GPIO_NUM;
|
||||||
|
config.pin_d6 = Y8_GPIO_NUM;
|
||||||
}
|
config.pin_d7 = Y9_GPIO_NUM;
|
||||||
|
config.pin_xclk = XCLK_GPIO_NUM;
|
||||||
uint8_t bytesIn;
|
config.pin_pclk = PCLK_GPIO_NUM;
|
||||||
char aLine[80+1];
|
config.pin_vsync = VSYNC_GPIO_NUM;
|
||||||
|
config.pin_href = HREF_GPIO_NUM;
|
||||||
|
config.pin_sscb_sda = SIOD_GPIO_NUM;
|
||||||
void loop() {
|
config.pin_sscb_scl = SIOC_GPIO_NUM;
|
||||||
if (Serial.available() > 0) {
|
config.pin_pwdn = PWDN_GPIO_NUM;
|
||||||
int b = Serial.read();
|
config.pin_reset = RESET_GPIO_NUM;
|
||||||
if (b != -1) {
|
config.xclk_freq_hz = 20000000;
|
||||||
switch (b) {
|
config.pixel_format = PIXFORMAT_JPEG;
|
||||||
case '\n':
|
|
||||||
if (bytesIn && aLine[bytesIn-1] == '\0') break;
|
if(psramFound()){
|
||||||
case '\r':
|
config.frame_size = FRAMESIZE_UXGA; // FRAMESIZE_ + QVGA|CIF|VGA|SVGA|XGA|SXGA|UXGA
|
||||||
Serial.println();
|
config.jpeg_quality = 7;
|
||||||
aLine[bytesIn] = '\0';
|
config.fb_count = 2;
|
||||||
execute(aLine);
|
} else {
|
||||||
bytesIn = 0;
|
config.frame_size = FRAMESIZE_SVGA;
|
||||||
break;
|
config.jpeg_quality = 10;
|
||||||
default:
|
config.fb_count = 1;
|
||||||
aLine[bytesIn++] = (char)b;
|
}
|
||||||
if (bytesIn >= sizeof(aLine)-1) {
|
|
||||||
aLine[bytesIn] = '\0';
|
// Init Camera
|
||||||
execute(aLine);
|
esp_err_t err = esp_camera_init(&config);
|
||||||
bytesIn = 0;
|
if (err != ESP_OK) {
|
||||||
}
|
Serial.printf("Camera init failed with error 0x%x", err);
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
sensor_t * s = esp_camera_sensor_get();
|
||||||
|
s->set_brightness(s, 0); // -2 to 2
|
||||||
|
s->set_contrast(s, 0); // -2 to 2
|
||||||
|
s->set_saturation(s, 0); // -2 to 2
|
||||||
|
s->set_special_effect(s, 0); // 0 to 6 (0 - No Effect, 1 - Negative, 2 - Grayscale, 3 - Red Tint, 4 - Green Tint, 5 - Blue Tint, 6 - Sepia)
|
||||||
|
s->set_whitebal(s, 1); // 0 = disable , 1 = enable
|
||||||
|
s->set_awb_gain(s, 1); // 0 = disable , 1 = enable
|
||||||
|
s->set_wb_mode(s, 0); // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home)
|
||||||
|
s->set_exposure_ctrl(s, 1); // 0 = disable , 1 = enable
|
||||||
|
s->set_aec2(s, 0); // 0 = disable , 1 = enable
|
||||||
|
s->set_ae_level(s, 0); // -2 to 2
|
||||||
|
s->set_aec_value(s, 300); // 0 to 1200
|
||||||
|
s->set_gain_ctrl(s, 1); // 0 = disable , 1 = enable
|
||||||
|
s->set_agc_gain(s, 0); // 0 to 30
|
||||||
|
s->set_gainceiling(s, (gainceiling_t)0); // 0 to 6
|
||||||
|
s->set_bpc(s, 0); // 0 = disable , 1 = enable
|
||||||
|
s->set_wpc(s, 1); // 0 = disable , 1 = enable
|
||||||
|
s->set_raw_gma(s, 1); // 0 = disable , 1 = enable
|
||||||
|
s->set_lenc(s, 1); // 0 = disable , 1 = enable
|
||||||
|
s->set_hmirror(s, 0); // 0 = disable , 1 = enable
|
||||||
|
s->set_vflip(s, 0); // 0 = disable , 1 = enable
|
||||||
|
s->set_dcw(s, 1); // 0 = disable , 1 = enable
|
||||||
|
s->set_colorbar(s, 0); // 0 = disable , 1 = enable
|
||||||
|
|
||||||
|
|
||||||
|
// Take Picture with Camera
|
||||||
|
fb = esp_camera_fb_get();
|
||||||
|
if(!fb) {
|
||||||
|
Serial.println("Camera capture failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
esp_camera_fb_return(fb);
|
||||||
|
|
||||||
|
Wire.begin(14,15);
|
||||||
|
|
||||||
|
BMESensor.begin();
|
||||||
|
|
||||||
|
print_commands("");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t bytesIn;
|
||||||
|
char aLine[80+1];
|
||||||
|
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
if (Serial.available() > 0) {
|
||||||
|
int b = Serial.read();
|
||||||
|
if (b != -1) {
|
||||||
|
switch (b) {
|
||||||
|
case '\n':
|
||||||
|
if (bytesIn && aLine[bytesIn-1] == '\0') break;
|
||||||
|
case '\r':
|
||||||
|
Serial.println();
|
||||||
|
aLine[bytesIn] = '\0';
|
||||||
|
execute(aLine);
|
||||||
|
bytesIn = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
aLine[bytesIn++] = (char)b;
|
||||||
|
if (bytesIn >= sizeof(aLine)-1) {
|
||||||
|
aLine[bytesIn] = '\0';
|
||||||
|
execute(aLine);
|
||||||
|
bytesIn = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
22
test/README
22
test/README
@@ -1,11 +1,11 @@
|
|||||||
|
|
||||||
This directory is intended for PlatformIO Unit Testing and project tests.
|
This directory is intended for PlatformIO Unit Testing and project tests.
|
||||||
|
|
||||||
Unit Testing is a software testing method by which individual units of
|
Unit Testing is a software testing method by which individual units of
|
||||||
source code, sets of one or more MCU program modules together with associated
|
source code, sets of one or more MCU program modules together with associated
|
||||||
control data, usage procedures, and operating procedures, are tested to
|
control data, usage procedures, and operating procedures, are tested to
|
||||||
determine whether they are fit for use. Unit testing finds problems early
|
determine whether they are fit for use. Unit testing finds problems early
|
||||||
in the development cycle.
|
in the development cycle.
|
||||||
|
|
||||||
More information about PlatformIO Unit Testing:
|
More information about PlatformIO Unit Testing:
|
||||||
- https://docs.platformio.org/page/plus/unit-testing.html
|
- https://docs.platformio.org/page/plus/unit-testing.html
|
||||||
|
|||||||
Reference in New Issue
Block a user