From: kyz Date: Tue, 21 May 2024 01:56:32 +0000 (+0800) Subject: 增加LCD上ota状态显示 X-Git-Url: http://kyz.pub/gitweb/?a=commitdiff_plain;h=5d1740402de5d557fe16243f06f1c90f953b3826;p=yn%2Fweldingcontroller.git 增加LCD上ota状态显示 --- diff --git a/user/user_ota.c b/user/user_ota.c index e353dad..b659414 100644 --- a/user/user_ota.c +++ b/user/user_ota.c @@ -75,6 +75,16 @@ static const osThreadAttr_t otaTask_attributes = { __attribute__((section(".DTCM"),zero_init)) static ota_t g_ota; +char * ota_status( void ) +{ + static char ota_st_str[50]; + if( !g_ota.task || !g_ota.fw_size ) + return NULL; + + sprintf( ota_st_str, "ota - %d%%", g_ota.fw_received*100/g_ota.fw_size ); + + return ota_st_str; +} int32_t ota_start( uint32_t link, char * url, char *ver ) { diff --git a/user/user_ui.c b/user/user_ui.c index c1ace78..3f08d40 100644 --- a/user/user_ui.c +++ b/user/user_ui.c @@ -309,7 +309,7 @@ void lcd_write_text( uint16_t addr, uint8_t *txt, uint8_t var_sz ) if( i < txt_sz ) tx_buf[ tx_n++ ] = txt[i]; else - tx_buf[ tx_n++ ] = 0; + tx_buf[ tx_n++ ] = 0xFF; } // crc = 0; //crc16(tx_buf, tx_n); @@ -411,6 +411,7 @@ void user_ui_task( void* unused ) EventBits_t uxBits; static uint32_t n = 0; char port_str[8]; + int32_t ota_disp = 0; //LCD Power ON @@ -496,6 +497,22 @@ void user_ui_task( void* unused ) n = 0; ///lcd_read( lcd_welding_method_addr, 3 ); } + + { + extern char * ota_status( void ); + char *s = ota_status(); + if( !s ){ + if(ota_disp){ + //ota stop, clear ota stauts str + ota_disp = 0; + lcd_write_text( lcd_msg_2_addr, (uint8_t*)" ", lcd_msg_2_size ); + } + }else{ + //ota_start + ota_disp = 1; + lcd_write_text( lcd_msg_2_addr, (uint8_t*)s, lcd_msg_2_size ); + } + } osDelay(1); } }