From a7a3919764893ebc01607611fa1e485e5713e8e1 Mon Sep 17 00:00:00 2001 From: kyz Date: Thu, 18 Sep 2025 15:57:10 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E6=94=B9=E7=B4=AF=E8=AE=A1=E6=B5=81?= =?utf8?q?=E9=87=8F=E4=B8=BAdouble=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- user/user.h | 2 +- user/user_flowmeter.c | 4 ++-- user/user_lfs.c | 6 +++--- user/user_lfs.h | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) 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 ); -- 2.34.1