From: kyz Date: Thu, 18 Sep 2025 07:57:10 +0000 (+0800) Subject: 修改累计流量为double类型 X-Git-Url: http://kyz.pub/gitweb/?a=commitdiff_plain;h=a7a3919764893ebc01607611fa1e485e5713e8e1;p=yn%2Fweldingcontroller.git 修改累计流量为double类型 --- diff --git a/user/user.h b/user/user.h index 8aa79ac..55a5668 100644 --- a/user/user.h +++ b/user/user.h @@ -132,7 +132,7 @@ typedef struct{ float flow_speed_raw_ad; //ad采集到瞬时流量 float flow_speed_raw; //485接口采集到瞬时流量 L/min float flow_speed; //校准后的瞬时流量 L/min - float flow_total; //累计流量 L + double flow_total; //累计流量 L float tem; uint32_t state; //0:流量计正常 1:传感器异常 2:EEPROM异常 3:传感器和EEPROM均异常 }flowmeter_t; diff --git a/user/user_flowmeter.c b/user/user_flowmeter.c index a822756..7f074d0 100644 --- a/user/user_flowmeter.c +++ b/user/user_flowmeter.c @@ -197,8 +197,8 @@ int32_t mb_master_read_regs( uint8_t device_addr, uint16_t reg, uint16_t* reg_va return -1; } -static float g_flow_total = 0; -extern float lfs_load_flow_total( void ); +static double g_flow_total = 0; +extern double lfs_load_flow_total( void ); void flow_total_update( uint32_t ms ) { diff --git a/user/user_lfs.c b/user/user_lfs.c index c004ded..85cee15 100644 --- a/user/user_lfs.c +++ b/user/user_lfs.c @@ -124,10 +124,10 @@ int32_t user_lfs_write( char *path, uint8_t *write_buffer, uint32_t write_size ) return ret; } -float lfs_load_flow_total( void ) +double lfs_load_flow_total( void ) { uint32_t total_x10; - float total = 0; + double total = 0; if( user_lfs_read( FLOW_TOTAL_PATH, (uint8_t*)&total_x10, sizeof( total_x10 ) ) == sizeof( total_x10 ) ){ total = total_x10/10.0f; @@ -136,7 +136,7 @@ float lfs_load_flow_total( void ) } -int32_t lfs_store_flow_total( float total ) +int32_t lfs_store_flow_total( double total ) { uint32_t total_x10; int32_t ret = -1; diff --git a/user/user_lfs.h b/user/user_lfs.h index 29157ff..693ca2d 100644 --- a/user/user_lfs.h +++ b/user/user_lfs.h @@ -13,8 +13,8 @@ int32_t user_lfs_init( void ); int32_t user_lfs_read( char *path, uint8_t *read_buffer, uint32_t read_size ); int32_t user_lfs_write( char *path, uint8_t *write_buffer, uint32_t write_size ); -float lfs_load_flow_total( void ); -int32_t lfs_store_flow_total( float total ); +double lfs_load_flow_total( void ); +int32_t lfs_store_flow_total( double total ); int32_t lfs_load_device_serial( char *read_buffer, uint32_t buffer_size ); int32_t lfs_store_device_serial( char *sn ); uint32_t lfs_load_offline_time( void );