Kaynağa Gözat

can_response_vols 改为S16Q5格式

Signed-off-by: kevin <huhui@sharkgulf.com>
kevin 2 yıl önce
ebeveyn
işleme
ff33771924
1 değiştirilmiş dosya ile 8 ekleme ve 14 silme
  1. 8 14
      Applications/prot/can_foc_msg.c

+ 8 - 14
Applications/prot/can_foc_msg.c

@@ -158,26 +158,20 @@ void can_report_mot_params_ested(float v, u8 type) {
 
 void can_response_vols(u8 can, u8 key) {
 	u8 data[16];
-	int len;
+	int len = 0;
 	encoder_can_key(data, CMD_2_CAN_KEY(key));
 	len += 2;
-	float acc = get_acc_vol() * 10.0f;
-	encode_s16(data + len, (s16)acc);
+	encode_s16(data + len, S16Q5(get_acc_vol()));
 	len += 2;
-	float vbus = get_vbus_float() * 10.0f;
-	encode_s16(data + len, (s16)vbus);
-	len = 2;
-	float thro = get_throttle_float() * 10.0f;
-	encode_s16(data + len, (s16)thro);
+	encode_s16(data + len, S16Q5(get_vbus_float()));
 	len += 2;
-	float thro_5v = get_thro_5v_float() * 10.0f;
-	encode_s16(data + len, (s16)thro_5v);
+	encode_s16(data + len, S16Q5(get_throttle_float()));
 	len += 2;
-	thro = get_throttle2_float() * 10.0f;
-	encode_s16(data + len, (s16)thro);
+	encode_s16(data + len, S16Q5(get_thro_5v_float()));
 	len += 2;
-	thro_5v = get_thro2_5v_float() * 10.0f;
-	encode_s16(data + len, (s16)thro_5v);
+	encode_s16(data + len, S16Q5(get_throttle2_float()));
+	len += 2;
+	encode_s16(data + len, S16Q5(get_thro2_5v_float()));
 	len += 2;
 	can_send_response(can, data, len);
 }