encoder_interface.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. }
  22. /* Motion Functions */
  23. void ICACHE_FLASH_ATTR Encoder_MotionSetCallback(motion_function_t motion_cb)
  24. {
  25. encoder.motion_cb = motion_cb;
  26. os_timer_setfn(&encoder.motion_timer, (os_timer_func_t *)encoder.motion_cb, NULL);
  27. }
  28. void ICACHE_FLASH_ATTR Encoder_MotionStartTimer(uint32_t timeout)
  29. {
  30. encoder.motion_timeout = timeout;
  31. os_timer_arm(&encoder.motion_timer, encoder.motion_timeout, false);
  32. }
  33. void ICACHE_FLASH_ATTR Encoder_MotionStopTimer()
  34. {
  35. os_timer_disarm(&encoder.motion_timer);
  36. }
  37. /* Battery Monitor Functions */
  38. // static void ICACHE_FLASH_ATTR encoder_battery_monitor_cb(void)
  39. // {
  40. //
  41. // }
  42. //
  43. // void ICACHE_FLASH_ATTR Encoder_StartBatteryMonitor(uint32_t battery_monitor_rate)
  44. // {
  45. //
  46. // }
  47. //
  48. // void ICACHE_FLASH_ATTR Encoder_StopBatteryMonitor(void)
  49. // {
  50. //
  51. // }
  52. //
  53. // Encoder_Battery_t ICACHE_FLASH_ATTR Encoder_GetBatteryStatus(void)
  54. // {
  55. //
  56. // }