encoder_interface.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #include "interface/encoder_interface.h"
  2. typedef void (* motion_function_t)(void);
  3. typedef struct {
  4. os_timer_t motion_timer;
  5. uint32_t motion_timeout;
  6. motion_function_t motion_cb;
  7. uint32_t vcell;
  8. uint32_t soc;
  9. os_timer_t battery_timer;
  10. uint32_t battery_timeout;
  11. } Encoder_t;
  12. typedef struct {
  13. uint32_t vcell;
  14. uint32_t motion;
  15. } Encoder_Battery_t;
  16. static Encoder_t encoder;
  17. void ICACHE_FLASH_ATTR Encoder_Shutdown(void)
  18. {
  19. Light_Shutdown();
  20. IO_Shutdown();
  21. //system_deep_sleep(0);
  22. }
  23. void ICACHE_FLASH_ATTR Encoder_Restart(void)
  24. {
  25. Light_Restart();
  26. system_restart();
  27. }
  28. /* Motion Functions */
  29. void ICACHE_FLASH_ATTR Encoder_MotionSetCallback(motion_function_t motion_cb)
  30. {
  31. encoder.motion_cb = motion_cb;
  32. os_timer_setfn(&encoder.motion_timer, (os_timer_func_t *)encoder.motion_cb, NULL);
  33. }
  34. void ICACHE_FLASH_ATTR Encoder_MotionStartTimer(uint32_t timeout)
  35. {
  36. encoder.motion_timeout = timeout;
  37. os_timer_arm(&encoder.motion_timer, encoder.motion_timeout, false);
  38. }
  39. void ICACHE_FLASH_ATTR Encoder_MotionStopTimer()
  40. {
  41. os_timer_disarm(&encoder.motion_timer);
  42. }
  43. /* Battery Monitor Functions */
  44. // static void ICACHE_FLASH_ATTR encoder_battery_monitor_cb(void)
  45. // {
  46. //
  47. // }
  48. //
  49. // void ICACHE_FLASH_ATTR Encoder_StartBatteryMonitor(uint32_t battery_monitor_rate)
  50. // {
  51. //
  52. // }
  53. //
  54. // void ICACHE_FLASH_ATTR Encoder_StopBatteryMonitor(void)
  55. // {
  56. //
  57. // }
  58. //
  59. // Encoder_Battery_t ICACHE_FLASH_ATTR Encoder_GetBatteryStatus(void)
  60. // {
  61. //
  62. // }