Skip to content

Commit c2a55e7

Browse files
caco3haverlandCaCO3jomjolSlider0007
authored
v15.2.0 (#2345)
* Testcase for #2145 and debug-log (#2151) * new models ana-cont-11.0.5, ana-class100-1.5.7, dig-class100-1.6.0 * Testcase for #2145 Added debug log, if allowNegativeRates is handeled * Fix timezone config parser (#2169) * make sure to parse the whole config line * fix crash on empty timezone parameter --------- Co-authored-by: CaCO3 <[email protected]> * Enhance ROI pages (#2161) * Check if the ROIs are equidistant. Only if not, untick the checkbox * renaming * Check if the ROIs have same y, dy and dx. If so, tick the sync checkbox * only allow editing space when box is checked * fix sync check * show inner frame on all ROIs * cleanup * Check if the ROIs have same dy and dx. If so, tick the sync checkbox * checkbox position * renaming * renaming * show inner frame and cross hairs on all ROIs * update ROIs on ticking checkboxes * show timezone hint * fix deleting last ROI * cleanup --------- Co-authored-by: CaCO3 <[email protected]> * restart timeout on progress, catch error (#2170) * restart timeout on progress, catch error * . --------- Co-authored-by: CaCO3 <[email protected]> * BugFix #2167 * Release 15.1 preparations (#2171) * Update Changelog.md * Update Changelog.md * Update Changelog.md * Update changelog * Fix links to PR * Formating * Update Changelog.md * Update Changelog.md * Update Changelog.md * Update Changelog.md * Update Changelog.md * Update Changelog.md * Update Changelog.md * Update Changelog.md * Update Changelog.md * Update Changelog.md * Update Changelog.md * Update Changelog.md --------- Co-authored-by: Slider0007 <[email protected]> Co-authored-by: Slider0007 <[email protected]> * fix typo * Replace relative documentation links with absolute ones pointing to the external documentation (#2180) Co-authored-by: CaCO3 <[email protected]> * Sort model files in configuration combobox (#2189) * new models ana-cont-11.0.5, ana-class100-1.5.7, dig-class100-1.6.0 * Testcase for #2145 Added debug log, if allowNegativeRates is handeled * Sort model files in combobox * reboot task - increase stack size (#2201) Avoid stack overflow * Update interface_influxdb.cpp * Update Changelog.md * Show PSRAM usage (#2206) * centralize PSRAM usage (application code only) * update logging * update logging * fix use after free * initialize buffer * free rgb_image before ussing it for new allocation * use wrapper function * switch log level to debug * . * undo adding free() calls * . * add names to all CImage instances * . * . * . * revert changes of stbi_image_free() with free_psram_heap() on the places where is is not in PSRAM * . * typos * typo * Added MQTT Outbox explanation/warning * added CONFIG_SPIRAM_USE_MEMMAP explanation --------- Co-authored-by: CaCO3 <[email protected]> * Disable custom MQTT Outbox. This also moves the MQTT Publishing memory usage back to the internal RAM! * log MQTT connection refused reasons (#2216) * Revert PSRAM usage as it lead to memory fragmentation. See #2200 for details * fix missing value data * Revert PSRAM usage as it lead to memory fragmentation. (#2224) See #2200 for details Co-authored-by: CaCO3 <[email protected]> * Fix missing value data in graph (#2230) * fix missing value data --------- Co-authored-by: CaCO3 <[email protected]> * Update Changelog.md (#2231) * Update interface_influxdb.cpp (#2233) * update copyright year * Cleanup * Set prevalue using MQTT + set prevalue to RAW value (REST+MQTT) (#2252) * Use double instead of float * Error handling + set to RAW if newvalue < 0 * REST SetPrevalue: Set to RAW if newvalue < 0 * set prevalue with MQTT * removed the stb_image files and re-add them as a submodule. (#2223) - stb_image.h: Version update 2.25 -> 2.28 - stb_resize.h: Version update 0.96 -> 0.97 - stb_write.h: Version update 1.14 -> 1.16 Co-authored-by: CaCO3 <[email protected]> * Remove obsolete ClassFlowWriteList (#2264) * Renaming & cleanup of some modules / functions in source code (#2265) * Rename module tag name * Rename server_tflite.cpp -> MainFlowControl.cpp * Remove redundandant MQTTMainTopic function * Update * Remove obsolete GetMQTTMainTopic * Fix last element missing in digit model drop down (#2282) * Debug influxdb (#2283) * Fix time offset issues in InfluxDB component. (#2278) Closes #2273 Closes #2150 * Update interface_influxdb.cpp * Update interface_influxdb.cpp * Improve Logging * Implement TimeSync at beginning * Update time_sntp.cpp * Update time_sntp.cpp * Set Time After WLAN Init --------- Co-authored-by: Antonin Delpeuch <[email protected]> * Implement a camera livestream handler (#2286) * fix leading NaN (#2310) * analogROI: Activate save button after ROI creation (#2326) * Migration of PlatformIO 5.2.0 to 6.1.0 (resp. ESP IDF from 4.4.2 to 5.0.1) (#2305) * Migration to PlatformIO 6.1.0 * Disable RMTMEM usage as it is no longer allowed -> Smart LEDs not functional! * moved miniz into subfolder of jomjol_fileserver_ota, else it does not build anymore. * cleanup * fix leading NaN (#2310) * Migration to PlatformIO 6.1.0 * Disable RMTMEM usage as it is no longer allowed -> Smart LEDs not functional! * moved miniz into subfolder of jomjol_fileserver_ota, else it does not build anymore. * cleanup * Task watchdog has new config name * Fix return value check. It must be something else than ESP_FAIL, but it does not need to be ESP_OK! * add missing strucures to work around new RMTMEM restriction (untested) --------- Co-authored-by: CaCO3 <[email protected]> * Keep MainFlowTask alive to handle reboot (#2325) * Shared PSRAM memory (#2285) * enable PSRAM logging * add extra functions for psram shared memroy handling * CImageBasis objects still should used dynamic memory (eg. rawImage), haw ever tmpImage must be placed inside the shared memory * Place all STBI allocs inside the shared memory * The models are placed in the shared PSRAM reagion and must be allocated through the dedicated functions * . * renaming * fix cast warning * add flag to switch STBI PSRAM usage * improve PSRAM shared handling * reserve shared PSRAM as early as possible * init logging eralier so we can use it in PSRAM shared alloc * move Wifi_LWIP, BSS_SEG and MQTT Outbox into PSRAM to ffree internal memory * Check if model fits into reserved shared memory * Update code/components/jomjol_tfliteclass/CTfLiteClass.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_flowcontroll/ClassFlowControll.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_image_proc/CImageBasis.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * . * . * . * . * Korrektur Merge Conflict in main.cpp --------- Co-authored-by: CaCO3 <[email protected]> Co-authored-by: jomjol <[email protected]> * fix PSRAM init return value check * Extend InfluxDBv1 with individual topic names (#2319) * Implement individual influx topic * Update interface_influxdb.cpp * Update interface_influxdb.cpp * Update FieldName * analogROI: Activate save button after ROI creation (#2326) * Migration of PlatformIO 5.2.0 to 6.1.0 (resp. ESP IDF from 4.4.2 to 5.0.1) (#2305) * Migration to PlatformIO 6.1.0 * Disable RMTMEM usage as it is no longer allowed -> Smart LEDs not functional! * moved miniz into subfolder of jomjol_fileserver_ota, else it does not build anymore. * cleanup * fix leading NaN (#2310) * Migration to PlatformIO 6.1.0 * Disable RMTMEM usage as it is no longer allowed -> Smart LEDs not functional! * moved miniz into subfolder of jomjol_fileserver_ota, else it does not build anymore. * cleanup * Task watchdog has new config name * Fix return value check. It must be something else than ESP_FAIL, but it does not need to be ESP_OK! * add missing strucures to work around new RMTMEM restriction (untested) --------- Co-authored-by: CaCO3 <[email protected]> * Keep MainFlowTask alive to handle reboot (#2325) * Shared PSRAM memory (#2285) * enable PSRAM logging * add extra functions for psram shared memroy handling * CImageBasis objects still should used dynamic memory (eg. rawImage), haw ever tmpImage must be placed inside the shared memory * Place all STBI allocs inside the shared memory * The models are placed in the shared PSRAM reagion and must be allocated through the dedicated functions * . * renaming * fix cast warning * add flag to switch STBI PSRAM usage * improve PSRAM shared handling * reserve shared PSRAM as early as possible * init logging eralier so we can use it in PSRAM shared alloc * move Wifi_LWIP, BSS_SEG and MQTT Outbox into PSRAM to ffree internal memory * Check if model fits into reserved shared memory * Update code/components/jomjol_tfliteclass/CTfLiteClass.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_flowcontroll/ClassFlowControll.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_image_proc/CImageBasis.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * . * . * . * . * Korrektur Merge Conflict in main.cpp --------- Co-authored-by: CaCO3 <[email protected]> Co-authored-by: jomjol <[email protected]> * fix PSRAM init return value check * Extend incl. indiv. Measurement * Implement UX * Update ClassFlowInfluxDBv2.cpp * Implement individual influx topic * Update interface_influxdb.cpp * Update interface_influxdb.cpp * Update FieldName * Extend incl. indiv. Measurement * Implement UX * Update ClassFlowInfluxDBv2.cpp * Update main.cpp --------- Co-authored-by: Slider0007 <[email protected]> Co-authored-by: CaCO3 <[email protected]> Co-authored-by: CaCO3 <[email protected]> * Update Changelog.md (#2344) * Update Changelog.md * Update Changelog.md * merge conflicts * merge conflicts * update changelog --------- Co-authored-by: Frank Haverland <[email protected]> Co-authored-by: CaCO3 <[email protected]> Co-authored-by: jomjol <[email protected]> Co-authored-by: Slider0007 <[email protected]> Co-authored-by: Slider0007 <[email protected]> Co-authored-by: Antonin Delpeuch <[email protected]>
1 parent 03c84a1 commit c2a55e7

File tree

84 files changed

+1304
-12775
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1304
-12775
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
[submodule "code/components/tflite-micro-esp-examples"]
88
path = code/components/tflite-micro-esp-examples
99
url = https://github.com/espressif/tflite-micro-esp-examples.git
10+
[submodule "code/components/stb"]
11+
path = code/components/stb
12+
url = https://github.com/nothings/stb.git

Changelog.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,40 @@
1+
## [15.2.0] - 2023-04-23
2+
3+
### Update Procedure
4+
5+
Update Procedure see [online documentation](https://jomjol.github.io/AI-on-the-edge-device-docs/Installation/#update-ota-over-the-air)
6+
7+
### Changes
8+
9+
For a full list of changes see [Full list of changes](https://github.com/jomjol/AI-on-the-edge-device/compare/v15.1.1...v15.2.0)
10+
11+
#### Added
12+
13+
- [#2286](https://github.com/jomjol/AI-on-the-edge-device/pull/2286) Implement a camera livestream handler
14+
- [#2252](https://github.com/jomjol/AI-on-the-edge-device/pull/2252) Set prevalue using MQTT + set prevalue to RAW value (REST+MQTT)
15+
- [#2319](https://github.com/jomjol/AI-on-the-edge-device/pull/2319) Extend InfluxDBv1 with individual topic names
16+
- [#](https://github.com/jomjol/AI-on-the-edge-device/pull/)
17+
- [#](https://github.com/jomjol/AI-on-the-edge-device/pull/)
18+
19+
#### Changed
20+
21+
- [#2285](https://github.com/jomjol/AI-on-the-edge-device/pull/2285) Re-implemented PSRAM usage
22+
- [#2325](https://github.com/jomjol/AI-on-the-edge-device/pull/2325) Keep MainFlowTask alive to handle reboot
23+
- [#2233](https://github.com/jomjol/AI-on-the-edge-device/pull/2233) Remove trailing slash in influxDBv1
24+
- [#2305](https://github.com/jomjol/AI-on-the-edge-device/pull/2305) Migration of PlatformIO `5.2.0` to `6.1.0` (resp. ESP IDF from `4.4.2` to `5.0.1`)
25+
- Various cleanup and refactoring
26+
27+
#### Fixed
28+
29+
- [#2326](https://github.com/jomjol/AI-on-the-edge-device/pull/2326) Activate save button after Analogue ROI creationSet prevalue using MQTT + set prevalue to RAW value (REST+MQTT)
30+
- [#2283](https://github.com/jomjol/AI-on-the-edge-device/pull/2283) Fix Timezone issues on InfluxDB
31+
- Various minor fixes
32+
33+
#### Removed
34+
35+
- n.a.
36+
37+
138
## [15.1.1] - 2023-03-23
239

340
### Update Procedure
@@ -933,6 +970,7 @@ External Illumination
933970
- Initial Version
934971

935972

973+
[15.2.0]: https://github.com/jomjol/AI-on-the-edge-device/compare/v15.1.1...v15.1.2
936974
[15.1.1]: https://github.com/jomjol/AI-on-the-edge-device/compare/v15.1.0...v15.1.1
937975
[15.1.0]: https://github.com/jomjol/AI-on-the-edge-device/compare/v15.0.3...v15.1.0
938976
[15.0.3]: https://github.com/jomjol/AI-on-the-edge-device/compare/v14.0.3...v15.0.3

code/components/jomjol_controlGPIO/SmartLeds.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11
#include "SmartLeds.h"
22

3+
4+
/* PlatformIO 6 (ESP IDF 5) does no longer allow access to RMTMEM,
5+
see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/migration-guides/release-5.x/5.0/peripherals.html?highlight=rmtmem#id5
6+
As a dirty workaround, we copy the needed structures from rmt_struct.h
7+
In the long run, this should be replaced! */
8+
typedef struct rmt_item32_s {
9+
union {
10+
struct {
11+
uint32_t duration0 :15;
12+
uint32_t level0 :1;
13+
uint32_t duration1 :15;
14+
uint32_t level1 :1;
15+
};
16+
uint32_t val;
17+
};
18+
} rmt_item32_t;
19+
20+
//Allow access to RMT memory using RMTMEM.chan[0].data32[8]
21+
typedef volatile struct rmt_mem_s {
22+
struct {
23+
rmt_item32_t data32[64];
24+
} chan[8];
25+
} rmt_mem_t;
26+
extern rmt_mem_t RMTMEM;
27+
28+
29+
330
IsrCore SmartLed::_interruptCore = CoreCurrent;
431
intr_handle_t SmartLed::_interruptHandle = NULL;
532

code/components/jomjol_controlGPIO/SmartLeds.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@
3535
#include <cassert>
3636
#include <cstring>
3737

38+
#include "esp_idf_version.h"
39+
#if (ESP_IDF_VERSION_MAJOR >= 5)
40+
#include "soc/periph_defs.h"
41+
#include "esp_private/periph_ctrl.h"
42+
#include "soc/gpio_sig_map.h"
43+
#include "soc/gpio_periph.h"
44+
#include "soc/io_mux_reg.h"
45+
#include "esp_rom_gpio.h"
46+
#define gpio_pad_select_gpio esp_rom_gpio_pad_select_gpio
47+
#define gpio_matrix_in(a,b,c) esp_rom_gpio_connect_in_signal(a,b,c)
48+
#define gpio_matrix_out(a,b,c,d) esp_rom_gpio_connect_out_signal(a,b,c,d)
49+
#define ets_delay_us(a) esp_rom_delay_us(a)
50+
#endif
51+
3852
#if defined ( ARDUINO )
3953
extern "C" { // ...someone forgot to put in the includes...
4054
#include "esp32-hal.h"
@@ -65,6 +79,27 @@
6579
#include <stdio.h>
6680
#endif
6781

82+
#if (ESP_IDF_VERSION_MAJOR >= 4) && (ESP_IDF_VERSION_MINOR > 1)
83+
#include "hal/gpio_ll.h"
84+
#else
85+
#include "soc/gpio_periph.h"
86+
#define esp_rom_delay_us ets_delay_us
87+
static inline int gpio_ll_get_level(gpio_dev_t *hw, int gpio_num)
88+
{
89+
if (gpio_num < 32) {
90+
return (hw->in >> gpio_num) & 0x1;
91+
} else {
92+
return (hw->in1.data >> (gpio_num - 32)) & 0x1;
93+
}
94+
}
95+
#endif
96+
97+
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0))
98+
#if !(configENABLE_BACKWARD_COMPATIBILITY == 1)
99+
#define xSemaphoreHandle SemaphoreHandle_t
100+
#endif
101+
#endif
102+
68103
#include "Color.h"
69104

70105
namespace detail {

code/components/jomjol_controlGPIO/server_GPIO.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
#include "freertos/FreeRTOS.h"
77
#include "freertos/task.h"
88
#include "esp_system.h"
9-
#include "esp_event.h"
10-
11-
#include "server_tflite.h"
129

1310
#include "esp_log.h"
1411

@@ -22,8 +19,10 @@
2219
#include "ClassLogFile.h"
2320
#include "configFile.h"
2421
#include "Helper.h"
22+
2523
#ifdef ENABLE_MQTT
26-
#include "interface_mqtt.h"
24+
#include "interface_mqtt.h"
25+
#include "server_mqtt.h"
2726
#endif //ENABLE_MQTT
2827

2928

@@ -331,7 +330,7 @@ bool GpioHandler::readConfig()
331330

332331
#ifdef ENABLE_MQTT
333332
// std::string mainTopicMQTT = "";
334-
std::string mainTopicMQTT = GetMQTTMainTopic();
333+
std::string mainTopicMQTT = mqttServer_getMainTopic();
335334
if (mainTopicMQTT.length() > 0)
336335
{
337336
mainTopicMQTT = mainTopicMQTT + "/GPIO";

code/components/jomjol_controlcamera/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/proto
44

55
idf_component_register(SRCS ${app_sources}
66
INCLUDE_DIRS "."
7-
REQUIRES esp32-camera esp_http_server jomjol_logfile jomjol_image_proc nvs_flash jomjol_fileserver_ota jomjol_controlGPIO)
7+
REQUIRES esp_timer esp32-camera esp_http_server jomjol_logfile jomjol_image_proc nvs_flash jomjol_fileserver_ota jomjol_controlGPIO)
88

99

code/components/jomjol_controlcamera/ClassControllCamera.cpp

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,39 @@
2121
#include <nvs_flash.h>
2222
#include <sys/param.h>
2323
#include <string.h>
24+
#include <sys/stat.h>
2425

2526
#include "freertos/FreeRTOS.h"
2627
#include "freertos/task.h"
2728

2829
#include "esp_camera.h"
2930

3031
#include "driver/ledc.h"
31-
#include "server_tflite.h"
32+
#include "MainFlowControl.h"
33+
34+
#if (ESP_IDF_VERSION_MAJOR >= 5)
35+
#include "soc/periph_defs.h"
36+
#include "esp_private/periph_ctrl.h"
37+
#include "soc/gpio_sig_map.h"
38+
#include "soc/gpio_periph.h"
39+
#include "soc/io_mux_reg.h"
40+
#include "esp_rom_gpio.h"
41+
#define gpio_pad_select_gpio esp_rom_gpio_pad_select_gpio
42+
#define gpio_matrix_in(a,b,c) esp_rom_gpio_connect_in_signal(a,b,c)
43+
#define gpio_matrix_out(a,b,c,d) esp_rom_gpio_connect_out_signal(a,b,c,d)
44+
#define ets_delay_us(a) esp_rom_delay_us(a)
45+
#endif
3246

3347
static const char *TAG = "CAM";
3448

49+
50+
/* Camera live stream */
51+
#define PART_BOUNDARY "123456789000000000000987654321"
52+
static const char* _STREAM_CONTENT_TYPE = "multipart/x-mixed-replace;boundary=" PART_BOUNDARY;
53+
static const char* _STREAM_BOUNDARY = "\r\n--" PART_BOUNDARY "\r\n";
54+
static const char* _STREAM_PART = "Content-Type: image/jpeg\r\nContent-Length: %u\r\n\r\n";
55+
56+
3557
static camera_config_t camera_config = {
3658
.pin_pwdn = CAM_PIN_PWDN,
3759
.pin_reset = CAM_PIN_RESET,
@@ -512,7 +534,7 @@ esp_err_t CCamera::CaptureToHTTP(httpd_req_t *req, int delay)
512534
esp_camera_fb_return(fb);
513535
int64_t fr_end = esp_timer_get_time();
514536

515-
ESP_LOGI(TAG, "JPG: %uKB %ums", (uint32_t)(fb_len/1024), (uint32_t)((fr_end - fr_start)/1000));
537+
ESP_LOGI(TAG, "JPG: %dKB %dms", (int)(fb_len/1024), (int)((fr_end - fr_start)/1000));
516538

517539
if (delay > 0)
518540
LightOnOff(false);
@@ -521,6 +543,74 @@ esp_err_t CCamera::CaptureToHTTP(httpd_req_t *req, int delay)
521543
}
522544

523545

546+
esp_err_t CCamera::CaptureToStream(httpd_req_t *req, bool FlashlightOn)
547+
{
548+
esp_err_t res = ESP_OK;
549+
size_t fb_len = 0;
550+
int64_t fr_start;
551+
char * part_buf[64];
552+
553+
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Live stream started");
554+
555+
if (FlashlightOn) {
556+
LEDOnOff(true);
557+
LightOnOff(true);
558+
}
559+
560+
//httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); //stream is blocking web interface, only serving to local
561+
562+
httpd_resp_set_type(req, _STREAM_CONTENT_TYPE);
563+
httpd_resp_send_chunk(req, _STREAM_BOUNDARY, strlen(_STREAM_BOUNDARY));
564+
565+
while(1)
566+
{
567+
fr_start = esp_timer_get_time();
568+
camera_fb_t *fb = esp_camera_fb_get();
569+
esp_camera_fb_return(fb);
570+
fb = esp_camera_fb_get();
571+
if (!fb) {
572+
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "CaptureToStream: Camera framebuffer not available");
573+
break;
574+
}
575+
fb_len = fb->len;
576+
577+
if (res == ESP_OK){
578+
size_t hlen = snprintf((char *)part_buf, sizeof(part_buf), _STREAM_PART, fb_len);
579+
res = httpd_resp_send_chunk(req, (const char *)part_buf, hlen);
580+
}
581+
if (res == ESP_OK){
582+
res = httpd_resp_send_chunk(req, (const char *)fb->buf, fb_len);
583+
}
584+
if (res == ESP_OK){
585+
res = httpd_resp_send_chunk(req, _STREAM_BOUNDARY, strlen(_STREAM_BOUNDARY));
586+
}
587+
588+
esp_camera_fb_return(fb);
589+
590+
int64_t fr_end = esp_timer_get_time();
591+
ESP_LOGD(TAG, "JPG: %dKB %dms", (int)(fb_len/1024), (int)((fr_end - fr_start)/1000));
592+
593+
if (res != ESP_OK){ // Exit loop, e.g. also when closing the webpage
594+
break;
595+
}
596+
597+
int64_t fr_delta_ms = (fr_end - fr_start) / 1000;
598+
if (CAM_LIVESTREAM_REFRESHRATE > fr_delta_ms) {
599+
const TickType_t xDelay = (CAM_LIVESTREAM_REFRESHRATE - fr_delta_ms) / portTICK_PERIOD_MS;
600+
ESP_LOGD(TAG, "Stream: sleep for: %ldms", (long) xDelay*10);
601+
vTaskDelay(xDelay);
602+
}
603+
}
604+
605+
LEDOnOff(false);
606+
LightOnOff(false);
607+
608+
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Live stream stopped");
609+
610+
return res;
611+
}
612+
613+
524614
void CCamera::LightOnOff(bool status)
525615
{
526616
GpioHandler* gpioHandler = gpio_handler_get();

code/components/jomjol_controlcamera/ClassControllCamera.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class CCamera {
4040
void LightOnOff(bool status);
4141
void LEDOnOff(bool status);
4242
esp_err_t CaptureToHTTP(httpd_req_t *req, int delay = 0);
43+
esp_err_t CaptureToStream(httpd_req_t *req, bool FlashlightOn);
4344
void SetQualitySize(int qual, framesize_t resol);
4445
bool SetBrightnessContrastSaturation(int _brightness, int _contrast, int _saturation);
4546
void GetCameraParameter(httpd_req_t *req, int &qual, framesize_t &resol);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*)
22

33
idf_component_register(SRCS ${app_sources}
4-
INCLUDE_DIRS "." "../../include"
5-
REQUIRES tflite-lib esp_http_server app_update esp_http_client nvs_flash jomjol_tfliteclass jomjol_flowcontroll spiffs jomjol_helper jomjol_controlGPIO miniz)
4+
INCLUDE_DIRS "." "../../include" "miniz"
5+
REQUIRES vfs tflite-lib esp_http_server app_update esp_http_client nvs_flash jomjol_tfliteclass jomjol_flowcontroll spiffs jomjol_helper jomjol_controlGPIO)
66

77

File renamed without changes.

0 commit comments

Comments
 (0)