加入vofa
This commit is contained in:
@@ -7,7 +7,9 @@
|
||||
#include "iic_soft.h"
|
||||
#include "printfs.h"
|
||||
#include "pwm.h"
|
||||
#include "vofa_client.h"
|
||||
|
||||
uint8 send_flag = 0;
|
||||
|
||||
uint8 mode[2] = INA226_DEF_MODE;
|
||||
// uint8 m5[2] = {0x0D, 0x1B};
|
||||
@@ -23,11 +25,15 @@ void main()
|
||||
P05 = 0;
|
||||
oled_init();
|
||||
INA226_Init(&ina226[0], INA226_DEF_ADDR, mode, 20, 5, 1.0683, 1.002393);
|
||||
VOFA_Client_Init();
|
||||
|
||||
pit_timer_ms(TIM_1,INA226_READ_TIME_MS);
|
||||
|
||||
pwm_init(PWMA_CH1P_P60,100000,5000);
|
||||
// pit_timer_ms(TIM_3,1000);
|
||||
|
||||
pwm_init(PWMA_CH1P_P60,500000,6000);
|
||||
|
||||
// pwm_init(PWMA_CH1P_P60,500000,6000);
|
||||
// oled_fill(0xff);
|
||||
|
||||
// iic_init(IIC_1,10);
|
||||
@@ -38,6 +44,38 @@ void main()
|
||||
// iic_scan();
|
||||
while(1)
|
||||
{
|
||||
// oled_p6x8str(0, 7, "BLOCK");
|
||||
VOFA_Set_JustFloat_Data(0, ina226[0].result.voltage_V);
|
||||
VOFA_Set_JustFloat_Data(1, ina226[0].result.current_A);
|
||||
VOFA_Set_JustFloat_Data(2, ina226[0].result.power_W);
|
||||
VOFA_Send_Datas(3);
|
||||
send_flag = 1;
|
||||
|
||||
// oled_printf_float(0, 0, ina226[0].result.voltage_V,2,4);oled_p6x8str(55, 0, "V");
|
||||
// oled_printf_float(0, 1, ina226[0].result.current_A,2,4);oled_p6x8str(55, 1, "A");
|
||||
// oled_printf_float(0, 2, ina226[0].result.power_W,2,4);oled_p6x8str(55, 2, "W");
|
||||
// oled_printf_float(0, 3, ina226[0].result.energy_J,5,2);oled_p6x8str(55, 3, "J");
|
||||
// oled_printf_float(0, 4, ina226[0].result.energy_J/3600.0f,5,3);oled_p6x8str(55, 4, "Wh");
|
||||
// oled_printf_float(0, 5, ina226[0].result.quantity_C,5,2);oled_p6x8str(55, 5, "C");
|
||||
// if(send_flag)
|
||||
// {
|
||||
oled_p6x8str(0, 7, "SENT");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// oled_p6x8str(0, 7, "BLOCK");
|
||||
// }
|
||||
send_flag = 0;
|
||||
if(vofa_receive_new_data[1])
|
||||
{
|
||||
vofa_receive_new_data[1] = 0;
|
||||
pwm_duty(PWMA_CH1P_P60, (uint32)(vofa_data[1]));
|
||||
}
|
||||
if(vofa_receive_new_data[2])
|
||||
{
|
||||
vofa_receive_new_data[2] = 0;
|
||||
pwm_freq(PWMA_CH1P_P60, (uint32)(vofa_data[2]),(uint32)(vofa_data[1]));
|
||||
}
|
||||
// soft_iic_scan(&ina226_soft_config);
|
||||
// uint8 vot[2] = {0};
|
||||
// uint8 cru[2] = {0};
|
||||
@@ -60,12 +98,7 @@ void main()
|
||||
// powt = (int16)(pow[0] << 8 | pow[1]);
|
||||
// powf = (float)powt * 0.30518*25 /1000.0f;
|
||||
|
||||
oled_printf_float(0, 0, ina226[0].result.voltage_V,2,4);oled_p6x8str(55, 0, "V");
|
||||
oled_printf_float(0, 1, ina226[0].result.current_A,2,4);oled_p6x8str(55, 1, "A");
|
||||
oled_printf_float(0, 2, ina226[0].result.power_W,2,4);oled_p6x8str(55, 2, "W");
|
||||
oled_printf_float(0, 3, ina226[0].result.energy_J,5,2);oled_p6x8str(55, 3, "J");
|
||||
oled_printf_float(0, 4, ina226[0].result.energy_J/3600.0f,5,3);oled_p6x8str(55, 4, "Wh");
|
||||
oled_printf_float(0, 5, ina226[0].result.quantity_C,5,2);oled_p6x8str(55, 5, "C");
|
||||
|
||||
// // oled_int16(0, 0, (int16)(vot[0] << 8 | vot[1]));
|
||||
// oled_int16(0, 1, vot[0]);
|
||||
// oled_int16(40, 1, vot[1]);
|
||||
@@ -84,7 +117,7 @@ void main()
|
||||
// {
|
||||
// oled_fill(0x00);
|
||||
// }
|
||||
// delay_ms(1000);
|
||||
delay_ms(3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user