selfcheck.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2024-09-29 Administrator the first version
  9. */
  10. #include <rtthread.h>
  11. #include <cJSON.h>
  12. #include <control.h>
  13. #include "selfcheck.h"
  14. #include <hmi.h>
  15. #include <dtu_uart2.h>
  16. #include <sht30_collect.h>
  17. #define DBG_ENABLE
  18. #define DBG_COLOR
  19. #define DBG_TAG "selfcheck"
  20. #define DBG_LEVEL DBG_LOG
  21. #include <rtdbg.h> //must after of DBG_LVL, DBG_TAG or other options
  22. rt_timer_t timer_takephoto = RT_NULL;
  23. Device_Status_typedef device_status;
  24. static int calculate_average(int arr[], int n) {
  25. int sum = 0; // 用于存储数组元素的总和
  26. for (int i = 0; i < n; i++) {
  27. sum += arr[i]; // 累加每个元素
  28. }
  29. // 计算平均值
  30. int average = sum / n; // 强制类型转换确保得到浮点数结果
  31. return average;
  32. }
  33. static void t_takephoto_callback(void *parameter)
  34. {
  35. // rt_timer_delete(timer_takephoto);
  36. LOG_E("拍照超时!");
  37. device_status.C01 |= (1<<2); //拍照故障
  38. device_status.C01 |= (1<<3); //补光灯故障
  39. HMI_WRITE("selfcheck.t4.bco=63488");
  40. HMI_WRITE("selfcheck.t3.bco=63488");
  41. HMI_WRITE("sysSet.va0.txt=\"拍照超时\"");
  42. }
  43. int selfcheck(uint8_t type)
  44. {
  45. return 0;
  46. }
  47. //int rt_software_timer_init(void)
  48. //{
  49. // //启动拍照超时定时器
  50. // timer_takephoto = rt_timer_create("t_takephoto",t_takephoto_callback,RT_NULL, 100000, RT_TIMER_FLAG_ONE_SHOT|RT_TIMER_FLAG_HARD_TIMER);
  51. // if(timer_takephoto==RT_NULL)
  52. // {
  53. // LOG_E("rt_timer_create t_takephoto failed!");
  54. // return RT_ERROR;
  55. // }
  56. // else
  57. // {
  58. // return RT_EOK;
  59. // }
  60. //}
  61. //INIT_APP_EXPORT(rt_software_timer_init);