defines.h 8.9 KB

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