|
@@ -1,23 +1,20 @@
|
|
|
#include "interface/encoder_interface.h"
|
|
|
|
|
|
typedef void (* motion_function_t)(void);
|
|
|
+typedef void (* battery_function_t)(void);
|
|
|
|
|
|
typedef struct {
|
|
|
os_timer_t motion_timer;
|
|
|
uint32_t motion_timeout;
|
|
|
motion_function_t motion_cb;
|
|
|
- uint32_t vcell;
|
|
|
- uint32_t soc;
|
|
|
+ uint16_t vcell;
|
|
|
+ uint16_t soc;
|
|
|
os_timer_t battery_timer;
|
|
|
uint32_t battery_timeout;
|
|
|
+ battery_function_t battery_cb;
|
|
|
} Encoder_t;
|
|
|
|
|
|
-typedef struct {
|
|
|
- uint32_t vcell;
|
|
|
- uint32_t motion;
|
|
|
-} Encoder_Battery_t;
|
|
|
-
|
|
|
-static Encoder_t encoder;
|
|
|
+
|
|
|
|
|
|
void ICACHE_FLASH_ATTR Encoder_Shutdown(void)
|
|
|
{
|
|
@@ -37,43 +34,70 @@ void ICACHE_FLASH_ATTR Encoder_Restart(void)
|
|
|
system_restart();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
-void ICACHE_FLASH_ATTR Encoder_MotionSetCallback(motion_function_t motion_cb)
|
|
|
-{
|
|
|
- encoder.motion_cb = motion_cb;
|
|
|
- os_timer_setfn(&encoder.motion_timer, (os_timer_func_t *)encoder.motion_cb, NULL);
|
|
|
-}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-void ICACHE_FLASH_ATTR Encoder_MotionStartTimer(uint32_t timeout)
|
|
|
-{
|
|
|
- encoder.motion_timeout = timeout;
|
|
|
- os_timer_arm(&encoder.motion_timer, encoder.motion_timeout, false);
|
|
|
-}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-void ICACHE_FLASH_ATTR Encoder_MotionStopTimer()
|
|
|
-{
|
|
|
- os_timer_disarm(&encoder.motion_timer);
|
|
|
-}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
+#define VOLTAGE_CUTOFF 2800
|
|
|
+
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|