main_entry.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #include "iot_boardled.h"
  2. #include "iot_boardbutton.h"
  3. #include "iot_sntp.h"
  4. #include "ohos_init.h"
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <ctype.h>
  8. #include <stdlib.h>
  9. #include <unistd.h>
  10. #include <stdbool.h>
  11. #include "red.h"
  12. #include <math.h>
  13. #include "iot_gpio.h"
  14. void EntryMain(void)
  15. {
  16. float ad_value1;
  17. float ad_value2;
  18. BoardInit();
  19. osDelay(100);
  20. printf("=================================================\r\n");
  21. printf("************* human_detect_example ***********\r\n");
  22. printf("=================================================\r\n");
  23. for(;;)
  24. {
  25. float tempNTC;
  26. float tempTP;
  27. IoTGpioSetOutputVal (12,1);
  28. osDelay(50);
  29. ad_value1 = GetVoltage();
  30. tempNTC = TEMP1();
  31. printf("+++***@@@ ad_value is %fV\r\n",ad_value1);
  32. IoTGpioSetOutputVal (12,0);
  33. osDelay(50);
  34. ad_value2 = GetVoltage();
  35. tempTP = HUMAN();
  36. printf("+++***@@@ ad_value2 is %fV\r\n",ad_value2);
  37. printf("ntc temp = %f \n",tempNTC);
  38. printf("tp temp = %f \n",tempTP);
  39. if (tempTP > 38) {
  40. BeepStatusSet(ON);
  41. LedSafeStatusSet(OFF);
  42. LedWarnStatusSet(ON);
  43. }else{
  44. BeepStatusSet(OFF);
  45. LedSafeStatusSet(ON);
  46. LedWarnStatusSet(OFF);
  47. }
  48. printf("human temp is %d\r\n",tempTP);
  49. osDelay(100);
  50. }
  51. }
  52. APP_FEATURE_INIT(EntryMain);