defines.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. #pragma once
  2. #ifndef defines_h
  3. #define defines_h
  4. /////////////////////////////////////////////
  5. //// Global definitions ////
  6. /////////////////////////////////////////////
  7. /* Uncomment this to generate task list with stack sizes using the /heap handler
  8. PLEASE BE AWARE: The following CONFIG parameters have to to be set in
  9. sdkconfig.defaults before use of this function is possible!!
  10. CONFIG_FREERTOS_USE_TRACE_FACILITY=1
  11. CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y
  12. CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y
  13. */
  14. // server_tflite.cpp
  15. //#define TASK_ANALYSIS_ON
  16. // ######## debug options :
  17. //#define DISABLE_BROWNOUT_DETECTOR
  18. /* Uncomment this to keep the logfile open for appending.
  19. * If commented out, the logfile gets opened/closed for each log measage (old behaviour) */
  20. // ClassLogFile
  21. //#define KEEP_LOGFILE_OPEN_FOR_APPENDING
  22. //compiler optimization for tflite-micro-esp-examples
  23. #define XTENSA
  24. //#define CONFIG_IDF_TARGET_ARCH_XTENSA //not needed with platformio/espressif32 @ 5.2.0
  25. //ClassControllCamera + ClassFlowMakeImage + connect_wlan + main
  26. #define FLASH_GPIO GPIO_NUM_4
  27. #define BLINK_GPIO GPIO_NUM_33
  28. //ClassFlowMQTT + interface_mqtt + connect_wlan + main
  29. #define __HIDE_PASSWORD
  30. //ClassControllCamera
  31. #define USE_PWM_LEDFLASH // if __LEDGLOBAL is defined, a global variable is used for LED control, otherwise locally and each time a new
  32. //server_GPIO
  33. #define __LEDGLOBAL
  34. //ClassControllCamera + ClassFlowMakeImage
  35. #define CAMERA_MODEL_AI_THINKER
  36. #define BOARD_ESP32CAM_AITHINKER
  37. //server_GPIO + server_file + SoftAP
  38. #define CONFIG_FILE "/sdcard/config/config.ini"
  39. //ClassFlowControll + Main + SoftAP
  40. #define WLAN_CONFIG_FILE "/sdcard/wlan.ini"
  41. //main
  42. #define __SD_USE_ONE_LINE_MODE__
  43. // server_file + Helper
  44. #define FILE_PATH_MAX (255) //Max length a file path can have on storage
  45. //server_file +(ota_page.html + upload_script.html)
  46. #define MAX_FILE_SIZE (8000*1024) // 8 MB Max size of an individual file. Make sure this value is same as that set in upload_script.html and ota_page.html!
  47. #define MAX_FILE_SIZE_STR "8MB"
  48. #define LOGFILE_LAST_PART_BYTES SERVER_FILER_SCRATCH_BUFSIZE * 20 // 80 kBytes // Size of partial log file to return
  49. #define SERVER_FILER_SCRATCH_BUFSIZE 4096
  50. #define SERVER_HELPER_SCRATCH_BUFSIZE 8192
  51. #define SERVER_OTA_SCRATCH_BUFSIZE 1024
  52. //server_file + server_help
  53. #define IS_FILE_EXT(filename, ext) \
  54. (strcasecmp(&filename[strlen(filename) - sizeof(ext) + 1], ext) == 0)
  55. //server_ota
  56. #define HASH_LEN 32 // SHA-256 digest length
  57. #define OTA_URL_SIZE 256
  58. //ClassFlow + ClassFlowImage + server_tflite
  59. #define LOGFILE_TIME_FORMAT "%Y%m%d-%H%M%S"
  60. #define LOGFILE_TIME_FORMAT_DATE_EXTR substr(0, 8)
  61. #define LOGFILE_TIME_FORMAT_HOUR_EXTR substr(9, 2)
  62. //ClassFlowControll
  63. #define READOUT_TYPE_VALUE 0
  64. #define READOUT_TYPE_PREVALUE 1
  65. #define READOUT_TYPE_RAWVALUE 2
  66. #define READOUT_TYPE_ERROR 3
  67. //ClassFlowMQTT
  68. #define LWT_TOPIC "connection"
  69. #define LWT_CONNECTED "connected"
  70. #define LWT_DISCONNECTED "connection lost"
  71. //ClassFlowPostProcessing
  72. #define PREVALUE_TIME_FORMAT_OUTPUT "%Y-%m-%dT%H:%M:%S%z"
  73. #define PREVALUE_TIME_FORMAT_INPUT "%d-%d-%dT%d:%d:%d"
  74. //CImageBasis
  75. #define HTTP_BUFFER_SENT 1024
  76. #define GET_MEMORY(X) heap_caps_malloc(X, MALLOC_CAP_SPIRAM)
  77. #define MAX_JPG_SIZE 128000
  78. //CAlignAndCutImage + CImageBasis
  79. #define _USE_MATH_DEFINES
  80. #define GET_MEMORY(X) heap_caps_malloc(X, MALLOC_CAP_SPIRAM)
  81. //make_stb + stb_image_resize + stb_image_write + stb_image //do not work if not in make_stb.cpp
  82. //#define STB_IMAGE_IMPLEMENTATION
  83. //#define STB_IMAGE_WRITE_IMPLEMENTATION
  84. //#define STB_IMAGE_RESIZE_IMPLEMENTATION
  85. #define STBI_ONLY_JPEG // (save 2% of Flash, but breaks the alignment mark generation, see https://github.com/jomjol/AI-on-the-edge-device/issues/1721)
  86. //interface_influxdb
  87. #define MAX_HTTP_OUTPUT_BUFFER 2048
  88. //server_mqtt
  89. #define LWT_TOPIC "connection"
  90. #define LWT_CONNECTED "connected"
  91. #define LWT_DISCONNECTED "connection lost"
  92. //CTfLiteClass
  93. #define TFLITE_MINIMAL_CHECK(x) \
  94. if (!(x)) { \
  95. fprintf(stderr, "Error at %s:%d\n", __FILE__, __LINE__); \
  96. exit(1); \
  97. }
  98. #define SUPRESS_TFLITE_ERRORS // use, to avoid error messages from TFLITE
  99. //connect_wlan
  100. #define WLAN_USE_MESH_ROAMING
  101. #define WLAN_WIFI_RSSI_THRESHOLD -50
  102. #define EXAMPLE_ESP_MAXIMUM_RETRY 1000
  103. /* The event group allows multiple bits for each event, but we only care about two events:
  104. * - we are connected to the AP with an IP
  105. * - we failed to connect after the maximum amount of retries */
  106. #define WIFI_CONNECTED_BIT BIT0
  107. #define WIFI_FAIL_BIT BIT1
  108. //ClassFlowCNNGeneral
  109. #define Analog_error 3
  110. #define AnalogToDigtalFehler 0.8
  111. #define Digital_Uncertainty 0.2
  112. #define DigitalBand 3
  113. #define Digital_Transition_Range_Predecessor 2
  114. #define Digital_Transition_Area_Predecessor 0.7 // 9.3 - 0.7
  115. #define Digital_Transition_Area_Forward 9.7 // Pre-run zero crossing only happens from approx. 9.7 onwards
  116. //#define DEBUG_DETAIL_ON
  117. /////////////////////////////////////////////
  118. //// Conditionnal definitions ////
  119. /////////////////////////////////////////////
  120. //******* camera model
  121. #if defined(CAMERA_MODEL_WROVER_KIT)
  122. #define PWDN_GPIO_NUM -1
  123. #define RESET_GPIO_NUM -1
  124. #define XCLK_GPIO_NUM 21
  125. #define SIOD_GPIO_NUM 26
  126. #define SIOC_GPIO_NUM 27
  127. #define Y9_GPIO_NUM 35
  128. #define Y8_GPIO_NUM 34
  129. #define Y7_GPIO_NUM 39
  130. #define Y6_GPIO_NUM 36
  131. #define Y5_GPIO_NUM 19
  132. #define Y4_GPIO_NUM 18
  133. #define Y3_GPIO_NUM 5
  134. #define Y2_GPIO_NUM 4
  135. #define VSYNC_GPIO_NUM 25
  136. #define HREF_GPIO_NUM 23
  137. #define PCLK_GPIO_NUM 22
  138. #elif defined(CAMERA_MODEL_M5STACK_PSRAM)
  139. #define PWDN_GPIO_NUM -1
  140. #define RESET_GPIO_NUM 15
  141. #define XCLK_GPIO_NUM 27
  142. #define SIOD_GPIO_NUM 25
  143. #define SIOC_GPIO_NUM 23
  144. #define Y9_GPIO_NUM 19
  145. #define Y8_GPIO_NUM 36
  146. #define Y7_GPIO_NUM 18
  147. #define Y6_GPIO_NUM 39
  148. #define Y5_GPIO_NUM 5
  149. #define Y4_GPIO_NUM 34
  150. #define Y3_GPIO_NUM 35
  151. #define Y2_GPIO_NUM 32
  152. #define VSYNC_GPIO_NUM 22
  153. #define HREF_GPIO_NUM 26
  154. #define PCLK_GPIO_NUM 21
  155. #elif defined(CAMERA_MODEL_AI_THINKER)
  156. #define PWDN_GPIO_NUM GPIO_NUM_32
  157. #define RESET_GPIO_NUM -1
  158. #define XCLK_GPIO_NUM GPIO_NUM_0
  159. #define SIOD_GPIO_NUM GPIO_NUM_26
  160. #define SIOC_GPIO_NUM GPIO_NUM_27
  161. #define Y9_GPIO_NUM GPIO_NUM_35
  162. #define Y8_GPIO_NUM GPIO_NUM_34
  163. #define Y7_GPIO_NUM GPIO_NUM_39
  164. #define Y6_GPIO_NUM GPIO_NUM_36
  165. #define Y5_GPIO_NUM GPIO_NUM_21
  166. #define Y4_GPIO_NUM GPIO_NUM_19
  167. #define Y3_GPIO_NUM GPIO_NUM_18
  168. #define Y2_GPIO_NUM GPIO_NUM_5
  169. #define VSYNC_GPIO_NUM GPIO_NUM_25
  170. #define HREF_GPIO_NUM GPIO_NUM_23
  171. #define PCLK_GPIO_NUM GPIO_NUM_22
  172. #else
  173. #error "Camera model not selected"
  174. #endif //camera model
  175. // ******* Board type
  176. #ifdef BOARD_WROVER_KIT // WROVER-KIT PIN Map
  177. #define CAM_PIN_PWDN -1 //power down is not used
  178. #define CAM_PIN_RESET -1 //software reset will be performed
  179. #define CAM_PIN_XCLK 21
  180. #define CAM_PIN_SIOD 26
  181. #define CAM_PIN_SIOC 27
  182. #define CAM_PIN_D7 35
  183. #define CAM_PIN_D6 34
  184. #define CAM_PIN_D5 39
  185. #define CAM_PIN_D4 36
  186. #define CAM_PIN_D3 19
  187. #define CAM_PIN_D2 18
  188. #define CAM_PIN_D1 5
  189. #define CAM_PIN_D0 4
  190. #define CAM_PIN_VSYNC 25
  191. #define CAM_PIN_HREF 23
  192. #define CAM_PIN_PCLK 22
  193. #endif //// WROVER-KIT PIN Map
  194. #ifdef BOARD_ESP32CAM_AITHINKER // ESP32Cam (AiThinker) PIN Map
  195. #define CAM_PIN_PWDN 32
  196. #define CAM_PIN_RESET -1 //software reset will be performed
  197. #define CAM_PIN_XCLK 0
  198. #define CAM_PIN_SIOD 26
  199. #define CAM_PIN_SIOC 27
  200. #define CAM_PIN_D7 35
  201. #define CAM_PIN_D6 34
  202. #define CAM_PIN_D5 39
  203. #define CAM_PIN_D4 36
  204. #define CAM_PIN_D3 21
  205. #define CAM_PIN_D2 19
  206. #define CAM_PIN_D1 18
  207. #define CAM_PIN_D0 5
  208. #define CAM_PIN_VSYNC 25
  209. #define CAM_PIN_HREF 23
  210. #define CAM_PIN_PCLK 22
  211. #endif // ESP32Cam (AiThinker) PIN Map
  212. // ******* LED definition
  213. #ifdef USE_PWM_LEDFLASH
  214. //// PWM für Flash-LED
  215. #define LEDC_TIMER LEDC_TIMER_1 // LEDC_TIMER_0
  216. #define LEDC_MODE LEDC_LOW_SPEED_MODE
  217. #define LEDC_OUTPUT_IO FLASH_GPIO // Define the output GPIO
  218. #define LEDC_CHANNEL LEDC_CHANNEL_1
  219. #define LEDC_DUTY_RES LEDC_TIMER_13_BIT // Set duty resolution to 13 bits
  220. //#define LEDC_DUTY (195) // Set duty to 50%. ((2 ** 13) - 1) * 50% = 4095
  221. #define LEDC_FREQUENCY (5000) // Frequency in Hertz. Set frequency at 5 kHz
  222. #endif //USE_PWM_LEDFLASH
  223. //softAP
  224. #ifdef ENABLE_SOFTAP
  225. #define EXAMPLE_ESP_WIFI_SSID "AI-on-the-Edge"
  226. #define EXAMPLE_ESP_WIFI_PASS ""
  227. #define EXAMPLE_ESP_WIFI_CHANNEL 11
  228. #define EXAMPLE_MAX_STA_CONN 1
  229. #endif // ENABLE_SOFTAP
  230. #endif // ifndef defines_h