Fix: 修复arduino下include异常

This commit is contained in:
王立帮
2024-09-11 19:30:04 +08:00
parent 84cf604c72
commit 3af2a14634
8 changed files with 14 additions and 14 deletions

View File

@@ -540,7 +540,7 @@ export const AFMotorStop = function (_, generator) {
export const arduino_dfplayer_mini_begin = function (_, generator) {
var text_dfplayer_name = this.getFieldValue('dfplayer_name');
var value_dfplayer_pin = generator.valueToCode(this, 'dfplayer_pin', generator.ORDER_ATOMIC);
generator.definitions_['include_Arduino'] = '#include "generator.h"';
generator.definitions_['include_Arduino'] = '#include <Arduino.h>';
generator.definitions_['include_DFRobotDFPlayerMini'] = '#include "DFRobotDFPlayerMini.h"';
generator.definitions_['var_declare_DFPlayerMini_' + text_dfplayer_name] = 'DFRobotDFPlayerMini ' + text_dfplayer_name + ';';
generator.setups_['setup_DFPlayerMini_' + text_dfplayer_name] = '' + text_dfplayer_name + '.begin(' + value_dfplayer_pin + ');';

View File

@@ -252,7 +252,7 @@ export const blynk_iot_ir_send_ac = function (_, generator) {
let AC_FAN = this.getFieldValue('AC_FAN');
let dropdown_pin = generator.valueToCode(this, 'PIN', generator.ORDER_ATOMIC);
let AC_TEMP = generator.valueToCode(this, 'AC_TEMP', generator.ORDER_ATOMIC);
generator.definitions_['include_Arduino'] = '#ifndef UNIT_TEST\n#include <generator.h>\n#endif';
generator.definitions_['include_Arduino'] = '#ifndef UNIT_TEST\n#include <Arduino.h>\n#endif';
generator.definitions_['include_IRremoteESP8266'] = '#include <IRremoteESP8266.h>';
generator.definitions_['include_IRsend'] = '#include <IRsend.h>';
generator.definitions_['include' + AC_TYPE] = '#include <ir_' + AC_TYPE + '.h>';
@@ -271,7 +271,7 @@ export const blynk_iot_ir_send_ac = function (_, generator) {
export const blynk_iot_ir_recv_raw = function (_, generator) {
let dropdown_pin = generator.valueToCode(this, 'PIN', generator.ORDER_ATOMIC);
generator.definitions_['include_IRremote'] = '#ifndef UNIT_TEST\n'
+ '#include <generator.h>\n'
+ '#include <Arduino.h>\n'
+ '#endif\n#include <IRremoteESP8266.h>\n#include <IRrecv.h>\n#include <IRutils.h>\n#if DECODE_AC\n#include <ir_Daikin.h>\n#include <ir_Fujitsu.h>\n#include <ir_Gree.h>\n#include <ir_Haier.h>\n#include <ir_Kelvinator.h>\n#include <ir_Midea.h>\n#include <ir_Toshiba.h>\n#endif \n';
generator.definitions_['define_RECV_PIN' + dropdown_pin] = '#define RECV_PIN ' + dropdown_pin + '\n';
// generator.definitions_['define_BAUD_RATE'] = '#define BAUD_RATE 115200\n';
@@ -351,7 +351,7 @@ export const blynk_iot_ir_send = function (_, generator) {
let IR_CODE = this.getFieldValue('IR_CODE');
let IR_CODE_LENGTH = IR_CODE.split(',').length;
let random_num = Math.ceil(Math.random() * 100000);
generator.definitions_['define_IRremote'] = '#ifndef UNIT_TEST\n#include <generator.h>\n#endif\n#include <IRremoteESP8266.h>\n#include <IRsend.h>\n#define IR_LED ' + dropdown_pin;
generator.definitions_['define_IRremote'] = '#ifndef UNIT_TEST\n#include <Arduino.h>\n#endif\n#include <IRremoteESP8266.h>\n#include <IRsend.h>\n#define IR_LED ' + dropdown_pin;
generator.definitions_['var_declare_IRsend_irsend'] = 'IRsend irsend(IR_LED);\n';
generator.definitions_['var_declare_send' + random_num] = 'uint16_t rawData' + random_num + '[' + IR_CODE_LENGTH + '] = {' + IR_CODE + '};';
// generator.setups_['Serial.begin'] = 'irsend.begin();\n Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);\n';
@@ -830,7 +830,7 @@ export const esp_camera = function (_, generator) {
+ 'Serial.println(IP);\n'
+ 'Serial.println("");\n';
}
generator.definitions_['esp_camera'] = '#include "esp_camera.h"\n#include <WiFi.h>\n#include "esp_timer.h"\n#include "img_converters.h"\n#include "generator.h"\n#include "fb_gfx.h"\n#include "soc/soc.h"\n#include "soc/rtc_cntl_reg.h"\n#include "dl_lib.h"\n#include "esp_http_server.h"\nconst char*wif_ssid = ' + wifi_ssid + ';\nconst char*wif_password = ' + wifi_pass + ';\n#define PART_BOUNDARY "123456789000000000000987654321"\n#define PWDN_GPIO_NUM 32\n#define RESET_GPIO_NUM -1\n#define XCLK_GPIO_NUM 0\n#define SIOD_GPIO_NUM 26\n#define SIOC_GPIO_NUM 27\n#define Y9_GPIO_NUM 35\n#define Y8_GPIO_NUM 34\n#define Y7_GPIO_NUM 39\n#define Y6_GPIO_NUM 36\n#define Y5_GPIO_NUM 21\n#define Y4_GPIO_NUM 19\n#define Y3_GPIO_NUM 18\n#define Y2_GPIO_NUM 5\n#define VSYNC_GPIO_NUM 25\n#define HREF_GPIO_NUM 23\n#define PCLK_GPIO_NUM 22\nstatic const char* _STREAM_CONTENT_TYPE = "multipart/x-mixed-replace;boundary=" PART_BOUNDARY;\nstatic const char* _STREAM_BOUNDARY = "\\r\\n--" PART_BOUNDARY "\\r\\n";\nstatic const char* _STREAM_PART = "Content-Type: image/jpeg\\r\\nContent-Length: %u\\r\\n\\r\\n";\nhttpd_handle_t stream_httpd = NULL;\nstatic esp_err_t stream_handler(httpd_req_t *req){\n camera_fb_t * fb = NULL;\n esp_err_t res = ESP_OK;\n size_t _jpg_buf_len = 0;\n uint8_t * _jpg_buf = NULL;\n char * part_buf[64];\n res = httpd_resp_set_type(req, _STREAM_CONTENT_TYPE);\n if(res != ESP_OK){\n return res;\n }\n while(true){\n fb = esp_camera_fb_get();\n if (!fb) {\n Serial.println("Camera capture failed");\n res = ESP_FAIL;\n } else {\n if(fb->width > 400){\n if(fb->format != PIXFORMAT_JPEG){\n bool jpeg_converted = frame2jpg(fb, 80, &_jpg_buf, &_jpg_buf_len);\n esp_camera_fb_return(fb);\n fb = NULL;\n if(!jpeg_converted){\n Serial.println("JPEG compression failed");\n res = ESP_FAIL;\n }\n } else {\n _jpg_buf_len = fb->len;\n _jpg_buf = fb->buf;\n }\n }\n }\n if(res == ESP_OK){\n size_t hlen = snprintf((char *)part_buf, 64, _STREAM_PART, _jpg_buf_len);\n res = httpd_resp_send_chunk(req, (const char *)part_buf, hlen);\n }\n if(res == ESP_OK){\n res = httpd_resp_send_chunk(req, (const char *)_jpg_buf, _jpg_buf_len);\n }\n if(res == ESP_OK){\n res = httpd_resp_send_chunk(req, _STREAM_BOUNDARY, strlen(_STREAM_BOUNDARY));\n }\n if(fb){\n esp_camera_fb_return(fb);\n fb = NULL;\n _jpg_buf = NULL;\n } else if(_jpg_buf){\n free(_jpg_buf);\n _jpg_buf = NULL;\n }\n if(res != ESP_OK){\n break;\n }\n }\n return res;\n}\nvoid startCameraServer(){\n httpd_config_t config = HTTPD_DEFAULT_CONFIG();\n config.server_port = 80;\n httpd_uri_t index_uri = {\n .uri = "/",\n .method = HTTP_GET,\n .handler = stream_handler,\n .user_ctx = NULL\n };\n if (httpd_start(&stream_httpd, &config) == ESP_OK) {\n httpd_register_uri_handler(stream_httpd, &index_uri);\n } \n}\n';
generator.definitions_['esp_camera'] = '#include "esp_camera.h"\n#include <WiFi.h>\n#include "esp_timer.h"\n#include "img_converters.h"\n#include <Arduino.h>\n#include "fb_gfx.h"\n#include "soc/soc.h"\n#include "soc/rtc_cntl_reg.h"\n#include "dl_lib.h"\n#include "esp_http_server.h"\nconst char*wif_ssid = ' + wifi_ssid + ';\nconst char*wif_password = ' + wifi_pass + ';\n#define PART_BOUNDARY "123456789000000000000987654321"\n#define PWDN_GPIO_NUM 32\n#define RESET_GPIO_NUM -1\n#define XCLK_GPIO_NUM 0\n#define SIOD_GPIO_NUM 26\n#define SIOC_GPIO_NUM 27\n#define Y9_GPIO_NUM 35\n#define Y8_GPIO_NUM 34\n#define Y7_GPIO_NUM 39\n#define Y6_GPIO_NUM 36\n#define Y5_GPIO_NUM 21\n#define Y4_GPIO_NUM 19\n#define Y3_GPIO_NUM 18\n#define Y2_GPIO_NUM 5\n#define VSYNC_GPIO_NUM 25\n#define HREF_GPIO_NUM 23\n#define PCLK_GPIO_NUM 22\nstatic const char* _STREAM_CONTENT_TYPE = "multipart/x-mixed-replace;boundary=" PART_BOUNDARY;\nstatic const char* _STREAM_BOUNDARY = "\\r\\n--" PART_BOUNDARY "\\r\\n";\nstatic const char* _STREAM_PART = "Content-Type: image/jpeg\\r\\nContent-Length: %u\\r\\n\\r\\n";\nhttpd_handle_t stream_httpd = NULL;\nstatic esp_err_t stream_handler(httpd_req_t *req){\n camera_fb_t * fb = NULL;\n esp_err_t res = ESP_OK;\n size_t _jpg_buf_len = 0;\n uint8_t * _jpg_buf = NULL;\n char * part_buf[64];\n res = httpd_resp_set_type(req, _STREAM_CONTENT_TYPE);\n if(res != ESP_OK){\n return res;\n }\n while(true){\n fb = esp_camera_fb_get();\n if (!fb) {\n Serial.println("Camera capture failed");\n res = ESP_FAIL;\n } else {\n if(fb->width > 400){\n if(fb->format != PIXFORMAT_JPEG){\n bool jpeg_converted = frame2jpg(fb, 80, &_jpg_buf, &_jpg_buf_len);\n esp_camera_fb_return(fb);\n fb = NULL;\n if(!jpeg_converted){\n Serial.println("JPEG compression failed");\n res = ESP_FAIL;\n }\n } else {\n _jpg_buf_len = fb->len;\n _jpg_buf = fb->buf;\n }\n }\n }\n if(res == ESP_OK){\n size_t hlen = snprintf((char *)part_buf, 64, _STREAM_PART, _jpg_buf_len);\n res = httpd_resp_send_chunk(req, (const char *)part_buf, hlen);\n }\n if(res == ESP_OK){\n res = httpd_resp_send_chunk(req, (const char *)_jpg_buf, _jpg_buf_len);\n }\n if(res == ESP_OK){\n res = httpd_resp_send_chunk(req, _STREAM_BOUNDARY, strlen(_STREAM_BOUNDARY));\n }\n if(fb){\n esp_camera_fb_return(fb);\n fb = NULL;\n _jpg_buf = NULL;\n } else if(_jpg_buf){\n free(_jpg_buf);\n _jpg_buf = NULL;\n }\n if(res != ESP_OK){\n break;\n }\n }\n return res;\n}\nvoid startCameraServer(){\n httpd_config_t config = HTTPD_DEFAULT_CONFIG();\n config.server_port = 80;\n httpd_uri_t index_uri = {\n .uri = "/",\n .method = HTTP_GET,\n .handler = stream_handler,\n .user_ctx = NULL\n };\n if (httpd_start(&stream_httpd, &config) == ESP_OK) {\n httpd_register_uri_handler(stream_httpd, &index_uri);\n } \n}\n';
generator.setups_['setups_esp_camera'] = ' WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);\n Serial.begin(115200);\n Serial.setDebugOutput(false);\n camera_config_t config;\n config.ledc_channel = LEDC_CHANNEL_0;\n config.ledc_timer = LEDC_TIMER_0;\n config.pin_d0 = Y2_GPIO_NUM;\n config.pin_d1 = Y3_GPIO_NUM;\n config.pin_d2 = Y4_GPIO_NUM;\n config.pin_d3 = Y5_GPIO_NUM;\n config.pin_d4 = Y6_GPIO_NUM;\n config.pin_d5 = Y7_GPIO_NUM;\n config.pin_d6 = Y8_GPIO_NUM;\n config.pin_d7 = Y9_GPIO_NUM;\n config.pin_xclk = XCLK_GPIO_NUM;\n config.pin_pclk = PCLK_GPIO_NUM;\n config.pin_vsync = VSYNC_GPIO_NUM;\n config.pin_href = HREF_GPIO_NUM;\n config.pin_sscb_sda = SIOD_GPIO_NUM;\n config.pin_sscb_scl = SIOC_GPIO_NUM;\n config.pin_pwdn = PWDN_GPIO_NUM;\n config.pin_reset = RESET_GPIO_NUM;\n config.xclk_freq_hz = 20000000;\n config.pixel_format = PIXFORMAT_JPEG; \n if(psramFound()){\n config.frame_size = FRAMESIZE_UXGA;\n config.jpeg_quality = 10;\n config.fb_count = 2;\n } else {\n config.frame_size = FRAMESIZE_SVGA;\n config.jpeg_quality = 12;\n config.fb_count = 1;\n }\n esp_err_t err = esp_camera_init(&config);\n if (err != ESP_OK) {\n Serial.printf("Camera init failed with error 0x%x", err);\n return;\n }\n ' + code + ' startCameraServer();\n';
return 'delay(1);\n';
};
@@ -853,13 +853,13 @@ export const esp_camera_blynk = function (_, generator) {
generator.definitions_['include_TimeLib'] = '#include <TimeLib.h>';
generator.definitions_['var_declare_auth_key'] = 'char auth[] = ' + auth + ';';
generator.definitions_['esp_camera'] = '#include "esp_camera.h"\n#include "esp_timer.h"\n#include "img_converters.h"\n#include "generator.h"\n#include "fb_gfx.h"\n#include "soc/soc.h"\n#include "soc/rtc_cntl_reg.h"\n#include "dl_lib.h"\n#include "esp_http_server.h"\nconst char*wif_ssid = ' + wifi_ssid + ';\nconst char*wif_password = ' + wifi_pass + ';\n#define PART_BOUNDARY "123456789000000000000987654321"\n#define PWDN_GPIO_NUM 32\n#define RESET_GPIO_NUM -1\n#define XCLK_GPIO_NUM 0\n#define SIOD_GPIO_NUM 26\n#define SIOC_GPIO_NUM 27\n#define Y9_GPIO_NUM 35\n#define Y8_GPIO_NUM 34\n#define Y7_GPIO_NUM 39\n#define Y6_GPIO_NUM 36\n#define Y5_GPIO_NUM 21\n#define Y4_GPIO_NUM 19\n#define Y3_GPIO_NUM 18\n#define Y2_GPIO_NUM 5\n#define VSYNC_GPIO_NUM 25\n#define HREF_GPIO_NUM 23\n#define PCLK_GPIO_NUM 22\nstatic const char* _STREAM_CONTENT_TYPE = "multipart/x-mixed-replace;boundary=" PART_BOUNDARY;\nstatic const char* _STREAM_BOUNDARY = "\\r\\n--" PART_BOUNDARY "\\r\\n";\nstatic const char* _STREAM_PART = "Content-Type: image/jpeg\\r\\nContent-Length: %u\\r\\n\\r\\n";\nhttpd_handle_t stream_httpd = NULL;\nstatic esp_err_t stream_handler(httpd_req_t *req){\n camera_fb_t * fb = NULL;\n esp_err_t res = ESP_OK;\n size_t _jpg_buf_len = 0;\n uint8_t * _jpg_buf = NULL;\n char * part_buf[64];\n res = httpd_resp_set_type(req, _STREAM_CONTENT_TYPE);\n if(res != ESP_OK){\n return res;\n }\n while(true){\n fb = esp_camera_fb_get();\n if (!fb) {\n Serial.println("Camera capture failed");\n res = ESP_FAIL;\n } else {\n if(fb->width > 400){\n if(fb->format != PIXFORMAT_JPEG){\n bool jpeg_converted = frame2jpg(fb, 80, &_jpg_buf, &_jpg_buf_len);\n esp_camera_fb_return(fb);\n fb = NULL;\n if(!jpeg_converted){\n Serial.println("JPEG compression failed");\n res = ESP_FAIL;\n }\n } else {\n _jpg_buf_len = fb->len;\n _jpg_buf = fb->buf;\n }\n }\n }\n if(res == ESP_OK){\n size_t hlen = snprintf((char *)part_buf, 64, _STREAM_PART, _jpg_buf_len);\n res = httpd_resp_send_chunk(req, (const char *)part_buf, hlen);\n }\n if(res == ESP_OK){\n res = httpd_resp_send_chunk(req, (const char *)_jpg_buf, _jpg_buf_len);\n }\n if(res == ESP_OK){\n res = httpd_resp_send_chunk(req, _STREAM_BOUNDARY, strlen(_STREAM_BOUNDARY));\n }\n if(fb){\n esp_camera_fb_return(fb);\n fb = NULL;\n _jpg_buf = NULL;\n } else if(_jpg_buf){\n free(_jpg_buf);\n _jpg_buf = NULL;\n }\n if(res != ESP_OK){\n break;\n }\n }\n return res;\n}\nvoid startCameraServer(){\n httpd_config_t config = HTTPD_DEFAULT_CONFIG();\n config.server_port = 80;\n httpd_uri_t index_uri = {\n .uri = "/",\n .method = HTTP_GET,\n .handler = stream_handler,\n .user_ctx = NULL\n };\n if (httpd_start(&stream_httpd, &config) == ESP_OK) {\n httpd_register_uri_handler(stream_httpd, &index_uri);\n } \n}\n';
generator.definitions_['esp_camera'] = '#include "esp_camera.h"\n#include "esp_timer.h"\n#include "img_converters.h"\n#include <Arduino.h>\n#include "fb_gfx.h"\n#include "soc/soc.h"\n#include "soc/rtc_cntl_reg.h"\n#include "dl_lib.h"\n#include "esp_http_server.h"\nconst char*wif_ssid = ' + wifi_ssid + ';\nconst char*wif_password = ' + wifi_pass + ';\n#define PART_BOUNDARY "123456789000000000000987654321"\n#define PWDN_GPIO_NUM 32\n#define RESET_GPIO_NUM -1\n#define XCLK_GPIO_NUM 0\n#define SIOD_GPIO_NUM 26\n#define SIOC_GPIO_NUM 27\n#define Y9_GPIO_NUM 35\n#define Y8_GPIO_NUM 34\n#define Y7_GPIO_NUM 39\n#define Y6_GPIO_NUM 36\n#define Y5_GPIO_NUM 21\n#define Y4_GPIO_NUM 19\n#define Y3_GPIO_NUM 18\n#define Y2_GPIO_NUM 5\n#define VSYNC_GPIO_NUM 25\n#define HREF_GPIO_NUM 23\n#define PCLK_GPIO_NUM 22\nstatic const char* _STREAM_CONTENT_TYPE = "multipart/x-mixed-replace;boundary=" PART_BOUNDARY;\nstatic const char* _STREAM_BOUNDARY = "\\r\\n--" PART_BOUNDARY "\\r\\n";\nstatic const char* _STREAM_PART = "Content-Type: image/jpeg\\r\\nContent-Length: %u\\r\\n\\r\\n";\nhttpd_handle_t stream_httpd = NULL;\nstatic esp_err_t stream_handler(httpd_req_t *req){\n camera_fb_t * fb = NULL;\n esp_err_t res = ESP_OK;\n size_t _jpg_buf_len = 0;\n uint8_t * _jpg_buf = NULL;\n char * part_buf[64];\n res = httpd_resp_set_type(req, _STREAM_CONTENT_TYPE);\n if(res != ESP_OK){\n return res;\n }\n while(true){\n fb = esp_camera_fb_get();\n if (!fb) {\n Serial.println("Camera capture failed");\n res = ESP_FAIL;\n } else {\n if(fb->width > 400){\n if(fb->format != PIXFORMAT_JPEG){\n bool jpeg_converted = frame2jpg(fb, 80, &_jpg_buf, &_jpg_buf_len);\n esp_camera_fb_return(fb);\n fb = NULL;\n if(!jpeg_converted){\n Serial.println("JPEG compression failed");\n res = ESP_FAIL;\n }\n } else {\n _jpg_buf_len = fb->len;\n _jpg_buf = fb->buf;\n }\n }\n }\n if(res == ESP_OK){\n size_t hlen = snprintf((char *)part_buf, 64, _STREAM_PART, _jpg_buf_len);\n res = httpd_resp_send_chunk(req, (const char *)part_buf, hlen);\n }\n if(res == ESP_OK){\n res = httpd_resp_send_chunk(req, (const char *)_jpg_buf, _jpg_buf_len);\n }\n if(res == ESP_OK){\n res = httpd_resp_send_chunk(req, _STREAM_BOUNDARY, strlen(_STREAM_BOUNDARY));\n }\n if(fb){\n esp_camera_fb_return(fb);\n fb = NULL;\n _jpg_buf = NULL;\n } else if(_jpg_buf){\n free(_jpg_buf);\n _jpg_buf = NULL;\n }\n if(res != ESP_OK){\n break;\n }\n }\n return res;\n}\nvoid startCameraServer(){\n httpd_config_t config = HTTPD_DEFAULT_CONFIG();\n config.server_port = 80;\n httpd_uri_t index_uri = {\n .uri = "/",\n .method = HTTP_GET,\n .handler = stream_handler,\n .user_ctx = NULL\n };\n if (httpd_start(&stream_httpd, &config) == ESP_OK) {\n httpd_register_uri_handler(stream_httpd, &index_uri);\n } \n}\n';
generator.setups_['setups_esp_camera'] = 'WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);\n Serial.begin(115200);\n Serial.setDebugOutput(false);\n camera_config_t config;\n config.ledc_channel = LEDC_CHANNEL_0;\n config.ledc_timer = LEDC_TIMER_0;\n config.pin_d0 = Y2_GPIO_NUM;\n config.pin_d1 = Y3_GPIO_NUM;\n config.pin_d2 = Y4_GPIO_NUM;\n config.pin_d3 = Y5_GPIO_NUM;\n config.pin_d4 = Y6_GPIO_NUM;\n config.pin_d5 = Y7_GPIO_NUM;\n config.pin_d6 = Y8_GPIO_NUM;\n config.pin_d7 = Y9_GPIO_NUM;\n config.pin_xclk = XCLK_GPIO_NUM;\n config.pin_pclk = PCLK_GPIO_NUM;\n config.pin_vsync = VSYNC_GPIO_NUM;\n config.pin_href = HREF_GPIO_NUM;\n config.pin_sscb_sda = SIOD_GPIO_NUM;\n config.pin_sscb_scl = SIOC_GPIO_NUM;\n config.pin_pwdn = PWDN_GPIO_NUM;\n config.pin_reset = RESET_GPIO_NUM;\n config.xclk_freq_hz = 20000000;\n config.pixel_format = PIXFORMAT_JPEG; \n if(psramFound()){\n config.frame_size = FRAMESIZE_UXGA;\n config.jpeg_quality = 10;\n config.fb_count = 2;\n } else {\n config.frame_size = FRAMESIZE_SVGA;\n config.jpeg_quality = 12;\n config.fb_count = 1;\n }\n esp_err_t err = esp_camera_init(&config);\n if (err != ESP_OK) {\n Serial.printf("Camera init failed with error 0x%x", err);\n return;\n }\n WiFi.begin(wif_ssid,wif_password);\n while (WiFi.status() != WL_CONNECTED) {\n delay(500);\n Serial.print(".");\n }\n Serial.println("");\n Serial.println("WiFi connected");\n Serial.print("Camera Stream Ready! Go to: http://");\n Serial.print(WiFi.localIP());\n Serial.println("");\n startCameraServer();\n Blynk.config(auth,' + server_add + ',8080);\n';
return 'Blynk.run();\n';
};
export const take_a_photo1 = function (_, generator) {
generator.definitions_['take_a_photo'] = '#include "esp_camera.h"\n#include "esp_timer.h"\n#include "img_converters.h"\n#include "generator.h"\n#include "fb_gfx.h"\n#include "fd_forward.h"\n#include "fr_forward.h"\n#include "FS.h" \n#include "SD_MMC.h" \n#include "soc/soc.h"\n#include "soc/rtc_cntl_reg.h" \n#include "dl_lib.h"\n#include "driver/rtc_io.h"\n#include <EEPROM.h>\n#define EEPROM_SIZE 1\n#define PWDN_GPIO_NUM 32\n#define RESET_GPIO_NUM -1\n#define XCLK_GPIO_NUM 0\n#define SIOD_GPIO_NUM 26\n#define SIOC_GPIO_NUM 27\n#define Y9_GPIO_NUM 35\n#define Y8_GPIO_NUM 34\n#define Y7_GPIO_NUM 39\n#define Y6_GPIO_NUM 36\n#define Y5_GPIO_NUM 21\n#define Y4_GPIO_NUM 19\n#define Y3_GPIO_NUM 18\n#define Y2_GPIO_NUM 5\n#define VSYNC_GPIO_NUM 25\n#define HREF_GPIO_NUM 23\n#define PCLK_GPIO_NUM 22\nint pictureNumber = 0;\n';
generator.definitions_['take_a_photo'] = '#include "esp_camera.h"\n#include "esp_timer.h"\n#include "img_converters.h"\n#include <Arduino.h>\n#include "fb_gfx.h"\n#include "fd_forward.h"\n#include "fr_forward.h"\n#include "FS.h" \n#include "SD_MMC.h" \n#include "soc/soc.h"\n#include "soc/rtc_cntl_reg.h" \n#include "dl_lib.h"\n#include "driver/rtc_io.h"\n#include <EEPROM.h>\n#define EEPROM_SIZE 1\n#define PWDN_GPIO_NUM 32\n#define RESET_GPIO_NUM -1\n#define XCLK_GPIO_NUM 0\n#define SIOD_GPIO_NUM 26\n#define SIOC_GPIO_NUM 27\n#define Y9_GPIO_NUM 35\n#define Y8_GPIO_NUM 34\n#define Y7_GPIO_NUM 39\n#define Y6_GPIO_NUM 36\n#define Y5_GPIO_NUM 21\n#define Y4_GPIO_NUM 19\n#define Y3_GPIO_NUM 18\n#define Y2_GPIO_NUM 5\n#define VSYNC_GPIO_NUM 25\n#define HREF_GPIO_NUM 23\n#define PCLK_GPIO_NUM 22\nint pictureNumber = 0;\n';
let code = 'WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);\nSerial.begin(115200);\ncamera_config_t config;\nconfig.ledc_channel = LEDC_CHANNEL_0;\nconfig.ledc_timer = LEDC_TIMER_0;\nconfig.pin_d0 = Y2_GPIO_NUM;\nconfig.pin_d1 = Y3_GPIO_NUM;\nconfig.pin_d2 = Y4_GPIO_NUM;\nconfig.pin_d3 = Y5_GPIO_NUM;\nconfig.pin_d4 = Y6_GPIO_NUM;\nconfig.pin_d5 = Y7_GPIO_NUM;\nconfig.pin_d6 = Y8_GPIO_NUM;\nconfig.pin_d7 = Y9_GPIO_NUM;\nconfig.pin_xclk = XCLK_GPIO_NUM;\nconfig.pin_pclk = PCLK_GPIO_NUM;\nconfig.pin_vsync = VSYNC_GPIO_NUM;\nconfig.pin_href = HREF_GPIO_NUM;\nconfig.pin_sscb_sda = SIOD_GPIO_NUM;\nconfig.pin_sscb_scl = SIOC_GPIO_NUM;\nconfig.pin_pwdn = PWDN_GPIO_NUM;\nconfig.pin_reset = RESET_GPIO_NUM;\nconfig.xclk_freq_hz = 20000000;\nconfig.pixel_format = PIXFORMAT_JPEG; \nif(psramFound()){\n config.frame_size = FRAMESIZE_UXGA;\n config.jpeg_quality = 10;\n config.fb_count = 2;\n} else {\n config.frame_size = FRAMESIZE_SVGA;\n config.jpeg_quality = 12;\n config.fb_count = 1;\n}\nesp_err_t err = esp_camera_init(&config);\nif (err != ESP_OK) {\n Serial.printf("Camera init failed with error 0x%x", err);\n return;\n}\nif(!SD_MMC.begin()){\n Serial.println("SD Card Mount Failed");\n return;\n}\nuint8_t cardType = SD_MMC.cardType();\nif(cardType == CARD_NONE){\n Serial.println("No SD Card attached");\n return;\n}\ncamera_fb_t * fb = NULL;\nfb = esp_camera_fb_get();\nif(!fb) {\n Serial.println("Camera capture failed");\n return;\n}\nEEPROM.begin(EEPROM_SIZE);\npictureNumber = EEPROM.read(0) + 1;\nString path = "/picture" + String(pictureNumber) +".jpg";\nfs::FS &fs = SD_MMC; \nSerial.printf("Picture file name: %s\\n", path.c_str());\nFile file = fs.open(path.c_str(), FILE_WRITE);\nif(!file){\n Serial.println("Failed to open file in writing mode");\n} \nelse {\n file.write(fb->buf, fb->len);\n Serial.printf("Saved file to path: %s\\n", path.c_str());\n EEPROM.write(0, pictureNumber);\n EEPROM.commit();\n}\nfile.close();\nesp_camera_fb_return(fb); \npinMode(4, OUTPUT);\ndigitalWrite(4, LOW);\nrtc_gpio_hold_en(GPIO_NUM_4);\n';
return code;
};

View File

@@ -255,7 +255,7 @@ export const ADS1015_Get_Value = function (_, generator) {
// PCF8591T模数转换模块 采集数值
export const PCF8591T = function (_, generator) {
//generator.definitions_['include_Wire'] = '#include "generator.h"';
//generator.definitions_['include_Wire'] = '#include <Arduino.h>';
generator.definitions_['include_PCF8591_h'] = '#include <PCF8591.h>';
generator.definitions_['var_declare_PCF8591'] = 'PCF8591 pcf8591(0x48);';
generator.setups_['setup_pcf8591.begin()'] = 'pcf8591.begin(); \n';