1.恢复出厂加灯效
authord15521469561 <1731678236@qq.com>
Tue, 16 Jun 2026 01:37:24 +0000 (09:37 +0800)
committerd15521469561 <1731678236@qq.com>
Tue, 16 Jun 2026 01:37:24 +0000 (09:37 +0800)
2.自动升级功能
3.修改版本号

App/inc/iap.h
App/inc/led.h
App/src/iap.c
App/src/iot.c
App/src/led.c
RVMDK/RVMDKN32G45X/main.c
RVMDK/RVMDKN32G45X/project_cfg.h

index 45b7d60..581a9e3 100644 (file)
@@ -308,6 +308,8 @@ typedef union
                uint8_t protocol_version;
                uint8_t reply;
                uint8_t sub_cmd;
+               
+               uint8_t ota_auto_flag;
        }end;
        
 }IAP_LITE_CMD_T;
index fbb2b88..d0b4b5a 100644 (file)
@@ -348,6 +348,7 @@ typedef enum
        KEY_TURN_OFF,
        KEY_COLOR_PREVIEW,
        KEY_BLE_CONNECT_BLINK,
+       KEY_IOT_FACTORY_RESET,
        KEY_EXHIBITION,
        KEY_POWER_ON,
 }KEY_LED_STATUS_ENUM;
@@ -366,11 +367,12 @@ typedef struct
                        uint16_t turn_off:1;
                        uint16_t color_preview:1;
                        uint16_t ble_state:1;
+                       uint16_t iot_factory_status:1;
                        uint16_t exhibition:1;
                        
                        
                        uint16_t power_on:1;
-                       uint16_t reserved1:6;
+                       uint16_t reserved1:5;
                };
                uint16_t status;
        };
index 34322d8..ce05080 100644 (file)
@@ -515,6 +515,7 @@ void Iap_Lite_Process(uint8_t* data, uint16_t len, uint8_t host_type)
                        // ×¼±¸Éý¼¶
                        case IAP_LITE_CMD_READY:
                        {
+                               FLASH_EraseOnePage(FLASH_MOVE_PARTITION_ADDR);
                                // ½«APP0°áÔ˵½APP1±¸·Ý
                                uint32_t crc32 = Iap_Check(FLASH_APP_PARTITION, FLASH_APP_PARTITION_SIZE);
                                
@@ -588,7 +589,14 @@ void Iap_Lite_Process(uint8_t* data, uint16_t len, uint8_t host_type)
                        //½áÊø¸´Î»
                        case IAP_LITE_CMD_END :
                        {
-                               iap_end_flag = 1;
+                               DUG_PRINTF("iap_lite_cmd->end.ota_auto_flag=%d\n",iap_lite_cmd->end.ota_auto_flag);
+                               if(!iap_lite_cmd->end.ota_auto_flag)
+                               {
+                                       iap_end_flag = 1;
+                               }else{
+                                       iap_end_flag = 0;
+                                       
+                               }
                                iap_lite_reply.payload.reply = REPLY_STATUS_OK;
                        }
                        break;
@@ -607,3 +615,4 @@ void Iap_Lite_Process(uint8_t* data, uint16_t len, uint8_t host_type)
                Iot_Uart_Tx_Query_Add(IOT_UART_IAP_CMD, (uint8_t*)&iap_lite_reply, sizeof(iap_lite_reply.payload));
        }
 }
+
index 17e4a64..9db21e5 100644 (file)
@@ -216,7 +216,7 @@ void Iot_Uart_Rx_Handle(uint8_t *data ,uint8_t len)
                 }
 
 //                             DUG_PRINTF("data[2]:%02x\n\n", data[2]);
-                switch (data[3])
+                switch (data[4])
                 {
                     case 0x00:
                                        {
@@ -321,6 +321,7 @@ void Iot_Uart_Rx_Handle(uint8_t *data ,uint8_t len)
                        case 0x13:
             {
                                iot_factroy_flag=0;
+                               key_led_status.iot_factory_status = 1;
             }
             break;
                        
@@ -333,6 +334,16 @@ void Iot_Uart_Rx_Handle(uint8_t *data ,uint8_t len)
             }
             break;
                        
+                       //ÖØÆôÖ÷¿ØºÍÄ£×é
+                       case 0x15:
+            {
+                               
+                               system_reset_remain=50;
+                               
+            }
+            break;
+                       
+                       
 
             case 0xB1:
             {
@@ -384,12 +395,8 @@ void Iot_Disconnect_Count(void)
 void Iot_OneTimerSecond(void)
 {
        static uint32_t timerSecond=0;
-       static uint32_t powerOn_count=0;
+       static uint8_t powerOn_count=0;
        
-       if(timerSecond == 0)
-       {
-               timerSecond= systicks;
-       }
        if(systicks - timerSecond >= ONE_TIMER_SECOND)
        {
                timerSecond= systicks;
index 15f51ee..08f5a94 100644 (file)
@@ -2003,77 +2003,76 @@ void Led_Key_Ble_Connected_Blink(void)
     for(uint8_t num=0;num<KEY_LED_NUM;num++)
     {
         key_led_struct[num].unit[0].startTime = 0;
-               key_led_struct[num].unit[0].axisTime = 40;
+               key_led_struct[num].unit[0].axisTime = 100;
                key_led_struct[num].unit[0].shiftInTime = 10;
                key_led_struct[num].unit[0].shiftOutTime = 0;
                key_led_struct[num].unit[0].dstR = 0;
                key_led_struct[num].unit[0].dstG = 0;
                key_led_struct[num].unit[0].dstB = 0;
 
-               key_led_struct[num].unit[1].startTime = 40;
-               key_led_struct[num].unit[1].axisTime = 40;
+               key_led_struct[num].unit[1].startTime = 100;
+               key_led_struct[num].unit[1].axisTime = 100;
                key_led_struct[num].unit[1].shiftInTime = 10;
                key_led_struct[num].unit[1].shiftOutTime = 0;
                key_led_struct[num].unit[1].dstR = led_key_profile[led_profile_status.key_current_profile][num][0];
                key_led_struct[num].unit[1].dstG = led_key_profile[led_profile_status.key_current_profile][num][1];
                key_led_struct[num].unit[1].dstB = led_key_profile[led_profile_status.key_current_profile][num][2];
                
-               key_led_struct[num].unit[2].startTime = 80;
-               key_led_struct[num].unit[2].axisTime = 40;
+               key_led_struct[num].unit[2].startTime = 200;
+               key_led_struct[num].unit[2].axisTime = 100;
                key_led_struct[num].unit[2].shiftInTime = 10;
                key_led_struct[num].unit[2].shiftOutTime = 0;
                key_led_struct[num].unit[2].dstR = 0;
                key_led_struct[num].unit[2].dstG = 0;
                key_led_struct[num].unit[2].dstB = 0;
 
-               key_led_struct[num].unit[3].startTime = 120;
-               key_led_struct[num].unit[3].axisTime = 40;
+               key_led_struct[num].unit[3].startTime = 300;
+               key_led_struct[num].unit[3].axisTime = 100;
                key_led_struct[num].unit[3].shiftInTime = 10;
                key_led_struct[num].unit[3].shiftOutTime = 0;
                key_led_struct[num].unit[3].dstR = led_key_profile[led_profile_status.key_current_profile][num][0];
                key_led_struct[num].unit[3].dstG = led_key_profile[led_profile_status.key_current_profile][num][1];
                key_led_struct[num].unit[3].dstB = led_key_profile[led_profile_status.key_current_profile][num][2];
                
-               key_led_struct[num].unit[4].startTime = 160;
-               key_led_struct[num].unit[4].axisTime = 40;
-               key_led_struct[num].unit[4].shiftInTime = 10;
-               key_led_struct[num].unit[4].shiftOutTime = 0;
-               key_led_struct[num].unit[4].dstR = 0;
-               key_led_struct[num].unit[4].dstG = 0;
-               key_led_struct[num].unit[4].dstB = 0;
-
-               key_led_struct[num].unit[5].startTime = 200;
-               key_led_struct[num].unit[5].axisTime = 40;
-               key_led_struct[num].unit[5].shiftInTime = 10;
-               key_led_struct[num].unit[5].shiftOutTime = 0;
-               key_led_struct[num].unit[5].dstR = led_key_profile[led_profile_status.key_current_profile][num][0];
-               key_led_struct[num].unit[5].dstG = led_key_profile[led_profile_status.key_current_profile][num][1];
-               key_led_struct[num].unit[5].dstB = led_key_profile[led_profile_status.key_current_profile][num][2];
-               
-               key_led_struct[num].unit[6].startTime = 240;
-               key_led_struct[num].unit[6].axisTime = 40;
-               key_led_struct[num].unit[6].shiftInTime = 10;
-               key_led_struct[num].unit[6].shiftOutTime = 0;
-               key_led_struct[num].unit[6].dstR = 0;
-               key_led_struct[num].unit[6].dstG = 0;
-               key_led_struct[num].unit[6].dstB = 0;
-
-               key_led_struct[num].unit[7].startTime = 280;
-               key_led_struct[num].unit[7].axisTime = 40;
-               key_led_struct[num].unit[7].shiftInTime = 10;
-               key_led_struct[num].unit[7].shiftOutTime = 0;
-               key_led_struct[num].unit[7].dstR = led_key_profile[led_profile_status.key_current_profile][num][0];
-               key_led_struct[num].unit[7].dstG = led_key_profile[led_profile_status.key_current_profile][num][1];
-               key_led_struct[num].unit[7].dstB = led_key_profile[led_profile_status.key_current_profile][num][2];
-               
-               key_led_struct[num].totalTime = 320;
-               key_led_struct[num].unitNum = 8;
+               
+               
+               key_led_struct[num].totalTime = 400;
+               key_led_struct[num].unitNum = 4;
                key_led_struct[num].loop = 0;
                
                key_led_struct[num].start = 1;
     }
 }
+//°´¼ü»Ö¸´³ö³§ÁÁ°´¼üµÆ
+void Led_Key_Factory_Blink(void)
+{
+    // Ó¦ÓÃ
+    for(uint8_t num=0;num<KEY_LED_NUM;num++)
+    {
+        key_led_struct[num].unit[0].startTime = 0;
+               key_led_struct[num].unit[0].axisTime = 100;
+               key_led_struct[num].unit[0].shiftInTime = 10;
+               key_led_struct[num].unit[0].shiftOutTime = 0;
+               key_led_struct[num].unit[0].dstR = 0;
+               key_led_struct[num].unit[0].dstG = 0;
+               key_led_struct[num].unit[0].dstB = 0;
 
+               key_led_struct[num].unit[1].startTime = 100;
+               key_led_struct[num].unit[1].axisTime = 100;
+               key_led_struct[num].unit[1].shiftInTime = 10;
+               key_led_struct[num].unit[1].shiftOutTime = 0;
+               key_led_struct[num].unit[1].dstR = led_key_profile[led_profile_status.key_current_profile][num][0];
+               key_led_struct[num].unit[1].dstG = led_key_profile[led_profile_status.key_current_profile][num][1];
+               key_led_struct[num].unit[1].dstB = led_key_profile[led_profile_status.key_current_profile][num][2];
+               
+               
+               key_led_struct[num].totalTime = 200;
+               key_led_struct[num].unitNum = 2;
+               key_led_struct[num].loop = 0;
+               
+               key_led_struct[num].start = 1;
+    }
+}
 void Led_Enc_Recover_Color(uint8_t abs_num, uint8_t led_num)
 {
 #if (ENC_LED_TOTAL_NUM)
@@ -2622,7 +2621,14 @@ void Led_Key_Status_Process(void)
                                Led_Key_Ble_Connected_Blink();
                        }
                        break;
-       
+                       
+                       case KEY_IOT_FACTORY_RESET:
+                       {
+                               key_led_status.wait_for_profile_end_enable = 1;
+                               Led_Key_Factory_Blink();
+                               
+                       }
+                       break;
                        case KEY_EXHIBITION:
                        {
                                Led_Key_Exhibition2();
index 3359260..15751db 100644 (file)
@@ -86,7 +86,9 @@ int main(void)
        IWDG_Init();
        iwdg_status = 1;
 #endif
+       #if IOT_ENABLE
        Iot_Init();
+       #endif
        while(1)
        {
 //             static uint32_t systicks_last = 0;
@@ -116,9 +118,13 @@ int main(void)
                Led_Update();
                
                Status_Update();
+               #if IOT_ENABLE
                Iot_OneTimerSecond();
+               #endif
        }
 }
+
+
 #else
 #include "project_cfg.h"
 #include "flash.h"
index d8dfa87..a5e301b 100644 (file)
@@ -16,7 +16,7 @@
 
 #if (W_GTL == 1)
        // USB
-       #define FW_VERSION                      (0x0105)                //¹Ì¼þ°æ±¾
+       #define FW_VERSION                      (0x0106)                //¹Ì¼þ°æ±¾
        #define BUILD_VERSION                   (0x0001)
        #define USB_VID                                         (0x36E6)
        #define USB_PID_APP                                     (0xA00B)