speed 460800, commands bright, satur, contr

This commit is contained in:
2021-10-15 18:22:06 +02:00
parent 9a82880086
commit aa53b5aca1
8 changed files with 463 additions and 388 deletions

4
.gitignore vendored
View File

@@ -3,3 +3,7 @@
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
src/.vscode/c_cpp_properties.json
.vscode/extensions.json
.vscode/extensions.json
platformio.ini

View File

@@ -14,5 +14,7 @@ board = esp32cam
framework = arduino
monitor_port = COM[13678]
monitor_speed = 115200
monitor_rts = 0
monitor_dtr = 0
lib_deps =
enviromonitor/BME280_Light@0.0.0-alpha+sha.600667f3a6

View File

@@ -64,11 +64,15 @@ void reboot_esp32(char *aLine)
ESP.restart();
}
void recv_ymodem(char *aLine)
void set_speed(char *aLine)
{
xmodem.sendFile(fb->buf, fb->len, "camera.jpg");
char *cmd = strtok(aLine, " \t");
char *speed = strtok(NULL," \t");
Serial.updateBaudRate(strtoul(speed,nullptr,10));
Serial.print("[OK] SETTING SPEED");
}
void capture_image(char *aLine)
{
fb = esp_camera_fb_get();
@@ -81,6 +85,13 @@ void free_image(char *aLine)
Serial.println("[OK] FREE CAPTURED IMAGE");
}
void recv_ymodem(char *aLine)
{
xmodem.sendFile(fb->buf, fb->len, "camera.jpg");
Serial.println("[OK] SEND IMAGE");
free_image(aLine);
}
void print_measurement(char *aLine)
{
BMESensor.refresh(); // read current sensor dat
@@ -88,9 +99,40 @@ void print_measurement(char *aLine)
return;
}
void set_brightness(char *aLine)
{
char *cmd = strtok(aLine, " \t");
char *str = strtok(NULL," \t");
sensor_t * s = esp_camera_sensor_get();
s->set_brightness(s, strtol(str,nullptr,10)); // -2 to 2
Serial.print("[OK] SETTING BRIGHTNESS");
}
void set_saturation(char *aLine)
{
char *cmd = strtok(aLine, " \t");
char *str = strtok(NULL," \t");
sensor_t * s = esp_camera_sensor_get();
s->set_saturation(s, strtol(str,nullptr,10)); // -2 to 2
Serial.print("[OK] SETTING SATURATION");
}
void set_contrast(char *aLine)
{
char *cmd = strtok(aLine, " \t");
char *str = strtok(NULL," \t");
sensor_t * s = esp_camera_sensor_get();
s->set_contrast(s, strtol(str,nullptr,10)); // -2 to 2
Serial.print("[OK] SETTING CONTRAST");
}
const command_action_t commands[] = {
// Name of command user types, function that implements the command.
{"reboot", reboot_esp32},
{"bright",set_brightness},
{"satur",set_saturation},
{"contr",set_contrast},
{"speed", set_speed},
{"capture", capture_image},
{"free", free_image},
{"measure", print_measurement},
@@ -126,7 +168,7 @@ void execute(char *aLine) {
void setup() {
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector
Serial.begin(115200);
Serial.begin(460800);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
@@ -155,11 +197,11 @@ camera_config_t config;
if(psramFound()){
config.frame_size = FRAMESIZE_UXGA; // FRAMESIZE_ + QVGA|CIF|VGA|SVGA|XGA|SXGA|UXGA
config.jpeg_quality = 10;
config.jpeg_quality = 7;
config.fb_count = 2;
} else {
config.frame_size = FRAMESIZE_SVGA;
config.jpeg_quality = 12;
config.jpeg_quality = 10;
config.fb_count = 1;
}
@@ -170,6 +212,31 @@ camera_config_t config;
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) {
@@ -182,6 +249,8 @@ camera_config_t config;
BMESensor.begin();
print_commands("");
}
uint8_t bytesIn;