From 34a0874156e627e6f7e4f5de3be57344f9e9f70c Mon Sep 17 00:00:00 2001 From: Robofish <1683502971@qq.com> Date: Fri, 20 Jun 2025 00:54:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=84=E7=A7=8D=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- MRobot.iss | 2 +- MRobot.py | 8 ++++++-- User_code/task/init.c.template | 1 - User_code/task/task.c.template | 2 +- User_code/task/user_task.c.template | 1 + User_code/task/user_task.h.template | 1 + 7 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 9a8a9c7..382ead6 100644 --- a/.gitignore +++ b/.gitignore @@ -31,4 +31,5 @@ Examples/ build/ dist/ -*.spec \ No newline at end of file +*.spec +*.exe \ No newline at end of file diff --git a/MRobot.iss b/MRobot.iss index 450a7f2..dc26181 100644 --- a/MRobot.iss +++ b/MRobot.iss @@ -1,6 +1,6 @@ [Setup] AppName=MRobot -AppVersion=1.0 +AppVersion=1.0.1 DefaultDirName={userappdata}\MRobot DefaultGroupName=MRobot OutputDir=. diff --git a/MRobot.py b/MRobot.py index 9bcc590..58caa56 100644 --- a/MRobot.py +++ b/MRobot.py @@ -52,7 +52,7 @@ from qfluentwidgets import ( from urllib.parse import quote from packaging.version import parse as vparse -__version__ = "1.0.0" +__version__ = "1.0.1" # ===================== 页面基类 ===================== class BaseInterface(QWidget): @@ -665,7 +665,7 @@ class DataInterface(BaseInterface): # 2. 在 /* USER CODE BEGIN RTOS_THREADS */ 区域添加 osThreadNew(Task_Init, NULL, &attr_init); rtos_threads_pattern = r'(\/\* *USER CODE BEGIN RTOS_THREADS *\*\/\s*)(.*?)(\/\* *USER CODE END RTOS_THREADS *\*\/)' match = re.search(rtos_threads_pattern, code, re.DOTALL) - task_line = ' initTaskHandle = osThreadNew(Task_Init, NULL, &attr_init); // 创建初始化任务\n' + task_line = ' osThreadNew(Task_Init, NULL, &attr_init); // 创建初始化任务\n' if match: threads_code = match.group(2) if 'Task_Init' not in threads_code: @@ -1026,6 +1026,10 @@ class DataInterface(BaseInterface): with open(task_c_path, "w", encoding="utf-8") as f: f.write(code) + # ----------- 保存任务配置到 config.yaml ----------- + config_yaml_path = os.path.join(output_dir, "config.yaml") + with open(config_yaml_path, "w", encoding="utf-8") as f: + yaml.safe_dump(task_list, f, allow_unicode=True) # ===================== 串口终端界面 ===================== class SerialReadThread(QThread): data_received = pyqtSignal(str) diff --git a/User_code/task/init.c.template b/User_code/task/init.c.template index 3e9b49d..87a1061 100644 --- a/User_code/task/init.c.template +++ b/User_code/task/init.c.template @@ -40,4 +40,3 @@ void Task_Init(void *argument) { osKernelUnlock(); // 解锁内核 osThreadTerminate(osThreadGetId()); // 任务完成后结束自身 } - diff --git a/User_code/task/task.c.template b/User_code/task/task.c.template index e9f49b5..0f5d936 100644 --- a/User_code/task/task.c.template +++ b/User_code/task/task.c.template @@ -54,4 +54,4 @@ void {{task_function}}(void *argument) { osDelay(1); /* 默认1ms延时,防止死循环卡死CPU */ } {% endif %} -} \ No newline at end of file +} diff --git a/User_code/task/user_task.c.template b/User_code/task/user_task.c.template index 69f49f0..c2e6c5d 100644 --- a/User_code/task/user_task.c.template +++ b/User_code/task/user_task.c.template @@ -10,3 +10,4 @@ const osThreadAttr_t attr_init = { /* User_task */ {{task_attr_definitions}} + diff --git a/User_code/task/user_task.h.template b/User_code/task/user_task.h.template index 79b7476..08ae301 100644 --- a/User_code/task/user_task.h.template +++ b/User_code/task/user_task.h.template @@ -78,3 +78,4 @@ void Task_Init(void *argument); #ifdef __cplusplus } #endif +