app_overturn.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #include "usr_config.h"
  2. #include "hal_battery.h"
  3. #include "nrf_drv_saadc.h"
  4. #include "bsp_time.h"
  5. #include "system.h"
  6. #include "hal_led.h"
  7. #include "hal_imu.h"
  8. #include "app_overturn.h"
  9. #include "app_wearshoes.h"
  10. #define acc0Value 3000
  11. #define acc1iValue -1600
  12. #define acc1aValue 0
  13. #define acc2iValue -1500
  14. #define acc2aValue 400
  15. /************************ 追신鞫刻든좆 ***********************************/
  16. static uint8_t flag_move =0;
  17. //void app_BatDispaly_Process_N(void)
  18. //{
  19. // int16_t acc[3];
  20. // static uint32_t cnt = 0;
  21. //
  22. // if(app_wearshoes_is_wearshoes()>0) return;//界岺榴檄
  23. //
  24. // IMU_Get_Index_Front_Low_Power_Data(acc, NULL, NULL, IMU_Get_Front_Low_Power_Data_GroupNum());
  25. //// SEGGER_RTT_printf(0,"0:acc[0]=%d,acc[1]=%d,acc[2]=%d\n",acc[0],acc[1],acc[2]);
  26. // if(acc[2] > acc1iValue){
  27. // cnt++;
  28. // if(cnt==1){
  29. // if(GetBatteryPersent()>20){
  30. // LED_SetColor(LED_OVERTURN,COLOR_GREEN);
  31. // }else{
  32. // LED_SetColor(LED_OVERTURN,COLOR_RED);
  33. // }
  34. // LED_Start(LED_OVERTURN);
  35. // Process_SetHoldOn(app_BatDispaly_Process_N,1);
  36. // }
  37. // if(cnt==100){
  38. // LED_Stop(LED_OVERTURN);
  39. // Process_SetHoldOn(app_BatDispaly_Process_N,0);
  40. // }
  41. // }else{
  42. // if(cnt>0){ cnt = 0;
  43. // LED_Stop(LED_OVERTURN);
  44. // Process_SetHoldOn(app_BatDispaly_Process_N,0);
  45. // }
  46. // if(flag_move == 1){
  47. // flag_move =0;
  48. // LED_Stop(LED_OVERTURN);
  49. // Process_SetHoldOn(app_BatDispaly_Process_N,0);
  50. // }
  51. // }
  52. //}
  53. //void app_BatDispaly_Process(void)
  54. //{
  55. // int16_t acc[3];
  56. // static uint32_t cnt = 0;
  57. // static int16_t acc0 = acc0Value;
  58. // static int16_t acc1i = acc1iValue;
  59. // static int16_t acc1a = acc1aValue;
  60. // static int16_t acc2i = acc2iValue;
  61. // static int16_t acc2a = acc2aValue;
  62. //
  63. // if(1 == IMU_GetSensorEnable()) {
  64. // LED_Stop(LED_OVERTURN);
  65. // return;//
  66. // }
  67. // if(app_wearshoes_is_wearshoes()==0) return;//浬쨌榴檄
  68. //
  69. // IMU_Get_Index_Front_Low_Power_Data(acc, NULL, NULL, IMU_Get_Front_Low_Power_Data_GroupNum());
  70. //// SEGGER_RTT_printf(0,"1:acc[0]=%d,acc[1]=%d,acc[2]=%d\n",acc[0],acc[1],acc[2]);
  71. // if(acc[0] < acc0 && acc[1] > acc1i && acc[1] < acc1a && acc[2] < acc2a && acc[2] > acc2i){
  72. // cnt++;
  73. // if(cnt==10){
  74. // if(GetBatteryPersent()>20){
  75. // LED_SetColor(LED_OVERTURN,COLOR_GREEN);
  76. // }else{
  77. // LED_SetColor(LED_OVERTURN,COLOR_RED);
  78. // }
  79. // LED_Start(LED_OVERTURN);
  80. // Process_SetHoldOn(app_BatDispaly_Process,1);
  81. // acc0 = acc0Value;
  82. // acc1i = acc1iValue;
  83. // acc1a = acc1aValue;
  84. // acc2i = acc2iValue;
  85. // acc2a = acc2aValue;
  86. // }
  87. // if(cnt==100){
  88. // LED_Stop(LED_OVERTURN);
  89. // Process_SetHoldOn(app_BatDispaly_Process,0);
  90. // acc0 = acc0Value-200;
  91. // acc1i = acc1iValue;
  92. // acc1a = acc1aValue;
  93. // acc2i = acc2iValue;
  94. // acc2a = acc2aValue;
  95. // }
  96. // }else{
  97. // if(cnt>0){ cnt = 0;
  98. // LED_Stop(LED_OVERTURN);
  99. // Process_SetHoldOn(app_BatDispaly_Process,0);
  100. // acc0 = acc0Value;
  101. // acc1i = acc1iValue;
  102. // acc1a = acc1aValue;
  103. // acc2i = acc2iValue;
  104. // acc2a = acc2aValue;
  105. // }
  106. // if(flag_move == 0){
  107. // flag_move =1;
  108. // LED_Stop(LED_OVERTURN);
  109. // Process_SetHoldOn(app_BatDispaly_Process,0);
  110. // acc0 = acc0Value;
  111. // acc1i = acc1iValue;
  112. // acc1a = acc1aValue;
  113. // acc2i = acc2iValue;
  114. // acc2a = acc2aValue;
  115. // }
  116. // }
  117. //}
  118. void app_overturn_Init(void)
  119. {
  120. // Process_Start(100,"BatDispaly",app_BatDispaly_Process);
  121. // Process_Start(100,"BatDispaly_N",app_BatDispaly_Process_N);
  122. }