diff --git a/src/SCRIPTS/BF/CONFIRM/acc_cal.lua b/src/SCRIPTS/BF/CONFIRM/acc_cal.lua index 1294e5c0..41a3c8de 100644 --- a/src/SCRIPTS/BF/CONFIRM/acc_cal.lua +++ b/src/SCRIPTS/BF/CONFIRM/acc_cal.lua @@ -1,9 +1,4 @@ -local template = loadScript(radio.templateHome.."acc_cal.lua") -if template then - template = template() -else - template = assert(loadScript(radio.templateHome.."default_template.lua"))() -end +local template = assert(loadScript(radio.template))() local margin = template.margin local indent = template.indent local lineSpacing = template.lineSpacing diff --git a/src/SCRIPTS/BF/CONFIRM/vtx_tables.lua b/src/SCRIPTS/BF/CONFIRM/vtx_tables.lua index 33d98dc5..5d51e617 100644 --- a/src/SCRIPTS/BF/CONFIRM/vtx_tables.lua +++ b/src/SCRIPTS/BF/CONFIRM/vtx_tables.lua @@ -1,9 +1,4 @@ -local template = loadScript(radio.templateHome.."vtx_tables.lua") -if template then - template = template() -else - template = assert(loadScript(radio.templateHome.."default_template.lua"))() -end +local template = assert(loadScript(radio.template))() local margin = template.margin local indent = template.indent local lineSpacing = template.lineSpacing diff --git a/src/SCRIPTS/BF/PAGES/failsafe.lua b/src/SCRIPTS/BF/PAGES/failsafe.lua index 39298c37..1ce6fbaa 100644 --- a/src/SCRIPTS/BF/PAGES/failsafe.lua +++ b/src/SCRIPTS/BF/PAGES/failsafe.lua @@ -1,9 +1,4 @@ -local template = loadScript(radio.templateHome.."failsafe.lua") -if template then - template = template() -else - template = assert(loadScript(radio.templateHome.."default_template.lua"))() -end +local template = assert(loadScript(radio.template))() local margin = template.margin local indent = template.indent local lineSpacing = template.lineSpacing diff --git a/src/SCRIPTS/BF/PAGES/filters1.lua b/src/SCRIPTS/BF/PAGES/filters1.lua index 430d566d..68db6c8e 100644 --- a/src/SCRIPTS/BF/PAGES/filters1.lua +++ b/src/SCRIPTS/BF/PAGES/filters1.lua @@ -1,9 +1,4 @@ -local template = loadScript(radio.templateHome.."filters1.lua") -if template then - template = template() -else - template = assert(loadScript(radio.templateHome.."default_template.lua"))() -end +local template = assert(loadScript(radio.template))() local margin = template.margin local indent = template.indent local lineSpacing = template.lineSpacing diff --git a/src/SCRIPTS/BF/PAGES/filters2.lua b/src/SCRIPTS/BF/PAGES/filters2.lua index 5984a61c..bf16d411 100644 --- a/src/SCRIPTS/BF/PAGES/filters2.lua +++ b/src/SCRIPTS/BF/PAGES/filters2.lua @@ -1,9 +1,4 @@ -local template = loadScript(radio.templateHome.."filters2.lua") -if template then - template = template() -else - template = assert(loadScript(radio.templateHome.."default_template.lua"))() -end +local template = assert(loadScript(radio.template))() local margin = template.margin local indent = template.indent local lineSpacing = template.lineSpacing diff --git a/src/SCRIPTS/BF/PAGES/gpspids.lua b/src/SCRIPTS/BF/PAGES/gpspids.lua index dd6af065..95382972 100644 --- a/src/SCRIPTS/BF/PAGES/gpspids.lua +++ b/src/SCRIPTS/BF/PAGES/gpspids.lua @@ -1,9 +1,4 @@ -local template = loadScript(radio.templateHome.."gpspids.lua") -if template then - template = template() -else - template = assert(loadScript(radio.templateHome.."default_template.lua"))() -end +local template = assert(loadScript(radio.template))() local margin = template.margin local indent = template.indent local lineSpacing = template.lineSpacing diff --git a/src/SCRIPTS/BF/PAGES/pid_advanced.lua b/src/SCRIPTS/BF/PAGES/pid_advanced.lua index fd596d5f..8a364b4c 100644 --- a/src/SCRIPTS/BF/PAGES/pid_advanced.lua +++ b/src/SCRIPTS/BF/PAGES/pid_advanced.lua @@ -1,9 +1,4 @@ -local template = loadScript(radio.templateHome.."pid_advanced.lua") -if template then - template = template() -else - template = assert(loadScript(radio.templateHome.."default_template.lua"))() -end +local template = assert(loadScript(radio.template))() local margin = template.margin local indent = template.indent local lineSpacing = template.lineSpacing diff --git a/src/SCRIPTS/BF/PAGES/pids1.lua b/src/SCRIPTS/BF/PAGES/pids1.lua index b3e9830f..ec829c3d 100644 --- a/src/SCRIPTS/BF/PAGES/pids1.lua +++ b/src/SCRIPTS/BF/PAGES/pids1.lua @@ -1,9 +1,4 @@ -local template = loadScript(radio.templateHome.."pids1.lua") -if template then - template = template() -else - template = assert(loadScript(radio.templateHome.."default_template.lua"))() -end +local template = assert(loadScript(radio.template))() local margin = template.margin local indent = template.indent local lineSpacing = template.lineSpacing diff --git a/src/SCRIPTS/BF/PAGES/pids2.lua b/src/SCRIPTS/BF/PAGES/pids2.lua index 2e56efdf..009591d6 100644 --- a/src/SCRIPTS/BF/PAGES/pids2.lua +++ b/src/SCRIPTS/BF/PAGES/pids2.lua @@ -1,9 +1,4 @@ -local template = loadScript(radio.templateHome.."pids2.lua") -if template then - template = template() -else - template = assert(loadScript(radio.templateHome.."default_template.lua"))() -end +local template = assert(loadScript(radio.template))() local margin = template.margin local indent = template.indent local lineSpacing = template.lineSpacing diff --git a/src/SCRIPTS/BF/PAGES/pwm.lua b/src/SCRIPTS/BF/PAGES/pwm.lua index a6531c5e..882e755b 100644 --- a/src/SCRIPTS/BF/PAGES/pwm.lua +++ b/src/SCRIPTS/BF/PAGES/pwm.lua @@ -1,9 +1,4 @@ -local template = loadScript(radio.templateHome.."pwm.lua") -if template then - template = template() -else - template = assert(loadScript(radio.templateHome.."default_template.lua"))() -end +local template = assert(loadScript(radio.template))() local margin = template.margin local indent = template.indent local lineSpacing = template.lineSpacing diff --git a/src/SCRIPTS/BF/PAGES/rates.lua b/src/SCRIPTS/BF/PAGES/rates.lua index 927b74aa..355674fb 100644 --- a/src/SCRIPTS/BF/PAGES/rates.lua +++ b/src/SCRIPTS/BF/PAGES/rates.lua @@ -1,9 +1,4 @@ -local template = loadScript(radio.templateHome.."rates.lua") -if template then - template = template() -else - template = assert(loadScript(radio.templateHome.."default_template.lua"))() -end +local template = assert(loadScript(radio.template))() local margin = template.margin local indent = template.indent local lineSpacing = template.lineSpacing diff --git a/src/SCRIPTS/BF/PAGES/rescue.lua b/src/SCRIPTS/BF/PAGES/rescue.lua index a409add9..c3bc9a2b 100644 --- a/src/SCRIPTS/BF/PAGES/rescue.lua +++ b/src/SCRIPTS/BF/PAGES/rescue.lua @@ -1,9 +1,4 @@ -local template = loadScript(radio.templateHome.."rescue.lua") -if template then - template = template() -else - template = assert(loadScript(radio.templateHome.."default_template.lua"))() -end +local template = assert(loadScript(radio.template))() local margin = template.margin local indent = template.indent local lineSpacing = template.lineSpacing diff --git a/src/SCRIPTS/BF/PAGES/rx.lua b/src/SCRIPTS/BF/PAGES/rx.lua index 9fa40d2e..c6099cb4 100644 --- a/src/SCRIPTS/BF/PAGES/rx.lua +++ b/src/SCRIPTS/BF/PAGES/rx.lua @@ -1,9 +1,4 @@ -local template = loadScript(radio.templateHome.."rx.lua") -if template then - template = template() -else - template = assert(loadScript(radio.templateHome.."default_template.lua"))() -end +local template = assert(loadScript(radio.template))() local margin = template.margin local indent = template.indent local lineSpacing = template.lineSpacing diff --git a/src/SCRIPTS/BF/PAGES/simplified_tuning.lua b/src/SCRIPTS/BF/PAGES/simplified_tuning.lua index 49c31303..8701d383 100644 --- a/src/SCRIPTS/BF/PAGES/simplified_tuning.lua +++ b/src/SCRIPTS/BF/PAGES/simplified_tuning.lua @@ -1,9 +1,4 @@ -local template = loadScript(radio.templateHome.."simplified_pids.lua") -if template then - template = template() -else - template = assert(loadScript(radio.templateHome.."default_template.lua"))() -end +local template = assert(loadScript(radio.template))() local margin = template.margin local indent = template.indent local lineSpacing = template.lineSpacing diff --git a/src/SCRIPTS/BF/PAGES/vtx.lua b/src/SCRIPTS/BF/PAGES/vtx.lua index 6b4bca9d..e957b225 100644 --- a/src/SCRIPTS/BF/PAGES/vtx.lua +++ b/src/SCRIPTS/BF/PAGES/vtx.lua @@ -1,17 +1,4 @@ -local vtx_tables -if apiVersion >= 1.042 then - vtx_tables = assert(loadScript("/BF/VTX/"..mcuId..".lua"))() -else - vtx_tables = assert(loadScript("/BF/VTX/vtx_defaults.lua"))() -end -local deviceTable = { [1]="6705", [3]="SA", [4]="Tramp", [255]="None" } -local pitModeTable = { [0]="OFF", "ON" } -local template = loadScript(radio.templateHome.."vtx.lua") -if template then - template = template() -else - template = assert(loadScript(radio.templateHome.."default_template.lua"))() -end +local template = assert(loadScript(radio.template))() local margin = template.margin local indent = template.indent local lineSpacing = template.lineSpacing @@ -24,6 +11,15 @@ local inc = { x = function(val) x = x + val return x end, y = function(val) y = local labels = {} local fields = {} +local vtx_tables +if apiVersion >= 1.042 then + vtx_tables = assert(loadScript("/BF/VTX/"..mcuId..".lua"))() +else + vtx_tables = assert(loadScript("/BF/VTX/vtx_defaults.lua"))() +end +local deviceTable = { [1]="6705", [3]="SA", [4]="Tramp", [255]="None" } +local pitModeTable = { [0]="OFF", "ON" } + if apiVersion >= 1.036 then fields[#fields + 1] = { t = "Band", x = x, y = inc.y(lineSpacing), sp = x + sp, min=0, max=#(vtx_tables.bandTable), vals = { 2 }, table = vtx_tables.bandTable, upd = function(self) self.handleBandChanUpdate(self) end } fields[#fields + 1] = { t = "Channel", x = x, y = inc.y(lineSpacing), sp = x + sp, min=1, max=vtx_tables.frequenciesPerBand, vals = { 3 }, upd = function(self) self.handleBandChanUpdate(self) end } diff --git a/src/SCRIPTS/BF/TEMPLATES/128x64/default_template.lua b/src/SCRIPTS/BF/TEMPLATES/128x64.lua similarity index 100% rename from src/SCRIPTS/BF/TEMPLATES/128x64/default_template.lua rename to src/SCRIPTS/BF/TEMPLATES/128x64.lua diff --git a/src/SCRIPTS/BF/TEMPLATES/128x96/default_template.lua b/src/SCRIPTS/BF/TEMPLATES/128x96.lua similarity index 100% rename from src/SCRIPTS/BF/TEMPLATES/128x96/default_template.lua rename to src/SCRIPTS/BF/TEMPLATES/128x96.lua diff --git a/src/SCRIPTS/BF/TEMPLATES/212x64/default_template.lua b/src/SCRIPTS/BF/TEMPLATES/212x64.lua similarity index 100% rename from src/SCRIPTS/BF/TEMPLATES/212x64/default_template.lua rename to src/SCRIPTS/BF/TEMPLATES/212x64.lua diff --git a/src/SCRIPTS/BF/TEMPLATES/320x480/default_template.lua b/src/SCRIPTS/BF/TEMPLATES/320x480.lua similarity index 100% rename from src/SCRIPTS/BF/TEMPLATES/320x480/default_template.lua rename to src/SCRIPTS/BF/TEMPLATES/320x480.lua diff --git a/src/SCRIPTS/BF/TEMPLATES/480x272/default_template.lua b/src/SCRIPTS/BF/TEMPLATES/480x272.lua similarity index 100% rename from src/SCRIPTS/BF/TEMPLATES/480x272/default_template.lua rename to src/SCRIPTS/BF/TEMPLATES/480x272.lua diff --git a/src/SCRIPTS/BF/radios.lua b/src/SCRIPTS/BF/radios.lua index eccc21c2..13eecaa8 100644 --- a/src/SCRIPTS/BF/radios.lua +++ b/src/SCRIPTS/BF/radios.lua @@ -3,13 +3,13 @@ local supportedRadios = ["128x64"] = { msp = { - templateHome = "TEMPLATES/128x64/", - MenuBox = { x=15, y=12, w=100, x_offset=36, h_line=8, h_offset=3 }, - SaveBox = { x=15, y=12, w=100, x_offset=4, h=30, h_offset=5 }, - NoTelem = { 30, 55, "No Telemetry", BLINK }, - textSize = SMLSIZE, - yMinLimit = 12, - yMaxLimit = 52, + template = "TEMPLATES/128x64.lua", + MenuBox = { x=15, y=12, w=100, x_offset=36, h_line=8, h_offset=3 }, + SaveBox = { x=15, y=12, w=100, x_offset=4, h=30, h_offset=5 }, + NoTelem = { 30, 55, "No Telemetry", BLINK }, + textSize = SMLSIZE, + yMinLimit = 12, + yMaxLimit = 52, }, cms = { rows = 8, @@ -30,13 +30,13 @@ local supportedRadios = ["128x96"] = { msp = { - templateHome = "TEMPLATES/128x96/", - MenuBox = { x=15, y=12, w=100, x_offset=36, h_line=8, h_offset=3 }, - SaveBox = { x=15, y=12, w=100, x_offset=4, h=30, h_offset=5 }, - NoTelem = { 30, 87, "No Telemetry", BLINK }, - textSize = SMLSIZE, - yMinLimit = 12, - yMaxLimit = 84, + template = "TEMPLATES/128x96.lua", + MenuBox = { x=15, y=12, w=100, x_offset=36, h_line=8, h_offset=3 }, + SaveBox = { x=15, y=12, w=100, x_offset=4, h=30, h_offset=5 }, + NoTelem = { 30, 87, "No Telemetry", BLINK }, + textSize = SMLSIZE, + yMinLimit = 12, + yMaxLimit = 84, }, cms = { rows = 12, @@ -57,13 +57,13 @@ local supportedRadios = ["212x64"] = { msp = { - templateHome = "TEMPLATES/212x64/", - MenuBox = { x=40, y=12, w=120, x_offset=36, h_line=8, h_offset=3 }, - SaveBox = { x=40, y=12, w=120, x_offset=4, h=30, h_offset=5 }, - NoTelem = { 70, 55, "No Telemetry", BLINK }, - textSize = SMLSIZE, - yMinLimit = 12, - yMaxLimit = 52, + template = "TEMPLATES/212x64.lua", + MenuBox = { x=40, y=12, w=120, x_offset=36, h_line=8, h_offset=3 }, + SaveBox = { x=40, y=12, w=120, x_offset=4, h=30, h_offset=5 }, + NoTelem = { 70, 55, "No Telemetry", BLINK }, + textSize = SMLSIZE, + yMinLimit = 12, + yMaxLimit = 52, }, cms = { rows = 8, @@ -84,14 +84,14 @@ local supportedRadios = ["480x272"] = { msp = { - templateHome = "TEMPLATES/480x272/", - highRes = true, - MenuBox = { x=120, y=100, w=200, x_offset=68, h_line=20, h_offset=6 }, - SaveBox = { x=120, y=100, w=180, x_offset=12, h=60, h_offset=12 }, - NoTelem = { 192, LCD_H - 28, "No Telemetry", (TEXT_COLOR or 0) + INVERS + BLINK }, - textSize = 0, - yMinLimit = 35, - yMaxLimit = 235, + template = "TEMPLATES/480x272.lua", + highRes = true, + MenuBox = { x=120, y=100, w=200, x_offset=68, h_line=20, h_offset=6 }, + SaveBox = { x=120, y=100, w=180, x_offset=12, h=60, h_offset=12 }, + NoTelem = { 192, LCD_H - 28, "No Telemetry", (TEXT_COLOR or 0) + INVERS + BLINK }, + textSize = 0, + yMinLimit = 35, + yMaxLimit = 235, }, cms = { rows = 9, @@ -112,14 +112,14 @@ local supportedRadios = ["320x480"] = { msp = { - templateHome = "TEMPLATES/320x480/", - highRes = true, - MenuBox = { x= (LCD_W -200)/2, y=LCD_H/2, w=200, x_offset=68, h_line=20, h_offset=6 }, - SaveBox = { x= (LCD_W -200)/2, y=LCD_H/2, w=180, x_offset=12, h=60, h_offset=12 }, - NoTelem = { LCD_W/2 - 50, LCD_H - 28, "No Telemetry", (TEXT_COLOR or 0) + INVERS + BLINK }, - textSize = 0, - yMinLimit = 35, - yMaxLimit = 435, + template = "TEMPLATES/320x480.lua", + highRes = true, + MenuBox = { x= (LCD_W -200)/2, y=LCD_H/2, w=200, x_offset=68, h_line=20, h_offset=6 }, + SaveBox = { x= (LCD_W -200)/2, y=LCD_H/2, w=180, x_offset=12, h=60, h_offset=12 }, + NoTelem = { LCD_W/2 - 50, LCD_H - 28, "No Telemetry", (TEXT_COLOR or 0) + INVERS + BLINK }, + textSize = 0, + yMinLimit = 35, + yMaxLimit = 435, }, cms = nil, },