mirror of
https://github.com/goldenfishs/MRobot.git
synced 2025-04-28 23:39:55 +08:00
Compare commits
2 Commits
2dc317f5ce
...
d56490f92f
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d56490f92f | ||
![]() |
b9b0053baa |
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -1,5 +1,7 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"uart.h": "c"
|
||||
"uart.h": "c",
|
||||
"device.h": "c",
|
||||
"pc_uart.h": "c"
|
||||
}
|
||||
}
|
34
MRobot.py
34
MRobot.py
@ -5,7 +5,7 @@ import shutil
|
||||
import re
|
||||
from git import Repo
|
||||
from collections import defaultdict
|
||||
|
||||
import csv
|
||||
|
||||
# 配置常量
|
||||
REPO_DIR = "MRobot_repo"
|
||||
@ -278,12 +278,28 @@ class MRobotApp:
|
||||
|
||||
# 更新 .h 文件复选框
|
||||
def update_header_files(self):
|
||||
# 清空现有的复选框
|
||||
for widget in self.header_files_frame.winfo_children():
|
||||
widget.destroy()
|
||||
|
||||
# 定义需要处理的文件夹
|
||||
folders = ["bsp", "component", "device", "module"]
|
||||
|
||||
# 存储依赖关系
|
||||
dependencies = defaultdict(list)
|
||||
|
||||
# 遍历文件夹,读取 dependencies.csv 文件
|
||||
for folder in folders:
|
||||
folder_dir = os.path.join(REPO_DIR, "User", folder)
|
||||
if os.path.exists(folder_dir):
|
||||
dependencies_file = os.path.join(folder_dir, "dependencies.csv")
|
||||
if os.path.exists(dependencies_file):
|
||||
with open(dependencies_file, "r", encoding="utf-8") as f:
|
||||
reader = csv.reader(f)
|
||||
for row in reader:
|
||||
if len(row) == 2:
|
||||
dependencies[row[0]].append(row[1])
|
||||
# 创建复选框
|
||||
for folder in folders:
|
||||
folder_dir = os.path.join(REPO_DIR, "User", folder)
|
||||
if os.path.exists(folder_dir):
|
||||
@ -304,15 +320,27 @@ class MRobotApp:
|
||||
module_frame,
|
||||
text=file_base,
|
||||
variable=var,
|
||||
wraplength=150 # 设置文本换行宽度
|
||||
wraplength=150, # 设置文本换行宽度
|
||||
command=lambda fb=file_base: self.handle_dependencies(fb, dependencies)
|
||||
)
|
||||
checkbox.grid(row=row, column=col, padx=5, pady=5, sticky="w")
|
||||
# 控制列数,达到一定数量后换行
|
||||
col += 1
|
||||
if col >= 6: # 每行最多显示 3 个复选框
|
||||
if col >= 6: # 每行最多显示 6 个复选框
|
||||
col = 0
|
||||
row += 1
|
||||
|
||||
def handle_dependencies(self, file_base, dependencies):
|
||||
"""
|
||||
根据依赖关系自动勾选相关模块
|
||||
"""
|
||||
if file_base in self.header_file_vars and self.header_file_vars[file_base].get():
|
||||
# 如果当前模块被选中,自动勾选其依赖项
|
||||
for dependency in dependencies.get(file_base, []):
|
||||
dep_base = os.path.basename(dependency)
|
||||
if dep_base in self.header_file_vars:
|
||||
self.header_file_vars[dep_base].set(True)
|
||||
|
||||
# 在 MRobotApp 类中添加以下方法
|
||||
def generate_task_files(self):
|
||||
try:
|
||||
|
1
User/device/dependencies.csv
Normal file
1
User/device/dependencies.csv
Normal file
@ -0,0 +1 @@
|
||||
oled_i2c,bsp/i2c
|
|
@ -1,5 +1,5 @@
|
||||
/* Includes ----------------------------------------------------------------- */
|
||||
#include "uart.h"
|
||||
#include "pc_uart.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -50,5 +50,5 @@ int8_t UART_StartSend(UART_t *huart)
|
||||
{
|
||||
return DEVICE_OK
|
||||
}
|
||||
return DEVICE_ERROR;
|
||||
return DEVICE_ERR;
|
||||
}
|
Loading…
Reference in New Issue
Block a user