mirror of
https://github.com/goldenfishs/MRobot.git
synced 2026-04-01 05:17:13 +08:00
重构User_code目录结构:将文件组织到子文件夹中
主要更改: - 将所有BSP外设文件移动到独立子文件夹(can/, fdcan/, uart/等) - 将所有Component文件移动到独立子文件夹(pid/, filter/, cmd/等) - 将所有Device文件移动到独立子文件夹(dr16/, bmi088/等) - 更新代码生成器以支持新的文件夹结构 - 保持向后兼容性,支持从子文件夹或根目录加载模板 - 添加STRUCTURE.md文档说明新的目录结构 优势: ✅ 更好的代码组织和管理 ✅ 便于添加、删除、修改模板 ✅ 清晰的模块划分 ✅ 向后兼容现有结构
This commit is contained in:
@@ -240,12 +240,18 @@ class DeviceSimple(QWidget):
|
||||
# 获取BSP配置
|
||||
bsp_config = self.get_bsp_config()
|
||||
|
||||
# 复制并修改文件
|
||||
template_dir = self._get_device_template_dir()
|
||||
# 使用设备名称作为子文件夹名(小写)
|
||||
device_folder = self.device_name.lower()
|
||||
template_base_dir = CodeGenerator.get_assets_dir("User_code/device")
|
||||
files = self.device_config.get('files', {})
|
||||
|
||||
for file_type, filename in files.items():
|
||||
src_path = os.path.join(template_dir, filename)
|
||||
# 先尝试从子文件夹加载
|
||||
src_path = os.path.join(template_base_dir, device_folder, filename)
|
||||
if not os.path.exists(src_path):
|
||||
# 如果子文件夹不存在,尝试从根目录加载(向后兼容)
|
||||
src_path = os.path.join(template_base_dir, filename)
|
||||
|
||||
dst_path = os.path.join(self.project_path, f"User/device/{filename}")
|
||||
|
||||
if os.path.exists(src_path):
|
||||
|
||||
Reference in New Issue
Block a user