瀏覽代碼

电流软保护这算到1s

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 4 年之前
父節點
當前提交
0317ca6d13
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      Application/app/sox/soft_current_protect.c

+ 4 - 2
Application/app/sox/soft_current_protect.c

@@ -3,7 +3,8 @@
 #include "libs/shark_libs.h"
 #include "libs/circle_buffer.h"
 #include "libs/logger.h"
-#define MAX_SIZE 50
+
+#define MAX_SIZE 100
 typedef struct {
 	c_buffer_t   current;
 	c_buffer_t   delta_ts;
@@ -53,6 +54,7 @@ int soft_current_push(float current_ma){
 		circle_put_one_data(&_fifo_i2.delta_ts,delta_ts);
 	}
 	_fifo_i2.last_ts = shark_get_mseconds();
-	return (_fifo_i2.i2t_sum >= MAX_I2T); //ÕÛËãµ½1s
+	float f_sum = _fifo_i2.i2t_sum*(1.0f / ((float)_fifo_i2.ts_sum/1000.0f));
+	return (f_sum >= MAX_I2T); //ÕÛËãµ½1s
 }