增加LCD上ota状态显示
authorkyz <kongyuzhong@google.com>
Tue, 21 May 2024 01:56:32 +0000 (09:56 +0800)
committerkyz <kongyuzhong@google.com>
Tue, 21 May 2024 02:03:17 +0000 (10:03 +0800)
user/user_ota.c
user/user_ui.c

index e353dada5f032f29c7c607f4b830b4c92491b0ec..b659414b32086414cf34d18adf4c759ee10ca24c 100644 (file)
@@ -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 )
 {
index c1ace78481a0682b7fd6a6a0bd7bf955f2809210..3f08d40c869763fcb9c269b2f165f595582c52f3 100644 (file)
@@ -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);
         }
     }