defines.h 8.1 KB

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