From b283120bf0d11fc252c9197090d3061f0ee57741 Mon Sep 17 00:00:00 2001
From: Hans Christian Olaussen <41271048+klutvott123@users.noreply.github.com>
Date: Sun, 4 Apr 2021 15:11:57 +0200
Subject: [PATCH] Mcu ID for lua vtx table
Use mcu ID as filename for the vtx table .lua file.
---
locales/en/messages.json | 2 +-
src/js/tabs/vtx.js | 13 +++++--------
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/locales/en/messages.json b/locales/en/messages.json
index d0482008..6a30440a 100644
--- a/locales/en/messages.json
+++ b/locales/en/messages.json
@@ -5673,7 +5673,7 @@
"description": "Save Lua script button in the VTX tab"
},
"vtxLuaFileHelp" :{
- "message": "The '$t(vtxButtonSaveLua.message)' button will allow you to save a craftname.lua file containing the vtx table configuration that can be used with the betaflight lua scripts. (See more here.)",
+ "message": "The '$t(vtxButtonSaveLua.message)' button will allow you to save a mcuid.lua file containing the VTX table configuration that can be used with the Betaflight TX Lua Scripts.
Version 1.6.0 and above can use the file as is, but for older versions of the scripts it should be renamed to match the modelname on the TX.",
"description": "Tooltip message for the Save Lua script button in the VTX tab"
},
"vtxButtonLoadFile": {
diff --git a/src/js/tabs/vtx.js b/src/js/tabs/vtx.js
index c394d7d6..c6c32952 100644
--- a/src/js/tabs/vtx.js
+++ b/src/js/tabs/vtx.js
@@ -608,16 +608,13 @@ TABS.vtx.initialize = function (callback) {
}
function save_lua() {
- const suggestedName = 'model01';
const suffix = 'lua';
- let filename;
- if(FC.CONFIG.name && FC.CONFIG.name.trim() !== '') {
- filename = FC.CONFIG.name.trim().replace(' ', '_');
- }else{
- filename = suggestedName;
- }
- filename += `.${suffix}`;
+ const uid0 = FC.CONFIG.uid[0].toString(16).padStart(8, '0');
+ const uid1 = FC.CONFIG.uid[1].toString(16).padStart(8, '0');
+ const uid2 = FC.CONFIG.uid[2].toString(16).padStart(8, '0');
+
+ const filename = `${uid0}${uid1}${uid2}.${suffix}`;
const accepts = [{
description: `${suffix.toUpperCase()} files`, extensions: [suffix],