From 587d8a932e45fa837c994eca4c8d44e121f972fc Mon Sep 17 00:00:00 2001 From: 3djc Date: Fri, 12 Jul 2019 17:18:11 +0200 Subject: [PATCH] Some sdcard tidy up --- .../{SxR => SxR Calibrate}/SxR_Calibrate.lua | 0 .../horus/{SxR => SxR Calibrate}/img/back.png | Bin .../{SxR => SxR Calibrate}/img/delta_b.png | Bin .../horus/{SxR => SxR Calibrate}/img/done.bmp | Bin .../horus/{SxR => SxR Calibrate}/img/down.png | Bin .../{SxR => SxR Calibrate}/img/forward.png | Bin .../horus/{SxR => SxR Calibrate}/img/left.png | Bin .../{SxR => SxR Calibrate}/img/plane_b.png | Bin .../{SxR => SxR Calibrate}/img/planev_b.png | Bin .../{SxR => SxR Calibrate}/img/planev_s.png | Bin .../{SxR => SxR Calibrate}/img/right.png | Bin .../horus/{SxR => SxR Calibrate}/img/up.png | Bin .../{SxR => SxR Calibrate}/img/vert-r.png | Bin .../horus/{SxR => SxR Calibrate}/img/vert.png | Bin radio/sdcard/horus/SxR/SxR.lua | 318 ------------------ .../{SxR => SxR Calibrate}/SxR_Calibrate.lua | 0 radio/sdcard/taranis-x7/SxR/SxR.lua | 278 --------------- .../{SxR => SxR Calibrate}/SxR_Calibrate.lua | 0 .../{SxR => SxR Calibrate}/bmp/back.bmp | Bin .../{SxR => SxR Calibrate}/bmp/delta.bmp | Bin .../{SxR => SxR Calibrate}/bmp/done.bmp | Bin .../{SxR => SxR Calibrate}/bmp/down.bmp | Bin .../{SxR => SxR Calibrate}/bmp/forward.bmp | Bin .../{SxR => SxR Calibrate}/bmp/horz-r.bmp | Bin .../{SxR => SxR Calibrate}/bmp/horz.bmp | Bin .../{SxR => SxR Calibrate}/bmp/left.bmp | Bin .../{SxR => SxR Calibrate}/bmp/plane.bmp | Bin .../{SxR => SxR Calibrate}/bmp/right.bmp | Bin .../{SxR => SxR Calibrate}/bmp/up.bmp | Bin .../{SxR => SxR Calibrate}/bmp/vert-r.bmp | Bin .../{SxR => SxR Calibrate}/bmp/vert.bmp | Bin .../{SxR => SxR Calibrate}/bmp/vtail.bmp | Bin radio/sdcard/taranis-x9/SxR/SxR.lua | 280 --------------- 33 files changed, 876 deletions(-) rename radio/sdcard/horus/{SxR => SxR Calibrate}/SxR_Calibrate.lua (100%) rename radio/sdcard/horus/{SxR => SxR Calibrate}/img/back.png (100%) rename radio/sdcard/horus/{SxR => SxR Calibrate}/img/delta_b.png (100%) rename radio/sdcard/horus/{SxR => SxR Calibrate}/img/done.bmp (100%) rename radio/sdcard/horus/{SxR => SxR Calibrate}/img/down.png (100%) rename radio/sdcard/horus/{SxR => SxR Calibrate}/img/forward.png (100%) rename radio/sdcard/horus/{SxR => SxR Calibrate}/img/left.png (100%) rename radio/sdcard/horus/{SxR => SxR Calibrate}/img/plane_b.png (100%) rename radio/sdcard/horus/{SxR => SxR Calibrate}/img/planev_b.png (100%) rename radio/sdcard/horus/{SxR => SxR Calibrate}/img/planev_s.png (100%) rename radio/sdcard/horus/{SxR => SxR Calibrate}/img/right.png (100%) rename radio/sdcard/horus/{SxR => SxR Calibrate}/img/up.png (100%) rename radio/sdcard/horus/{SxR => SxR Calibrate}/img/vert-r.png (100%) rename radio/sdcard/horus/{SxR => SxR Calibrate}/img/vert.png (100%) delete mode 100755 radio/sdcard/horus/SxR/SxR.lua rename radio/sdcard/taranis-x7/{SxR => SxR Calibrate}/SxR_Calibrate.lua (100%) delete mode 100644 radio/sdcard/taranis-x7/SxR/SxR.lua rename radio/sdcard/taranis-x9/{SxR => SxR Calibrate}/SxR_Calibrate.lua (100%) rename radio/sdcard/taranis-x9/{SxR => SxR Calibrate}/bmp/back.bmp (100%) rename radio/sdcard/taranis-x9/{SxR => SxR Calibrate}/bmp/delta.bmp (100%) rename radio/sdcard/taranis-x9/{SxR => SxR Calibrate}/bmp/done.bmp (100%) rename radio/sdcard/taranis-x9/{SxR => SxR Calibrate}/bmp/down.bmp (100%) rename radio/sdcard/taranis-x9/{SxR => SxR Calibrate}/bmp/forward.bmp (100%) rename radio/sdcard/taranis-x9/{SxR => SxR Calibrate}/bmp/horz-r.bmp (100%) rename radio/sdcard/taranis-x9/{SxR => SxR Calibrate}/bmp/horz.bmp (100%) rename radio/sdcard/taranis-x9/{SxR => SxR Calibrate}/bmp/left.bmp (100%) rename radio/sdcard/taranis-x9/{SxR => SxR Calibrate}/bmp/plane.bmp (100%) rename radio/sdcard/taranis-x9/{SxR => SxR Calibrate}/bmp/right.bmp (100%) rename radio/sdcard/taranis-x9/{SxR => SxR Calibrate}/bmp/up.bmp (100%) rename radio/sdcard/taranis-x9/{SxR => SxR Calibrate}/bmp/vert-r.bmp (100%) rename radio/sdcard/taranis-x9/{SxR => SxR Calibrate}/bmp/vert.bmp (100%) rename radio/sdcard/taranis-x9/{SxR => SxR Calibrate}/bmp/vtail.bmp (100%) delete mode 100644 radio/sdcard/taranis-x9/SxR/SxR.lua diff --git a/radio/sdcard/horus/SxR/SxR_Calibrate.lua b/radio/sdcard/horus/SxR Calibrate/SxR_Calibrate.lua similarity index 100% rename from radio/sdcard/horus/SxR/SxR_Calibrate.lua rename to radio/sdcard/horus/SxR Calibrate/SxR_Calibrate.lua diff --git a/radio/sdcard/horus/SxR/img/back.png b/radio/sdcard/horus/SxR Calibrate/img/back.png similarity index 100% rename from radio/sdcard/horus/SxR/img/back.png rename to radio/sdcard/horus/SxR Calibrate/img/back.png diff --git a/radio/sdcard/horus/SxR/img/delta_b.png b/radio/sdcard/horus/SxR Calibrate/img/delta_b.png similarity index 100% rename from radio/sdcard/horus/SxR/img/delta_b.png rename to radio/sdcard/horus/SxR Calibrate/img/delta_b.png diff --git a/radio/sdcard/horus/SxR/img/done.bmp b/radio/sdcard/horus/SxR Calibrate/img/done.bmp similarity index 100% rename from radio/sdcard/horus/SxR/img/done.bmp rename to radio/sdcard/horus/SxR Calibrate/img/done.bmp diff --git a/radio/sdcard/horus/SxR/img/down.png b/radio/sdcard/horus/SxR Calibrate/img/down.png similarity index 100% rename from radio/sdcard/horus/SxR/img/down.png rename to radio/sdcard/horus/SxR Calibrate/img/down.png diff --git a/radio/sdcard/horus/SxR/img/forward.png b/radio/sdcard/horus/SxR Calibrate/img/forward.png similarity index 100% rename from radio/sdcard/horus/SxR/img/forward.png rename to radio/sdcard/horus/SxR Calibrate/img/forward.png diff --git a/radio/sdcard/horus/SxR/img/left.png b/radio/sdcard/horus/SxR Calibrate/img/left.png similarity index 100% rename from radio/sdcard/horus/SxR/img/left.png rename to radio/sdcard/horus/SxR Calibrate/img/left.png diff --git a/radio/sdcard/horus/SxR/img/plane_b.png b/radio/sdcard/horus/SxR Calibrate/img/plane_b.png similarity index 100% rename from radio/sdcard/horus/SxR/img/plane_b.png rename to radio/sdcard/horus/SxR Calibrate/img/plane_b.png diff --git a/radio/sdcard/horus/SxR/img/planev_b.png b/radio/sdcard/horus/SxR Calibrate/img/planev_b.png similarity index 100% rename from radio/sdcard/horus/SxR/img/planev_b.png rename to radio/sdcard/horus/SxR Calibrate/img/planev_b.png diff --git a/radio/sdcard/horus/SxR/img/planev_s.png b/radio/sdcard/horus/SxR Calibrate/img/planev_s.png similarity index 100% rename from radio/sdcard/horus/SxR/img/planev_s.png rename to radio/sdcard/horus/SxR Calibrate/img/planev_s.png diff --git a/radio/sdcard/horus/SxR/img/right.png b/radio/sdcard/horus/SxR Calibrate/img/right.png similarity index 100% rename from radio/sdcard/horus/SxR/img/right.png rename to radio/sdcard/horus/SxR Calibrate/img/right.png diff --git a/radio/sdcard/horus/SxR/img/up.png b/radio/sdcard/horus/SxR Calibrate/img/up.png similarity index 100% rename from radio/sdcard/horus/SxR/img/up.png rename to radio/sdcard/horus/SxR Calibrate/img/up.png diff --git a/radio/sdcard/horus/SxR/img/vert-r.png b/radio/sdcard/horus/SxR Calibrate/img/vert-r.png similarity index 100% rename from radio/sdcard/horus/SxR/img/vert-r.png rename to radio/sdcard/horus/SxR Calibrate/img/vert-r.png diff --git a/radio/sdcard/horus/SxR/img/vert.png b/radio/sdcard/horus/SxR Calibrate/img/vert.png similarity index 100% rename from radio/sdcard/horus/SxR/img/vert.png rename to radio/sdcard/horus/SxR Calibrate/img/vert.png diff --git a/radio/sdcard/horus/SxR/SxR.lua b/radio/sdcard/horus/SxR/SxR.lua deleted file mode 100755 index 0e76fb781..000000000 --- a/radio/sdcard/horus/SxR/SxR.lua +++ /dev/null @@ -1,318 +0,0 @@ ----- ######################################################################### ----- # # ----- # Copyright (C) OpenTX # ------# # ----- # License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html # ----- # # ----- # This program is free software; you can redistribute it and/or modify # ----- # it under the terms of the GNU General Public License version 2 as # ----- # published by the Free Software Foundation. # ----- # # ----- # This program is distributed in the hope that it will be useful # ----- # but WITHOUT ANY WARRANTY; without even the implied warranty of # ----- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # ----- # GNU General Public License for more details. # ----- # # ----- ######################################################################### -local VALUE = 0 -local COMBO = 1 - -local COLUMN_2 = 300 - -local edit = false -local page = 1 -local current = 1 -local refreshState = 0 -local refreshIndex = 0 -local calibrationState = 0 -local pageOffset = 0 -local calibrationStep = 0 -local pages = {} -local fields = {} -local modifications = {} -local wingBitmaps = {} -local mountBitmaps = {} - -local configFields = { - {"Wing type:", COMBO, 0x80, nil, { "Normal", "Delta", "VTail" } }, - {"Mounting type:", COMBO, 0x81, nil, { "Horz", "Horz rev.", "Vert", "Vert rev." } }, -} -local wingBitmapsFile = {"img/plane_b.png", "img/delta_b.png", "img/planev_b.png"} -local mountBitmapsFile = {"img/up.png", "img/down.png", "img/vert.png", "img/vert-r.png"} - -local settingsFields = { - {"SxR functions:", COMBO, 0x9C, nil, { "Disable", "Enable" } }, - {"Quick Mode:", COMBO, 0xAA, nil, { "Disable", "Enable" } }, - {"CH5 mode:", COMBO, 0xA8, nil, { "AIL2", "AUX1" } }, - {"CH6 mode:", COMBO, 0xA9, nil, { "ELE2", "AUX2" } }, - {"AIL direction:", COMBO, 0x82, nil, { "Normal", "Invers" }, { 255, 0 } }, - {"ELE direction:", COMBO, 0x83, nil, { "Normal", "Invers" }, { 255, 0 } }, - {"RUD direction:", COMBO, 0x84, nil, { "Normal", "Invers" }, { 255, 0 } }, - {"AIL2 direction:", COMBO, 0x9A, nil, { "Normal", "Invers" }, { 255, 0 } }, - {"ELE2 direction:", COMBO, 0x9B, nil, { "Normal", "Invers" }, { 255, 0 } }, - {"AIL stabilize gain:", VALUE, 0x85, nil, 0, 200, "%"}, - {"ELE stabilize gain:", VALUE, 0x86, nil, 0, 200, "%"}, - {"RUD stabilize gain:", VALUE, 0x87, nil, 0, 200, "%"}, - {"AIL auto level gain:", VALUE, 0x88, nil, 0, 200, "%"}, - {"ELE auto level gain:", VALUE, 0x89, nil, 0, 200, "%"}, - {"ELE upright gain:", VALUE, 0x8C, nil, 0, 200, "%"}, - {"RUD upright gain:", VALUE, 0x8D, nil, 0, 200, "%"}, - {"AIL crab gain:", VALUE, 0x8E, nil, 0, 200, "%"}, - {"RUD crab gain:", VALUE, 0x90, nil, 0, 200, "%"}, - {"AIL auto angle offset:", VALUE, 0x91, nil, -20, 20, "%", 0x6C}, - {"ELE auto angle offset:", VALUE, 0x92, nil, -20, 20, "%", 0x6C}, - {"ELE upright angle offset:", VALUE, 0x95, nil, -20, 20, "%", 0x6C}, - {"RUD upright angle offset:", VALUE, 0x96, nil, -20, 20, "%", 0x6C}, - {"AIL crab angle offset:", VALUE, 0x97, nil, -20, 20, "%", 0x6C}, - {"RUD crab angle offset:", VALUE, 0x99, nil, -20, 20, "%", 0x6C}, -} - -local calibrationFields = { - {"X:", VALUE, 0x9E, 0, -100, 100, "%"}, - {"Y:", VALUE, 0x9F, 0, -100, 100, "%"}, - {"Z:", VALUE, 0xA0, 0, -100, 100, "%"} -} - -local function drawScreenTitle(title,page, pages) - lcd.drawFilledRectangle(0, 0, LCD_W, 30, TITLE_BGCOLOR) - lcd.drawText(1, 5, title, MENU_TITLE_COLOR) - lcd.drawText(LCD_W-40, 5, page.."/"..pages, MENU_TITLE_COLOR) -end - --- Change display attribute to current field -local function addField(step) - local field = fields[current] - local min, max - if field[2] == VALUE then - min = field[5] - max = field[6] - elseif field[2] == COMBO then - min = 0 - max = #(field[5]) - 1 - end - if (step < 0 and field[4] > min) or (step > 0 and field[4] < max) then - field[4] = field[4] + step - end -end - --- Select the next or previous page -local function selectPage(step) - page = 1 + ((page + step - 1 + #pages) % #pages) - refreshIndex = 0 - calibrationStep = 0 - pageOffset = 0 -end - --- Select the next or previous editable field -local function selectField(step) - current = 1 + ((current + step - 1 + #fields) % #fields) - if current > 7 + pageOffset then - pageOffset = current - 7 - elseif current <= pageOffset then - pageOffset = current - 1 - end -end - -local function drawProgressBar() - local width = (300 * refreshIndex) / #fields - lcd.drawRectangle(100, 10, 300, 6) - lcd.drawFilledRectangle(102, 13, width, 2); -end - --- Redraw the current page -local function redrawFieldsPage(event) - lcd.clear() - drawScreenTitle("SxR", page, #pages) - - if refreshIndex < #fields then - drawProgressBar() - end - - for index = 1, 10, 1 do - local field = fields[pageOffset+index] - if field == nil then - break - end - - local attr = current == (pageOffset+index) and ((edit == true and BLINK or 0) + INVERS) or 0 - attr = attr + TEXT_COLOR - - lcd.drawText(1, 30+20*index, field[1], TEXT_COLOR) - - if field[4] == nil then - lcd.drawText(COLUMN_2, 30+20*index, "---", attr) - else - if field[2] == VALUE then - lcd.drawNumber(COLUMN_2, 30+20*index, field[4], LEFT + attr) - elseif field[2] == COMBO then - if field[4] >= 0 and field[4] < #(field[5]) then - lcd.drawText(COLUMN_2, 30+20*index, field[5][1+field[4]], attr) - end - end - end - end -end - -local function telemetryRead(field) - return sportTelemetryPush(0x17, 0x30, 0x0C30, field) -end - -local function telemetryWrite(field, value) - return sportTelemetryPush(0x17, 0x31, 0x0C30, field + value*256) -end - -local telemetryPopTimeout = 0 -local function refreshNext() - if refreshState == 0 then - if calibrationState == 1 then - if telemetryWrite(0x9D, calibrationStep) == true then - refreshState = 1 - calibrationState = 2 - telemetryPopTimeout = getTime() + 120 -- normal delay is 500ms - end - elseif #modifications > 0 then - telemetryWrite(modifications[1][1], modifications[1][2]) - modifications[1] = nil - elseif refreshIndex < #fields then - local field = fields[refreshIndex + 1] - if telemetryRead(field[3]) == true then - refreshState = 1 - telemetryPopTimeout = getTime() + 80 -- normal delay is 500ms - end - end - elseif refreshState == 1 then - local physicalId, primId, dataId, value = sportTelemetryPop() - if physicalId == 0x1A and primId == 0x32 and dataId == 0x0C30 then - local fieldId = value % 256 - if calibrationState == 2 then - if fieldId == 0x9D then - refreshState = 0 - calibrationState = 0 - calibrationStep = (calibrationStep + 1) % 7 - end - else - local field = fields[refreshIndex + 1] - if fieldId == field[3] then - local value = math.floor(value / 256) - if field[3] == 0xAA then - value = bit32.band(value, 0x0001) - end - if field[3] >= 0x9E and field[3] <= 0xA0 then - local b1 = value % 256 - local b2 = math.floor(value / 256) - value = b1*256 + b2 - value = value - bit32.band(value, 0x8000) * 2 - end - if field[2] == COMBO and #field == 6 then - for index = 1, #(field[6]), 1 do - if value == field[6][index] then - value = index - 1 - break - end - end - elseif field[2] == VALUE and #field == 8 then - value = value - field[8] + field[5] - end - fields[refreshIndex + 1][4] = value - refreshIndex = refreshIndex + 1 - refreshState = 0 - end - end - elseif getTime() > telemetryPopTimeout then - fields[refreshIndex + 1][4] = nil - refreshIndex = refreshIndex + 1 - refreshState = 0 - calibrationState = 0 - end - end -end - -local function updateField(field) - local value = field[4] - if field[2] == COMBO and #field == 6 then - value = field[6][1+value] - elseif field[2] == VALUE and #field == 8 then - value = value + field[8] - field[5] - end - modifications[#modifications+1] = { field[3], value } -end - --- Main -local function runFieldsPage(event) - if event == EVT_EXIT_BREAK then -- exit script - return 2 - elseif event == EVT_ENTER_BREAK or event == EVT_ROT_BREAK then -- toggle editing/selecting current field - if fields[current][4] ~= nil then - edit = not edit - if edit == false then - updateField(fields[current]) - end - end - elseif edit then - if event == EVT_PLUS_FIRST or event == EVT_ROT_RIGHT or event == EVT_PLUS_REPT then - addField(1) - elseif event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT or event == EVT_MINUS_REPT then - addField(-1) - end - else - if event == EVT_MINUS_FIRST or event == EVT_ROT_RIGHT then - selectField(1) - elseif event == EVT_PLUS_FIRST or event == EVT_ROT_LEFT then - selectField(-1) - end - end - redrawFieldsPage(event) - return 0 -end - -local function runConfigPage(event) - fields = configFields - local result = runFieldsPage(event) - if fields[1][4] ~= nil then - if wingBitmaps[1 + fields[1][4]] == nil then - wingBitmaps[1 + fields[1][4]] = Bitmap.open(wingBitmapsFile[1 + fields[1][4]]) - end - lcd.drawBitmap(wingBitmaps[1 + fields[1][4]], 10, 90) - end - if fields[2][4] ~= nil then - if mountBitmaps[1 + fields[2][4]] == nil then - mountBitmaps[1 + fields[2][4]] = Bitmap.open(mountBitmapsFile[1 + fields[2][4]]) - end - lcd.drawBitmap(mountBitmaps[1 + fields[2][4]], 190, 110) - end - return result -end - -local function runSettingsPage(event) - fields = settingsFields - return runFieldsPage(event) -end - --- Init -local function init() - current, edit, refreshState, refreshIndex = 1, false, 0, 0 - pages = { - runConfigPage, - runSettingsPage, - } -end - --- Main -local function run(event) - if event == nil then - error("Cannot be run as a model script!") - return 2 - elseif event == EVT_PAGE_BREAK or event == EVT_PAGEDN_FIRST then - selectPage(1) - elseif event == EVT_PAGE_LONG or event == EVT_PAGEUP_FIRST then - killEvents(event); - selectPage(-1) - end - - local result = pages[page](event) - refreshNext() - - return result -end - -return { init=init, run=run } diff --git a/radio/sdcard/taranis-x7/SxR/SxR_Calibrate.lua b/radio/sdcard/taranis-x7/SxR Calibrate/SxR_Calibrate.lua similarity index 100% rename from radio/sdcard/taranis-x7/SxR/SxR_Calibrate.lua rename to radio/sdcard/taranis-x7/SxR Calibrate/SxR_Calibrate.lua diff --git a/radio/sdcard/taranis-x7/SxR/SxR.lua b/radio/sdcard/taranis-x7/SxR/SxR.lua deleted file mode 100644 index ba0e94272..000000000 --- a/radio/sdcard/taranis-x7/SxR/SxR.lua +++ /dev/null @@ -1,278 +0,0 @@ ----- ######################################################################### ----- # # ----- # Copyright (C) OpenTX # ------# # ----- # License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html # ----- # # ----- # This program is free software; you can redistribute it and/or modify # ----- # it under the terms of the GNU General Public License version 2 as # ----- # published by the Free Software Foundation. # ----- # # ----- # This program is distributed in the hope that it will be useful # ----- # but WITHOUT ANY WARRANTY; without even the implied warranty of # ----- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # ----- # GNU General Public License for more details. # ----- # # ----- ######################################################################### -local VALUE = 0 -local COMBO = 1 - -local edit = false -local page = 1 -local current = 1 -local refreshState = 0 -local refreshIndex = 0 -local pageOffset = 0 -local pages = {} -local fields = {} -local modifications = {} - -local configFields = { - {"Wing type", COMBO, 0x80, nil, { "Normal", "Delta", "VTail" } }, - {"Mounting type", COMBO, 0x81, nil, { "Horz", "Horz rev.", "Vert", "Vert rev." } }, -} - -local settingsFields = { - {"SxR functions", COMBO, 0x9C, nil, { "Disable", "Enable" } }, - {"Quick Mode:", COMBO, 0xAA, nil, { "Disable", "Enable" } }, - {"CH5 mode", COMBO, 0xA8, nil, { "AIL2", "AUX1" } }, - {"CH6 mode", COMBO, 0xA9, nil, { "ELE2", "AUX2" } }, - {"AIL direction", COMBO, 0x82, nil, { "Normal", "Invers" }, { 255, 0 } }, - {"ELE direction", COMBO, 0x83, nil, { "Normal", "Invers" }, { 255, 0 } }, - {"RUD direction", COMBO, 0x84, nil, { "Normal", "Invers" }, { 255, 0 } }, - {"AIL2 direction", COMBO, 0x9A, nil, { "Normal", "Invers" }, { 255, 0 } }, - {"ELE2 direction", COMBO, 0x9B, nil, { "Normal", "Invers" }, { 255, 0 } }, - {"AIL stab gain", VALUE, 0x85, nil, 0, 200, "%"}, - {"ELE stab gain", VALUE, 0x86, nil, 0, 200, "%"}, - {"RUD stab gain", VALUE, 0x87, nil, 0, 200, "%"}, - {"AIL autolvl gain", VALUE, 0x88, nil, 0, 200, "%"}, - {"ELE autolvl gain", VALUE, 0x89, nil, 0, 200, "%"}, - {"ELE hover gain", VALUE, 0x8C, nil, 0, 200, "%"}, - {"RUD hover gain", VALUE, 0x8D, nil, 0, 200, "%"}, - {"AIL knife gain", VALUE, 0x8E, nil, 0, 200, "%"}, - {"RUD knife gain", VALUE, 0x90, nil, 0, 200, "%"}, - {"AIL autolvl offset", VALUE, 0x91, nil, -20, 20, "%", 0x6C}, - {"ELE autolvl offset", VALUE, 0x92, nil, -20, 20, "%", 0x6C}, - {"ELE hover offset", VALUE, 0x95, nil, -20, 20, "%", 0x6C}, - {"RUD hover offset", VALUE, 0x96, nil, -20, 20, "%", 0x6C}, - {"AIL knife offset", VALUE, 0x97, nil, -20, 20, "%", 0x6C}, - {"RUD knife offset", VALUE, 0x99, nil, -20, 20, "%", 0x6C}, -} - --- Change display attribute to current field -local function addField(step) - local field = fields[current] - local min, max - if field[2] == VALUE then - min = field[5] - max = field[6] - elseif field[2] == COMBO then - min = 0 - max = #(field[5]) - 1 - end - if (step < 0 and field[4] > min) or (step > 0 and field[4] < max) then - field[4] = field[4] + step - end -end - --- Select the next or previous page -local function selectPage(step) - page = 1 + ((page + step - 1 + #pages) % #pages) - refreshIndex = 0 - pageOffset = 0 -end - --- Select the next or previous editable field -local function selectField(step) - current = 1 + ((current + step - 1 + #fields) % #fields) - if current > 7 + pageOffset then - pageOffset = current - 7 - elseif current <= pageOffset then - pageOffset = current - 1 - end -end - -local function drawProgressBar() - local width = (70 * refreshIndex) / #fields - lcd.drawRectangle(30, 1, 70, 6) - lcd.drawFilledRectangle(32, 3, width, 2); -end - --- Redraw the current page -local function redrawFieldsPage() - lcd.clear() - lcd.drawScreenTitle("SxR", page, #pages) - - if refreshIndex < #fields then - drawProgressBar() - end - - for index = 1, 7, 1 do - local field = fields[pageOffset+index] - if field == nil then - break - end - - local attr = current == (pageOffset+index) and ((edit == true and BLINK or 0) + INVERS) or 0 - - lcd.drawText(0, 1+8*index, field[1]) - - if field[4] == nil then - lcd.drawText(LCD_W, 1+8*index, "---", attr + RIGHT) - else - if field[2] == VALUE then - lcd.drawNumber(LCD_W, 1+8*index, field[4], attr + RIGHT) - elseif field[2] == COMBO then - if field[4] >= 0 and field[4] < #(field[5]) then - lcd.drawText(LCD_W, 1+8*index, field[5][1+field[4]], attr + RIGHT) - end - end - end - end -end - -local function telemetryRead(field) - return sportTelemetryPush(0x17, 0x30, 0x0C30, field) -end - -local function telemetryWrite(field, value) - return sportTelemetryPush(0x17, 0x31, 0x0C30, field + value*256) -end - -local telemetryPopTimeout = 0 -local function refreshNext() - if refreshState == 0 then - if #modifications > 0 then - telemetryWrite(modifications[1][1], modifications[1][2]) - modifications[1] = nil - elseif refreshIndex < #fields then - local field = fields[refreshIndex + 1] - if telemetryRead(field[3]) == true then - refreshState = 1 - telemetryPopTimeout = getTime() + 120 -- normal delay is 500ms - end - end - elseif refreshState == 1 then - local physicalId, primId, dataId, value = sportTelemetryPop() - if physicalId == 0x1A and primId == 0x32 and dataId == 0x0C30 then - local fieldId = value % 256 - local field = fields[refreshIndex + 1] - if fieldId == field[3] then - local value = math.floor(value / 256) - if field[3] == 0xAA then - value = bit32.band(value, 0x0001) - end - if field[3] >= 0x9E and field[3] <= 0xA0 then - local b1 = value % 256 - local b2 = math.floor(value / 256) - value = b1*256 + b2 - value = value - bit32.band(value, 0x8000) * 2 - end - if field[2] == COMBO and #field == 6 then - for index = 1, #(field[6]), 1 do - if value == field[6][index] then - value = index - 1 - break - end - end - elseif field[2] == VALUE and #field == 8 then - value = value - field[8] + field[5] - end - fields[refreshIndex + 1][4] = value - refreshIndex = refreshIndex + 1 - refreshState = 0 - end - elseif getTime() > telemetryPopTimeout then - fields[refreshIndex + 1][4] = nil - refreshIndex = refreshIndex + 1 - refreshState = 0 - end - end -end - -local function updateField(field) - local value = field[4] - if field[2] == COMBO and #field == 6 then - value = field[6][1+value] - elseif field[2] == VALUE and #field == 8 then - value = value + field[8] - field[5] - end - modifications[#modifications+1] = { field[3], value } -end - --- Main -local function runFieldsPage(event) - if event == EVT_EXIT_BREAK then -- exit script - return 2 - elseif event == EVT_ENTER_BREAK then -- toggle editing/selecting current field - if fields[current][4] ~= nil then - edit = not edit - if edit == false then - updateField(fields[current]) - end - end - elseif edit then - if event == EVT_PLUS_FIRST or event == EVT_ROT_RIGHT or event == EVT_PLUS_REPT or event == EVT_RIGHT_BREAK then - addField(1) - elseif event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT or event == EVT_MINUS_REPT or event == EVT_LEFT_BREAK then - addField(-1) - end - else - if event == EVT_MINUS_FIRST or event == EVT_ROT_RIGHT or event == EVT_DOWN_BREAK then - selectField(1) - elseif event == EVT_PLUS_FIRST or event == EVT_ROT_LEFT or event == EVT_UP_BREAK then - selectField(-1) - end - end - redrawFieldsPage() - return 0 -end - -local mountText = { "Label is facing the sky", "Label is facing ground", "Label is left when", "Label is right when" } - -local function runConfigPage(event) - fields = configFields - local result = runFieldsPage(event) - if fields[2][4] ~= nil then - lcd.drawText(1, 30, "Pins toward tail") - lcd.drawText(1, 40, mountText[1 + fields[2][4]]) - if fields[2][4] > 1 then - lcd.drawText(1, 50, "looking from the tail") - end - end - return result -end - -local function runSettingsPage(event) - fields = settingsFields - return runFieldsPage(event) -end - --- Init -local function init() - current, edit, refreshState, refreshIndex = 1, false, 0, 0 - pages = { - runConfigPage, - runSettingsPage, - } -end - --- Main -local function run(event) - if event == nil then - error("Cannot be run as a model script!") - return 2 - elseif event == EVT_PAGE_BREAK or (edit == false and event==EVT_RIGHT_BREAK) then - selectPage(1) - elseif event == EVT_PAGE_LONG or (edit == false and event==EVT_LEFT_BREAK) then - killEvents(event); - selectPage(-1) - end - - local result = pages[page](event) - refreshNext() - - return result -end - -return { init=init, run=run } diff --git a/radio/sdcard/taranis-x9/SxR/SxR_Calibrate.lua b/radio/sdcard/taranis-x9/SxR Calibrate/SxR_Calibrate.lua similarity index 100% rename from radio/sdcard/taranis-x9/SxR/SxR_Calibrate.lua rename to radio/sdcard/taranis-x9/SxR Calibrate/SxR_Calibrate.lua diff --git a/radio/sdcard/taranis-x9/SxR/bmp/back.bmp b/radio/sdcard/taranis-x9/SxR Calibrate/bmp/back.bmp similarity index 100% rename from radio/sdcard/taranis-x9/SxR/bmp/back.bmp rename to radio/sdcard/taranis-x9/SxR Calibrate/bmp/back.bmp diff --git a/radio/sdcard/taranis-x9/SxR/bmp/delta.bmp b/radio/sdcard/taranis-x9/SxR Calibrate/bmp/delta.bmp similarity index 100% rename from radio/sdcard/taranis-x9/SxR/bmp/delta.bmp rename to radio/sdcard/taranis-x9/SxR Calibrate/bmp/delta.bmp diff --git a/radio/sdcard/taranis-x9/SxR/bmp/done.bmp b/radio/sdcard/taranis-x9/SxR Calibrate/bmp/done.bmp similarity index 100% rename from radio/sdcard/taranis-x9/SxR/bmp/done.bmp rename to radio/sdcard/taranis-x9/SxR Calibrate/bmp/done.bmp diff --git a/radio/sdcard/taranis-x9/SxR/bmp/down.bmp b/radio/sdcard/taranis-x9/SxR Calibrate/bmp/down.bmp similarity index 100% rename from radio/sdcard/taranis-x9/SxR/bmp/down.bmp rename to radio/sdcard/taranis-x9/SxR Calibrate/bmp/down.bmp diff --git a/radio/sdcard/taranis-x9/SxR/bmp/forward.bmp b/radio/sdcard/taranis-x9/SxR Calibrate/bmp/forward.bmp similarity index 100% rename from radio/sdcard/taranis-x9/SxR/bmp/forward.bmp rename to radio/sdcard/taranis-x9/SxR Calibrate/bmp/forward.bmp diff --git a/radio/sdcard/taranis-x9/SxR/bmp/horz-r.bmp b/radio/sdcard/taranis-x9/SxR Calibrate/bmp/horz-r.bmp similarity index 100% rename from radio/sdcard/taranis-x9/SxR/bmp/horz-r.bmp rename to radio/sdcard/taranis-x9/SxR Calibrate/bmp/horz-r.bmp diff --git a/radio/sdcard/taranis-x9/SxR/bmp/horz.bmp b/radio/sdcard/taranis-x9/SxR Calibrate/bmp/horz.bmp similarity index 100% rename from radio/sdcard/taranis-x9/SxR/bmp/horz.bmp rename to radio/sdcard/taranis-x9/SxR Calibrate/bmp/horz.bmp diff --git a/radio/sdcard/taranis-x9/SxR/bmp/left.bmp b/radio/sdcard/taranis-x9/SxR Calibrate/bmp/left.bmp similarity index 100% rename from radio/sdcard/taranis-x9/SxR/bmp/left.bmp rename to radio/sdcard/taranis-x9/SxR Calibrate/bmp/left.bmp diff --git a/radio/sdcard/taranis-x9/SxR/bmp/plane.bmp b/radio/sdcard/taranis-x9/SxR Calibrate/bmp/plane.bmp similarity index 100% rename from radio/sdcard/taranis-x9/SxR/bmp/plane.bmp rename to radio/sdcard/taranis-x9/SxR Calibrate/bmp/plane.bmp diff --git a/radio/sdcard/taranis-x9/SxR/bmp/right.bmp b/radio/sdcard/taranis-x9/SxR Calibrate/bmp/right.bmp similarity index 100% rename from radio/sdcard/taranis-x9/SxR/bmp/right.bmp rename to radio/sdcard/taranis-x9/SxR Calibrate/bmp/right.bmp diff --git a/radio/sdcard/taranis-x9/SxR/bmp/up.bmp b/radio/sdcard/taranis-x9/SxR Calibrate/bmp/up.bmp similarity index 100% rename from radio/sdcard/taranis-x9/SxR/bmp/up.bmp rename to radio/sdcard/taranis-x9/SxR Calibrate/bmp/up.bmp diff --git a/radio/sdcard/taranis-x9/SxR/bmp/vert-r.bmp b/radio/sdcard/taranis-x9/SxR Calibrate/bmp/vert-r.bmp similarity index 100% rename from radio/sdcard/taranis-x9/SxR/bmp/vert-r.bmp rename to radio/sdcard/taranis-x9/SxR Calibrate/bmp/vert-r.bmp diff --git a/radio/sdcard/taranis-x9/SxR/bmp/vert.bmp b/radio/sdcard/taranis-x9/SxR Calibrate/bmp/vert.bmp similarity index 100% rename from radio/sdcard/taranis-x9/SxR/bmp/vert.bmp rename to radio/sdcard/taranis-x9/SxR Calibrate/bmp/vert.bmp diff --git a/radio/sdcard/taranis-x9/SxR/bmp/vtail.bmp b/radio/sdcard/taranis-x9/SxR Calibrate/bmp/vtail.bmp similarity index 100% rename from radio/sdcard/taranis-x9/SxR/bmp/vtail.bmp rename to radio/sdcard/taranis-x9/SxR Calibrate/bmp/vtail.bmp diff --git a/radio/sdcard/taranis-x9/SxR/SxR.lua b/radio/sdcard/taranis-x9/SxR/SxR.lua deleted file mode 100644 index 2a2fb4ef1..000000000 --- a/radio/sdcard/taranis-x9/SxR/SxR.lua +++ /dev/null @@ -1,280 +0,0 @@ ----- ######################################################################### ----- # # ----- # Copyright (C) OpenTX # ------# # ----- # License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html # ----- # # ----- # This program is free software; you can redistribute it and/or modify # ----- # it under the terms of the GNU General Public License version 2 as # ----- # published by the Free Software Foundation. # ----- # # ----- # This program is distributed in the hope that it will be useful # ----- # but WITHOUT ANY WARRANTY; without even the implied warranty of # ----- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # ----- # GNU General Public License for more details. # ----- # # ----- ######################################################################### -local VALUE = 0 -local COMBO = 1 - -local COLUMN_2 = 150 - -local edit = false -local page = 1 -local current = 1 -local refreshState = 0 -local refreshIndex = 0 -local pageOffset = 0 -local pages = {} -local fields = {} -local modifications = {} - -local configFields = { - {"Wing type:", COMBO, 0x80, nil, { "Normal", "Delta", "VTail" } }, - {"Mounting type:", COMBO, 0x81, nil, { "Horz", "Horz rev.", "Vert", "Vert rev." } }, -} - -local settingsFields = { - {"SxR functions:", COMBO, 0x9C, nil, { "Disable", "Enable" } }, - {"Quick Mode:", COMBO, 0xAA, nil, { "Disable", "Enable" } }, - {"CH5 mode:", COMBO, 0xA8, nil, { "AIL2", "AUX1" } }, - {"CH6 mode:", COMBO, 0xA9, nil, { "ELE2", "AUX2" } }, - {"AIL direction:", COMBO, 0x82, nil, { "Normal", "Invers" }, { 255, 0 } }, - {"ELE direction:", COMBO, 0x83, nil, { "Normal", "Invers" }, { 255, 0 } }, - {"RUD direction:", COMBO, 0x84, nil, { "Normal", "Invers" }, { 255, 0 } }, - {"AIL2 direction:", COMBO, 0x9A, nil, { "Normal", "Invers" }, { 255, 0 } }, - {"ELE2 direction:", COMBO, 0x9B, nil, { "Normal", "Invers" }, { 255, 0 } }, - {"AIL stabilize gain:", VALUE, 0x85, nil, 0, 200, "%"}, - {"ELE stabilize gain:", VALUE, 0x86, nil, 0, 200, "%"}, - {"RUD stabilize gain:", VALUE, 0x87, nil, 0, 200, "%"}, - {"AIL auto level gain:", VALUE, 0x88, nil, 0, 200, "%"}, - {"ELE auto level gain:", VALUE, 0x89, nil, 0, 200, "%"}, - {"ELE upright gain:", VALUE, 0x8C, nil, 0, 200, "%"}, - {"RUD upright gain:", VALUE, 0x8D, nil, 0, 200, "%"}, - {"AIL crab gain:", VALUE, 0x8E, nil, 0, 200, "%"}, - {"RUD crab gain:", VALUE, 0x90, nil, 0, 200, "%"}, - {"AIL auto angle offset:", VALUE, 0x91, nil, -20, 20, "%", 0x6C}, - {"ELE auto angle offset:", VALUE, 0x92, nil, -20, 20, "%", 0x6C}, - {"ELE upright angle offset:", VALUE, 0x95, nil, -20, 20, "%", 0x6C}, - {"RUD upright angle offset:", VALUE, 0x96, nil, -20, 20, "%", 0x6C}, - {"AIL crab angle offset:", VALUE, 0x97, nil, -20, 20, "%", 0x6C}, - {"RUD crab angle offset:", VALUE, 0x99, nil, -20, 20, "%", 0x6C}, -} - --- Change display attribute to current field -local function addField(step) - local field = fields[current] - local min, max - if field[2] == VALUE then - min = field[5] - max = field[6] - elseif field[2] == COMBO then - min = 0 - max = #(field[5]) - 1 - end - if (step < 0 and field[4] > min) or (step > 0 and field[4] < max) then - field[4] = field[4] + step - end -end - --- Select the next or previous page -local function selectPage(step) - page = 1 + ((page + step - 1 + #pages) % #pages) - refreshIndex = 0 - pageOffset = 0 -end - --- Select the next or previous editable field -local function selectField(step) - current = 1 + ((current + step - 1 + #fields) % #fields) - if current > 7 + pageOffset then - pageOffset = current - 7 - elseif current <= pageOffset then - pageOffset = current - 1 - end -end - -local function drawProgressBar() - local width = (140 * refreshIndex) / #fields - lcd.drawRectangle(30, 1, 144, 6) - lcd.drawFilledRectangle(32, 3, width, 2); -end - --- Redraw the current page -local function redrawFieldsPage() - lcd.clear() - lcd.drawScreenTitle("SxR", page, #pages) - - if refreshIndex < #fields then - drawProgressBar() - end - - for index = 1, 7, 1 do - local field = fields[pageOffset+index] - if field == nil then - break - end - - local attr = current == (pageOffset+index) and ((edit == true and BLINK or 0) + INVERS) or 0 - - lcd.drawText(0, 1+8*index, field[1]) - - if field[4] == nil then - lcd.drawText(COLUMN_2, 1+8*index, "---", attr) - else - if field[2] == VALUE then - lcd.drawNumber(COLUMN_2, 1+8*index, field[4], LEFT + attr) - elseif field[2] == COMBO then - if field[4] >= 0 and field[4] < #(field[5]) then - lcd.drawText(COLUMN_2, 1+8*index, field[5][1+field[4]], attr) - end - end - end - end -end - -local function telemetryRead(field) - return sportTelemetryPush(0x17, 0x30, 0x0C30, field) -end - -local function telemetryWrite(field, value) - return sportTelemetryPush(0x17, 0x31, 0x0C30, field + value*256) -end - -local telemetryPopTimeout = 0 -local function refreshNext() - if refreshState == 0 then - if #modifications > 0 then - telemetryWrite(modifications[1][1], modifications[1][2]) - modifications[1] = nil - elseif refreshIndex < #fields then - local field = fields[refreshIndex + 1] - if telemetryRead(field[3]) == true then - refreshState = 1 - telemetryPopTimeout = getTime() + 120 -- normal delay is 500ms - end - end - elseif refreshState == 1 then - local physicalId, primId, dataId, value = sportTelemetryPop() - if physicalId == 0x1A and primId == 0x32 and dataId == 0x0C30 then - local fieldId = value % 256 - local field = fields[refreshIndex + 1] - if fieldId == field[3] then - local value = math.floor(value / 256) - if field[3] == 0xAA then - value = bit32.band(value, 0x0001) - end - if field[3] >= 0x9E and field[3] <= 0xA0 then - local b1 = value % 256 - local b2 = math.floor(value / 256) - value = b1*256 + b2 - value = value - bit32.band(value, 0x8000) * 2 - end - if field[2] == COMBO and #field == 6 then - for index = 1, #(field[6]), 1 do - if value == field[6][index] then - value = index - 1 - break - end - end - elseif field[2] == VALUE and #field == 8 then - value = value - field[8] + field[5] - end - fields[refreshIndex + 1][4] = value - refreshIndex = refreshIndex + 1 - refreshState = 0 - end - elseif getTime() > telemetryPopTimeout then - fields[refreshIndex + 1][4] = nil - refreshIndex = refreshIndex + 1 - refreshState = 0 - end - end -end - -local function updateField(field) - local value = field[4] - if field[2] == COMBO and #field == 6 then - value = field[6][1+value] - elseif field[2] == VALUE and #field == 8 then - value = value + field[8] - field[5] - end - modifications[#modifications+1] = { field[3], value } -end - --- Main -local function runFieldsPage(event) - if event == EVT_EXIT_BREAK then -- exit script - return 2 - elseif event == EVT_ENTER_BREAK then -- toggle editing/selecting current field - if fields[current][4] ~= nil then - edit = not edit - if edit == false then - updateField(fields[current]) - end - end - elseif edit then - if event == EVT_PLUS_FIRST or event == EVT_ROT_RIGHT or event == EVT_PLUS_REPT then - addField(1) - elseif event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT or event == EVT_MINUS_REPT then - addField(-1) - end - else - if event == EVT_MINUS_FIRST or event == EVT_ROT_RIGHT then - selectField(1) - elseif event == EVT_PLUS_FIRST or event == EVT_ROT_LEFT then - selectField(-1) - end - end - redrawFieldsPage() - return 0 -end - -local wingBitmaps = { "bmp/plane.bmp", "bmp/delta.bmp", "bmp/vtail.bmp" } -local mountBitmaps = { "bmp/horz.bmp", "bmp/horz-r.bmp", "bmp/vert.bmp", "bmp/vert-r.bmp" } - -local function runConfigPage(event) - fields = configFields - local result = runFieldsPage(event) - if fields[1][4] ~= nil then - lcd.drawPixmap(20, 28, wingBitmaps[1 + fields[1][4]]) - end - if fields[2][4] ~= nil then - lcd.drawPixmap(128, 28, mountBitmaps[1 + fields[2][4]]) - end - return result -end - -local function runSettingsPage(event) - fields = settingsFields - return runFieldsPage(event) -end - --- Init -local function init() - current, edit, refreshState, refreshIndex = 1, false, 0, 0 - pages = { - runConfigPage, - runSettingsPage, - } -end - --- Main -local function run(event) - if event == nil then - error("Cannot be run as a model script!") - return 2 - elseif event == EVT_PAGE_BREAK then - selectPage(1) - elseif event == EVT_PAGE_LONG then - killEvents(event); - selectPage(-1) - end - - local result = pages[page](event) - refreshNext() - - return result -end - -return { init=init, run=run }