From: d15521469561 <1731678236@qq.com> Date: Fri, 5 Jun 2026 03:02:12 +0000 (+0800) Subject: 1.修复绝对值按键映射不保存的问题 pc和app同时设置 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=cd9e9f9e136f7944c30000369492cb5e47e8d1bf;p=mirrors%2FNG455.git 1.修复绝对值按键映射不保存的问题 pc和app同时设置 --- diff --git a/App/inc/flash.h b/App/inc/flash.h index 74f4ecb..c23384b 100644 --- a/App/inc/flash.h +++ b/App/inc/flash.h @@ -49,7 +49,7 @@ // °´¼üÓ³Éä #define FLASH_INPUT_REMAP_ADDR (0x08075000) -#define FLASH_INPUT_REMAP_FLAG (0x09000001) +#define FLASH_INPUT_REMAP_FLAG (0x09000002) // Óû§ÊäÈëÊä³öÉèÖà #define FLASH_USER_IO_SETTING_ADDR (0x08075800) diff --git a/App/inc/io.h b/App/inc/io.h index dc72fa5..af72331 100644 --- a/App/inc/io.h +++ b/App/inc/io.h @@ -5,6 +5,10 @@ #include "led.h" #pragma pack(push, 1) + +// ½á¹¹Ìå³ÉÔ±Æ«ÒÆÁ¿ +#define offsetofstruct(type,member) ((int) &((type *)0)->member) + typedef enum { GPIOP_A = 0, @@ -869,7 +873,59 @@ typedef union }; uint8_t remap_dst[34]; #endif -}IO_REMAPABLE_KEY_T; +}IO_REMAPABLE_KEY_0_T; + +typedef union +{ +#if (W_GTL) + struct + { + uint8_t abs_enc1_cnt1; + uint8_t abs_enc1_cnt2; + uint8_t abs_enc1_cnt3; + uint8_t abs_enc1_cnt4; + uint8_t abs_enc1_cnt5; + uint8_t abs_enc1_cnt6; + uint8_t abs_enc1_cnt7; + uint8_t abs_enc1_cnt8; + + uint8_t abs_enc1_cnt9; + uint8_t abs_enc1_cnt10; + uint8_t abs_enc1_cnt11; + uint8_t abs_enc1_cnt12; + uint8_t abs_enc2_cnt1; + uint8_t abs_enc2_cnt2; + uint8_t abs_enc2_cnt3; + uint8_t abs_enc2_cnt4; + + uint8_t abs_enc2_cnt5; + uint8_t abs_enc2_cnt6; + uint8_t abs_enc2_cnt7; + uint8_t abs_enc2_cnt8; + uint8_t abs_enc2_cnt9; + uint8_t abs_enc2_cnt10; + uint8_t abs_enc2_cnt11; + uint8_t abs_enc2_cnt12; + + uint8_t abs_enc3_cnt1; + uint8_t abs_enc3_cnt2; + uint8_t abs_enc3_cnt3; + uint8_t abs_enc3_cnt4; + uint8_t abs_enc3_cnt5; + uint8_t abs_enc3_cnt6; + uint8_t abs_enc3_cnt7; + uint8_t abs_enc3_cnt8; + + uint8_t abs_enc3_cnt9; + uint8_t abs_enc3_cnt10; + uint8_t abs_enc3_cnt11; + uint8_t abs_enc3_cnt12; + }; + uint8_t remap_dst[36]; +#elif (W_TS) + +#endif +}IO_REMAPABLE_KEY_1_T; typedef union { @@ -985,7 +1041,8 @@ typedef union uint8_t sub_packet; union { - IO_REMAPABLE_KEY_T remapable_key; + IO_REMAPABLE_KEY_0_T remapable_key_0; + IO_REMAPABLE_KEY_1_T remapable_key_1; }; }mode1; diff --git a/App/src/flash.c b/App/src/flash.c index 26f692c..1eee383 100644 --- a/App/src/flash.c +++ b/App/src/flash.c @@ -811,7 +811,7 @@ void Flash_Io_Input_Remap_Set_Default(void *remap_table) for(uint8_t i=0;i<=((int)&((IO_INPUT_REMAP_T *)0)->abs_enc3_cnt12)-((int)&((IO_INPUT_REMAP_T *)0)->abs_enc1_cnt1);i++) { - ((IO_INPUT_REMAP_T*)remap_table)->data[i+((int)&((IO_INPUT_REMAP_T *)0)->abs_enc1_cnt1)] = i+(128-36)+1; + ((IO_INPUT_REMAP_T*)remap_table)->data[i+((int)&((IO_INPUT_REMAP_T *)0)->abs_enc1_cnt1)] = i+55; } ((IO_INPUT_REMAP_T*)remap_table)->paddle_ld = KV_AXIS_Z; diff --git a/App/src/iap.c b/App/src/iap.c index 31c2bd8..fe052b2 100644 --- a/App/src/iap.c +++ b/App/src/iap.c @@ -59,7 +59,7 @@ uint8_t Iap_Write(uint32_t addr, uint8_t packet_size, uint8_t* data) wdata |= data[j+1]<<8; wdata |= data[j+2]<<16; wdata |= data[j+3]<<24; - DUG_PRINTF("addr:%08x\n",waddr+4*i); + FLASH_ProgramWord(waddr+4*i, wdata); j+=4; } diff --git a/App/src/io.c b/App/src/io.c index 73ae933..8ec95f7 100644 --- a/App/src/io.c +++ b/App/src/io.c @@ -487,7 +487,7 @@ void Io_Init(void) // Led_Key_Switch_Profile(0); // Led_Tele_Switch_Profile(0); // Led_Enc_Switch_Profile(0); - Led_Key_Ble_Connected_Blink(); +// Led_Key_Ble_Connected_Blink(); Base_Uart_Init(); #if (IOT_ENABLE) @@ -610,7 +610,6 @@ ENCODER_DIR_T encoder_dir[DIR_ENC_NUM] = {{.data = 0}, {.data = 0}}; uint16_t encoder_bcd_cooldown[ABS_ENC_NUM] = {0}; ENCODER_BCD_T encoder_bcd[ABS_ENC_NUM] = {{.data = 0}, {.data = 0}, {.data = 0}}; ENCODER_BCD_T encoder_bcd_last[ABS_ENC_NUM] = {{.data = 0xFF}, {.data = 0xFF}, {.data = 0xFF}}; -uint8_t abs_enc_mode[ABS_ENC_NUM] = {0, 0, 0}; uint16_t abs_enc_pos_bit[ABS_ENC_NUM] = {0}; #endif #endif @@ -2516,31 +2515,45 @@ void App_Comm_Handle(uint8_t* data, uint8_t size) if(app_command->key_remap.mode == 0) { app_reply.key_remap.mode1.sub_packet = app_command->key_remap.mode1.sub_packet; + app_reply.cmd.status = REPLY_STATUS_OK; +#if (W_GTL) if(app_command->key_remap.mode1.sub_packet == 0) { -#if (W_GTL) - memcpy(&app_reply.key_remap.mode1.remapable_key.key1, &io_input_remap[DINPUT_MODE].key1, 40); - memcpy(&app_reply.key_remap.mode1.remapable_key.paddle_ld, &io_input_remap[DINPUT_MODE].paddle_ld, 2); + memcpy(&app_reply.key_remap.mode1.remapable_key_0.key1, &io_input_remap[DINPUT_MODE].key1, 40); + memcpy(&app_reply.key_remap.mode1.remapable_key_0.paddle_ld, &io_input_remap[DINPUT_MODE].paddle_ld, 2); + } + else if(app_command->key_remap.mode1.sub_packet == 1) + { + memcpy(&app_reply.key_remap.mode1.remapable_key_1.abs_enc1_cnt1, &io_input_remap[DINPUT_MODE].abs_enc1_cnt1, sizeof(IO_REMAPABLE_KEY_1_T)); + } #elif (W_TS) - memcpy(&app_reply.key_remap.mode1.remapable_key.key1, &io_input_remap[DINPUT_MODE].key1, sizeof(IO_REMAPABLE_KEY_T)); + if(app_command->key_remap.mode1.sub_packet == 0) + { + memcpy(&app_reply.key_remap.mode1.remapable_key_0.key1, &io_input_remap[DINPUT_MODE].key1, sizeof(IO_REMAPABLE_KEY_0_T)); + } #endif + else + { + app_reply.cmd.status = REPLY_STATUS_NO_CMD; } - app_reply.cmd.status = REPLY_STATUS_OK; + } else if(app_command->key_remap.mode == 1) { app_reply.key_remap.mode2.remap_src = app_command->key_remap.mode2.remap_src; - if(app_command->key_remap.mode2.remap_src >= 40 && app_command->key_remap.mode2.remap_src <= 75) - { - app_reply.key_remap.mode2.remap_dst = 0; - app_reply.cmd.status = REPLY_STATUS_FAIL; - } - else - { - app_reply.key_remap.mode2.remap_dst = io_input_remap[DINPUT_MODE].data[app_command->key_remap.mode2.remap_src]; - app_reply.cmd.status = REPLY_STATUS_OK; - } +// if(app_command->key_remap.mode2.remap_src >= 40 && app_command->key_remap.mode2.remap_src <= 75) +// { +// app_reply.key_remap.mode2.remap_dst = 0; +// app_reply.cmd.status = REPLY_STATUS_FAIL; +// } +// else +// { +// app_reply.key_remap.mode2.remap_dst = io_input_remap[DINPUT_MODE].data[app_command->key_remap.mode2.remap_src]; +// app_reply.cmd.status = REPLY_STATUS_OK; +// } + app_reply.key_remap.mode2.remap_dst = io_input_remap[DINPUT_MODE].data[app_command->key_remap.mode2.remap_src]; + app_reply.cmd.status = REPLY_STATUS_OK; } } else if(app_command->key_remap.read_write == USB_COMM_WRITE) @@ -2549,41 +2562,68 @@ void App_Comm_Handle(uint8_t* data, uint8_t size) if(app_command->key_remap.mode == 0) { app_reply.key_remap.mode1.sub_packet = app_command->key_remap.mode1.sub_packet; + app_reply.cmd.status = REPLY_STATUS_OK; if(app_command->key_remap.mode1.sub_packet == 0) { for(uint8_t i=0;i<40;i++) { - if(app_command->key_remap.mode1.remapable_key.remap_dst[i] != 0) + if(app_command->key_remap.mode1.remapable_key_0.remap_dst[i] != 0) { - io_input_remap[DINPUT_MODE].data[i] = app_command->key_remap.mode1.remapable_key.remap_dst[i]; + io_input_remap[DINPUT_MODE].data[i] = app_command->key_remap.mode1.remapable_key_0.remap_dst[i]; } - app_reply.key_remap.mode1.remapable_key.remap_dst[i] = io_input_remap[DINPUT_MODE].data[i]; + app_reply.key_remap.mode1.remapable_key_0.remap_dst[i] = io_input_remap[DINPUT_MODE].data[i]; } for(uint8_t i=40;i<42;i++) { - if(app_command->key_remap.mode1.remapable_key.remap_dst[i] != 0) + if(app_command->key_remap.mode1.remapable_key_0.remap_dst[i] != 0) { - io_input_remap[DINPUT_MODE].data[i+36] = app_command->key_remap.mode1.remapable_key.remap_dst[i]; + io_input_remap[DINPUT_MODE].data[i+36] = app_command->key_remap.mode1.remapable_key_0.remap_dst[i]; } - app_reply.key_remap.mode1.remapable_key.remap_dst[i] = io_input_remap[DINPUT_MODE].data[i+36]; + app_reply.key_remap.mode1.remapable_key_0.remap_dst[i] = io_input_remap[DINPUT_MODE].data[i+36]; } - app_reply.cmd.status = REPLY_STATUS_OK; + Flash_Write_Query_Add(FLASH_INPUT_REMAP_ADDR, FLASH_INPUT_REMAP_FLAG, (uint8_t*)&io_input_remap, sizeof(IO_INPUT_REMAP_T)*3, 1); + + } + else if(app_command->key_remap.mode1.sub_packet == 1) + { + for(uint8_t i=0;ikey_remap.mode1.remapable_key_1.remap_dst[i] != 0) + { + io_input_remap[DINPUT_MODE].data[offsetofstruct(IO_INPUT_REMAP_T, abs_enc1_cnt1) + i] = app_command->key_remap.mode1.remapable_key_1.remap_dst[i]; + } + app_reply.key_remap.mode1.remapable_key_1.remap_dst[i] = io_input_remap[DINPUT_MODE].data[offsetofstruct(IO_INPUT_REMAP_T, abs_enc1_cnt1) + i]; + } + Flash_Write_Query_Add(FLASH_INPUT_REMAP_ADDR, FLASH_INPUT_REMAP_FLAG, (uint8_t*)&io_input_remap, sizeof(IO_INPUT_REMAP_T)*3, 1); + } + else + { + app_reply.cmd.status = REPLY_STATUS_NO_CMD; } + } else if(app_command->key_remap.mode == 1) { - if(app_command->key_remap.mode2.remap_src >= 40 && app_command->key_remap.mode2.remap_src <= 75) - { - app_reply.cmd.status = REPLY_STATUS_FAIL; - } - else if(app_command->key_remap.mode2.remap_src && app_command->key_remap.mode2.remap_dst != 0) +// if(app_command->key_remap.mode2.remap_src >= 40 && app_command->key_remap.mode2.remap_src <= 75) +// { +// app_reply.cmd.status = REPLY_STATUS_FAIL; +// } +// else + if(app_command->key_remap.mode2.remap_src < sizeof(IO_INPUT_REMAP_T) && app_command->key_remap.mode2.remap_dst != 0) { io_input_remap[DINPUT_MODE].data[app_command->key_remap.mode2.remap_src] = app_command->key_remap.mode2.remap_dst; app_reply.cmd.status = REPLY_STATUS_OK; + Flash_Write_Query_Add(FLASH_INPUT_REMAP_ADDR, FLASH_INPUT_REMAP_FLAG, (uint8_t*)&io_input_remap, sizeof(IO_INPUT_REMAP_T)*3, 1); + } + else + { + app_reply.cmd.status = REPLY_STATUS_FAIL; } app_reply.key_remap.mode2.remap_src = app_command->key_remap.mode2.remap_src; app_reply.key_remap.mode2.remap_dst = app_command->key_remap.mode2.remap_dst; + + } else { diff --git a/App/src/iot.c b/App/src/iot.c index 72dd086..17e4a64 100644 --- a/App/src/iot.c +++ b/App/src/iot.c @@ -166,7 +166,7 @@ uint8_t got_heartbeat_flag = 0; void Iot_Uart_Rx_Handle(uint8_t *data ,uint8_t len) { - if(data[1] != 0xE0) + if(data[1] != 0xE0 && data[1] != 0xB7) { DUG_PRINTF("IOT: "); for(uint8_t i=0;i<10;i++) @@ -182,7 +182,7 @@ void Iot_Uart_Rx_Handle(uint8_t *data ,uint8_t len) } if(len >= 4 && len <= IOT_UART_BUFFER_MAX && data[0] == FRAMEHEAD_IOT_TO_PANEL && Crc8_ROHC_Cal(&data[1], len-2) == data[len-1]) { - DUG_PRINTF("recv:%02x\n", data[1]); +// DUG_PRINTF("recv:%02x\n", data[1]); switch (data[1]) { case 0x00: @@ -393,11 +393,11 @@ void Iot_OneTimerSecond(void) if(systicks - timerSecond >= ONE_TIMER_SECOND) { timerSecond= systicks; - if(powerOn_count <= 10) + if(powerOn_count <= 15) { powerOn_count++; // DUG_PRINTF("iot got_heartbeat_flag:%d",got_heartbeat_flag); - if(powerOn_count == 10 && got_heartbeat_flag >= 3) //¿ª»ú10¼ì²éÒ»´ÎÊÇ·ñÐèÒª·¢ËÍmcuÐÅÏ¢ + if(powerOn_count % 5 == 0 && got_heartbeat_flag >= 3) //¿ª»ú10¼ì²éÒ»´ÎÊÇ·ñÐèÒª·¢ËÍmcuÐÅÏ¢ { Iot_Send_Mcu_Info(); Iot_Uart_Tx_Query_Add(0x0A, NULL, 0); @@ -467,7 +467,7 @@ void Iot_Uart_Tx_Query_Process(void) // DUG_PRINTF("iot_uart_tx_query[0].size %d\n",iot_uart_tx_query[0].size); #if (1) // DUG_PRINTF("iot iot_uart_tx_query[0].size£º%d\n",iot_uart_tx_query[0].size); - if(iot_uart_tx_query[0].buffer[0] != 0xb7 || iot_uart_tx_query[0].buffer[0] != 0xe0 ){ + if(iot_uart_tx_query[0].buffer[0] != 0xb7 && iot_uart_tx_query[0].buffer[0] != 0xe0 ){ DUG_PRINTF("iot send:\n"); // for(uint8_t i=0;i