diff --git a/src/SCRIPTS/BF/NV14/filters.lua b/src/SCRIPTS/BF/NV14/filters.lua new file mode 100644 index 00000000..71fc95fb --- /dev/null +++ b/src/SCRIPTS/BF/NV14/filters.lua @@ -0,0 +1,95 @@ +return { + read = 92, -- MSP_FILTER_CONFIG + write = 93, -- MSP_SET_FILTER_CONFIG + eepromWrite = true, + reboot = false, + title = "Filters", + minBytes = 37, + outputBytes = 37, + yMinLimit = 35, + yMaxLimit = 215, + text= { + { t = "Gyro Lowpass 1 Dynamic", x = 5, y = 35 }, + { t = "Min Cutoff", x = 35, y = 55, to = SMLSIZE }, + { t = "Max Cutoff", x = 35, y = 75, to = SMLSIZE }, + { t = "Filter Type", x = 35, y = 95, to = SMLSIZE }, + + { t = "Gyro Lowpass 1", x = 5, y = 115 }, + { t = "Cutoff", x = 35, y = 135, to = SMLSIZE }, + { t = "Filter Type", x = 35, y = 155, to = SMLSIZE }, + + { t = "Gyro Lowpass 2", x = 5, y = 175 }, + { t = "Cutoff", x = 35, y = 195, to = SMLSIZE }, + { t = "Filter Type", x = 35, y = 215, to = SMLSIZE }, + + { t = "Gyro Notch 1", x = 5, y = 235 }, + { t = "Center", x = 35, y = 255, to = SMLSIZE }, + { t = "Cutoff", x = 35, y = 275, to = SMLSIZE }, + + { t = "Gyro Notch 2", x = 5, y = 295 }, + { t = "Center", x = 35, y = 315, to = SMLSIZE }, + { t = "Cutoff", x = 35, y = 335, to = SMLSIZE }, + + { t = "D Term Lowpass 1 Dynamic", x = 5, y = 355 }, + { t = "Min Cutoff", x = 35, y = 375, to = SMLSIZE }, + { t = "Max Cutoff", x = 35, y = 395, to = SMLSIZE }, + { t = "Filter Type", x = 35, y = 415, to = SMLSIZE }, + + { t = "D Term Lowpass 1", x = 5, y = 435 }, + { t = "Cutoff", x = 35, y = 455, to = SMLSIZE }, + { t = "Filter Type", x = 35, y = 475, to = SMLSIZE }, + + { t = "D Term Lowpass 2", x = 5, y = 495 }, + { t = "Cutoff", x = 35, y = 515, to = SMLSIZE }, + { t = "Filter Type", x = 35, y = 535, to = SMLSIZE }, + + { t = "D Term Notch", x = 5, y = 555 }, + { t = "Center", x = 35, y = 575, to = SMLSIZE }, + { t = "Cutoff", x = 35, y = 595, to = SMLSIZE }, + + { t = "Yaw Lowpass", x = 5, y = 615 }, + { t = "Cutoff", x = 35, y = 635, to = SMLSIZE }, + }, + fields = { + -- Gyro Lowpass 1 Dynamic + { x = 200, y = 55, min = 0, max = 1000, vals = { 30, 31 } }, + { x = 200, y = 75, min = 0, max = 1000, vals = { 32, 33 } }, + { x = 200, y = 95, min = 0, max = 1, vals = { 25 }, table = { [0] = "PT1", [1] = "BIQUAD" } }, + + -- Gyro Lowpass 1 + { x = 200, y = 135, min = 0, max = 16000, vals = { 21, 22 } }, + { x = 200, y = 155, min = 0, max = 1, vals = { 25 }, table = { [0] = "PT1", [1] = "BIQUAD" } }, + + -- Gyro Lowpass 2 + { x = 200, y = 195, min = 0, max = 16000, vals = { 23, 24 } }, + { x = 200, y = 215, min = 0, max = 1, vals = { 26 }, table = { [0] = "PT1", [1] = "BIQUAD" } }, + + -- Gyro Notch 1 + { x = 200, y = 255, min = 0, max = 16000, vals = { 6, 7 } }, + { x = 200, y = 275, min = 0, max = 16000, vals = { 8, 9 } }, + + -- Gyro Notch 2 + { x = 200, y = 315, min = 0, max = 16000, vals = { 14, 15 } }, + { x = 200, y = 335, min = 0, max = 16000, vals = { 16, 17 } }, + + -- D Term Lowpass 1 Dynamic + { x = 200, y = 375, min = 0, max = 1000, vals = { 34, 35 } }, + { x = 200, y = 395, min = 0, max = 1000, vals = { 36, 37 } }, + { x = 200, y = 415, min = 0, max = 1, vals = { 18 }, table = { [0] = "PT1", [1] = "BIQUAD" } }, + + -- D Term Lowpass 1 + { x = 200, y = 455, min = 0, max = 16000, vals = { 2, 3 } }, + { x = 200, y = 475, min = 0, max = 1, vals = { 18 }, table = { [0] = "PT1", [1] = "BIQUAD" } }, + + -- D Term Lowpass 2 + { x = 200, y = 515, min = 0, max = 16000, vals = { 27, 28 } }, + { x = 200, y = 535, min = 0, max = 1, vals = { 29 }, table = { [0] = "PT1", [1] = "BIQUAD" } }, + + -- D Term Notch + { x = 200, y = 575, min = 0, max = 16000, vals = { 10, 11 } }, + { x = 200, y = 595, min = 0, max = 16000, vals = { 12, 13 } }, + + -- Yaw Lowpass + { x = 200, y = 635, min = 0, max = 500, vals = { 4, 5 } }, + } +} diff --git a/src/SCRIPTS/BF/NV14/gpspids.lua b/src/SCRIPTS/BF/NV14/gpspids.lua new file mode 100644 index 00000000..fb870204 --- /dev/null +++ b/src/SCRIPTS/BF/NV14/gpspids.lua @@ -0,0 +1,29 @@ +return { + read = 136, -- MSP_GPS_RESCUE_PIDS + write = 226, -- MSP_SET_GPS_RESCUE_PIDS + title = "GPS Rescue / PIDs", + reboot = false, + eepromWrite = true, + minBytes = 14, + requiredVersion = 1.041, + text = { + { t = "P", x = 100, y = 48, to = MIDSIZE }, + { t = "I", x = 180, y = 48, to = MIDSIZE }, + { t = "D", x = 260, y = 48, to = MIDSIZE }, + { t = "Throttle", x = 10, y = 100 }, + { t = "Velocity", x = 10, y = 150 }, + { t = "Yaw" , x = 10, y = 200 }, + }, + fields = { + -- P + { x = 100, y = 100, min = 0, max = 200, vals = { 1, 3 }, to = MIDSIZE }, + { x = 100, y = 150, min = 0, max = 200, vals = { 7, 8 }, to = MIDSIZE }, + { x = 100, y = 200, min = 0, max = 500, vals = {13,14 }, to = MIDSIZE }, + -- I + { x = 180, y = 100, min = 0, max = 200, vals = { 3, 4 }, to = MIDSIZE }, + { x = 180, y = 150, min = 0, max = 200, vals = { 9,10 }, to = MIDSIZE }, + -- D + { x = 260, y = 100, min = 0, max = 200, vals = { 5, 6 }, to = MIDSIZE }, + { x = 260, y = 150, min = 0, max = 200, vals = { 11,12 }, to = MIDSIZE }, + }, +} diff --git a/src/SCRIPTS/BF/NV14/nv14pre.lua b/src/SCRIPTS/BF/NV14/nv14pre.lua new file mode 100644 index 00000000..5d6ffcd1 --- /dev/null +++ b/src/SCRIPTS/BF/NV14/nv14pre.lua @@ -0,0 +1,17 @@ +PageFiles = +{ + "pids1.lua", + "pids2.lua", + "rates.lua", + "pid_advanced.lua", + "filters.lua", + "pwm.lua", + "rx.lua", + "vtx.lua", + "rescue.lua", + "gpspids.lua", +} + +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 + INVERS + BLINK } diff --git a/src/SCRIPTS/BF/NV14/pid_advanced.lua b/src/SCRIPTS/BF/NV14/pid_advanced.lua new file mode 100644 index 00000000..1421dfb4 --- /dev/null +++ b/src/SCRIPTS/BF/NV14/pid_advanced.lua @@ -0,0 +1,48 @@ +return { + read = 94, -- MSP_PID_ADVANCED + write = 95, -- MSP_SET_PID_ADVANCED + title = "PID Advanced", + reboot = false, + eepromWrite = true, + minBytes = 46, + outputBytes = 46, + yMinLimit = 35, + yMaxLimit = 215, + text = { + { t = "Acro Trainer", x = 5, y = 35 }, + { t = "Angle Limit", x = 15, y = 55, to = SMLSIZE }, + + { t = "Throttle Boost", x = 5, y = 75 }, + { t = "Absolute Control", x = 5, y = 95 }, + { t = "I Term Rotation", x = 5, y = 115 }, + { t = "VBAT Compensation", x = 5, y = 135 }, + + { t = "I Term Relax", x = 5, y = 155 }, + { t = "Axes", x = 15, y = 175, to = SMLSIZE }, + { t = "Type", x = 15, y = 195, to = SMLSIZE }, + + { t = "Integrated Yaw", x = 5, y = 215 }, + + { t = "Anti Gravity", x = 5, y = 235 }, + { t = "Mode", x = 15, y = 255, to = SMLSIZE }, + { t = "Gain", x = 15, y = 275, to = SMLSIZE }, + { t = "Threshold", x = 15, y = 295, to = SMLSIZE }, + }, + fields = { + { x = 200, y = 55, min = 20, max = 80, vals = { 32 } }, + + { x = 200, y = 75, min = 0, max = 100, vals = { 31 } }, + { x = 200, y = 95, min = 0, max = 20, vals = { 30 } }, + { x = 200, y = 115, min = 0, max = 1, vals = { 26 }, table = { [0]="OFF", "ON" } }, + { x = 200, y = 135, min = 0, max = 1, vals = { 8 }, table = { [0]="OFF", "ON" } }, + + { x = 200, y = 175, min = 0, max = 4, vals = { 28 }, table = { [0]="NONE", "RP", "RPY", "RP (increment only)", "RPY (increment only)" } }, + { x = 200, y = 195, min = 0, max = 1, vals = { 29 }, table = { [0]="Gyro", "Setpoint" } }, + + { x = 200, y = 215, min = 0, max = 1, vals = { 45 }, table = { [0]="OFF", "ON" } }, + + { x = 200, y = 255, min = 0, max = 1, vals = { 39 }, table = { [0]="Smooth", "Step" } }, + { x = 200, y = 275, min = 1000, max = 30000, vals = { 22, 23 }, scale = 1000, mult = 100 }, + { x = 200, y = 295, min = 20, max = 1000, vals = { 20, 21 } }, + } +} diff --git a/src/SCRIPTS/BF/NV14/pids1.lua b/src/SCRIPTS/BF/NV14/pids1.lua new file mode 100644 index 00000000..c48518bb --- /dev/null +++ b/src/SCRIPTS/BF/NV14/pids1.lua @@ -0,0 +1,31 @@ + +return { + read = 112, -- MSP_PID + write = 202, -- MSP_SET_PID + title = "PIDs (1/2)", + reboot = false, + eepromWrite = true, + minBytes = 9, + text = { + { t = "P", x = 100, y = 48, to = MIDSIZE }, + { t = "I", x = 180, y = 48, to = MIDSIZE }, + { t = "D", x = 260, y = 48, to = MIDSIZE }, + { t = "ROLL", x = 10, y = 100 }, + { t = "PITCH", x = 10, y = 150 }, + { t = "YAW", x = 10, y = 200 }, + }, + fields = { + -- P + { x = 100, y = 100, min = 0, max = 200, vals = { 1 }, to = MIDSIZE }, + { x = 100, y = 150, min = 0, max = 200, vals = { 4 }, to = MIDSIZE }, + { x = 100, y = 200, min = 0, max = 200, vals = { 7 }, to = MIDSIZE }, + -- I + { x = 180, y = 100, min = 0, max = 200, vals = { 2 }, to = MIDSIZE }, + { x = 180, y = 150, min = 0, max = 200, vals = { 5 }, to = MIDSIZE }, + { x = 180, y = 200, min = 0, max = 200, vals = { 8 }, to = MIDSIZE }, + -- D + { x = 260, y = 100, min = 0, max = 200, vals = { 3 }, to = MIDSIZE }, + { x = 260, y = 150, min = 0, max = 200, vals = { 6 }, to = MIDSIZE }, + { x = 260, y = 200, min = 0, max = 200, vals = { 9 }, to = MIDSIZE }, + }, +} diff --git a/src/SCRIPTS/BF/NV14/pids2.lua b/src/SCRIPTS/BF/NV14/pids2.lua new file mode 100644 index 00000000..3080e49a --- /dev/null +++ b/src/SCRIPTS/BF/NV14/pids2.lua @@ -0,0 +1,44 @@ + +return { + read = 94, -- MSP_PID_ADVANCED + write = 95, -- MSP_SET_PID_ADVANCED + title = "PIDs (2/2)", + reboot = false, + eepromWrite = true, + minBytes = 44, + text = { + { t = "Feed", x = 97, y = 52 }, + { t = "forward", x = 82, y = 70 }, + { t = "D", x = 207, y = 52 }, + { t = "Min", x = 202, y = 70 }, + { t = "ROLL", x = 28, y = 100 }, + { t = "PITCH", x = 28, y = 150 }, + { t = "YAW", x = 28, y = 200 }, + + { t = "Feedforward", x = 28, y = 250 }, + { t = "Transition", x = 40, y = 270, to = SMLSIZE }, + { t = "D Min", x = 28, y = 300 }, + { t = "Gain", x = 40, y = 320, to = SMLSIZE }, + { t = "Advance", x = 40, y = 350, to = SMLSIZE }, + }, + fields = { + -- ROLL FF + { x = 102, y = 100, min = 0, max = 2000, vals = { 33, 34 }, to = MIDSIZE }, + -- PITCH FF + { x = 102, y = 150, min = 0, max = 2000, vals = { 35, 36 }, to = MIDSIZE }, + -- YAW FF + { x = 102, y = 200, min = 0, max = 2000, vals = { 37, 38 }, to = MIDSIZE }, + -- ROLL D MIN + { x = 202, y = 100, min = 0, max = 100, vals = { 40 }, to = MIDSIZE }, + -- PITCH D MIN + { x = 202, y = 150, min = 0, max = 100, vals = { 41 }, to = MIDSIZE }, + -- YAW D MIN + { x = 202, y = 200, min = 0, max = 100, vals = { 42 }, to = MIDSIZE }, + -- FF TRANSITION + { x = 150, y = 270, min = 0, max = 100, vals = { 9 }, scale = 100 }, + -- D MIN GAIN + { x = 150, y = 320, min = 0, max = 100, vals = { 43 } }, + -- D MIN ADVANCE + { x = 150, y = 350, min = 0, max = 200, vals = { 44 } }, + }, +} diff --git a/src/SCRIPTS/BF/NV14/pwm.lua b/src/SCRIPTS/BF/NV14/pwm.lua new file mode 100644 index 00000000..9186df15 --- /dev/null +++ b/src/SCRIPTS/BF/NV14/pwm.lua @@ -0,0 +1,66 @@ +return { + read = 90, -- MSP_ADVANCED_CONFIG + write = 91, -- MSP_SET_ADVANCED_CONFIG + reboot = true, + eepromWrite = true, + title = "PWM", + minBytes = 9, + text= { + { t = "Protocol", x = 36, y = 68 }, + { t = "32K", x = 36, y = 110 }, + { t = "Gyro Rt", x = 36, y = 155 }, + { t = "PID Rt", x = 36, y = 200 }, + { t = "Unsynced", x = 36, y = 242 }, + { t = "PWM Rate", x = 36, y = 284 }, + { t = "Idle Offset", x = 36, y = 326 } + }, + fields = { + { x = 150, y = 68, vals = { 4 }, min = 0, max = 9, to = MIDSIZE, + table = { [0] = "OFF", "ONESHOT125", "ONESHOT42", + "MULTISHOT","BRUSHED", + "DSHOT150", "DSHOT300", "DSHOT600","DSHOT1200", + "PROSHOT1000" } + }, + { x = 150, y = 110, vals = { 9 }, min = 0, max = 1, to = MIDSIZE, + table = { [0] = "OFF", "ON" }, + upd = function(self) self.updateRateTables(self) end + }, + { x = 150, y = 155, vals = { 1 }, min = 1, max = 32, to = MIDSIZE, + upd = function(self) self.updatePidRateTable(self) end + }, + { x = 150, y = 200, vals = { 2 }, min = 1, max = 16, to = MIDSIZE }, + { x = 150, y = 242, vals = { 3 }, min = 0, max = 1, to = MIDSIZE, + table = { [0] = "OFF", "ON" } }, + { x = 150, y = 284, vals = { 5, 6 }, min = 200, max = 32000, to = MIDSIZE }, + { x = 150, y = 326, vals = { 7, 8 }, min = 0, max = 2000, scale = 100, to = MIDSIZE }, + }, + calculateGyroRates = function(self, baseRate) + self.gyroRates = {} + self.fields[2].table = {} + for i=1, 32 do + self.gyroRates[i] = baseRate/i + local fmt = nil + self.fields[2].table[i] = string.format("%.2f",baseRate/i) + end + end, + calculatePidRates = function(self, baseRate) + self.fields[3].table = {} + for i=1, 16 do + self.fields[3].table[i] = string.format("%.2f",baseRate/i) + end + end, + updateRateTables = function(self) + if self.values[9] == 0 then + self.calculateGyroRates(self, 8) + self.calculatePidRates(self, 8) + elseif self.values[9] == 1 then + self.calculateGyroRates(self, 32) + self.calculatePidRates(self, 32) + end + end, + updatePidRateTable = function(self) + local newRateIdx = self.values[1] + local newRate = self.gyroRates[newRateIdx] + self.calculatePidRates(self, newRate) + end +} diff --git a/src/SCRIPTS/BF/NV14/rates.lua b/src/SCRIPTS/BF/NV14/rates.lua new file mode 100644 index 00000000..b2539650 --- /dev/null +++ b/src/SCRIPTS/BF/NV14/rates.lua @@ -0,0 +1,50 @@ +return { + read = 111, -- MSP_RC_TUNING + write = 204, -- MSP_SET_RC_TUNING + title = "Rates", + reboot = false, + eepromWrite = true, + minBytes = 16, + text = { + { t = "RC", x = 100, y = 52 }, + { t = "Rate", x = 94, y = 70 }, + { t = "Super", x = 148, y = 52 }, + { t = "Rate", x = 152, y = 70 }, + { t = "RC", x = 214, y = 52 }, + { t = "Expo", x = 207, y = 70 }, + { t = "ROLL", x = 28, y = 100 }, + { t = "PITCH", x = 28, y = 150 }, + { t = "YAW", x = 28, y = 200 }, + + { t = "Throttle", x = 28, y = 250 }, + { t = "Mid", x = 40, y = 270, to = SMLSIZE }, + { t = "Expo", x = 40, y = 290, to = SMLSIZE }, + { t = "Limit Type", x = 40, y = 310, to = SMLSIZE }, + { t = "Limit %", x = 40, y = 330, to = SMLSIZE }, + { t = "TPA", x = 28, y = 350 }, + { t = "Rate", x = 40, y = 370, to = SMLSIZE }, + { t = "Breakpoint", x = 40, y = 390, to = SMLSIZE }, + }, + fields = { + -- RC Rates + { x = 102, y = 100, vals = { 1 }, min = 0, max = 255, scale = 100, to = MIDSIZE }, + { x = 102, y = 150, vals = { 13 }, min = 0, max = 255, scale = 100, to = MIDSIZE }, + { x = 102, y = 200, vals = { 12 }, min = 0, max = 255, scale = 100, to = MIDSIZE }, + -- Super Rates + { x = 158, y = 100, vals = { 3 }, min = 0, max = 100, scale = 100, to = MIDSIZE }, + { x = 158, y = 150, vals = { 4 }, min = 0, max = 100, scale = 100, to = MIDSIZE }, + { x = 158, y = 200, vals = { 5 }, min = 0, max = 255, scale = 100, to = MIDSIZE }, + -- RC Expo + { x = 216, y = 100, vals = { 2 }, min = 0, max = 100, scale = 100, to = MIDSIZE }, + { x = 216, y = 150, vals = { 14 }, min = 0, max = 100, scale = 100, to = MIDSIZE }, + { x = 216, y = 200, vals = { 11 }, min = 0, max = 100, scale = 100, to = MIDSIZE }, + -- Throttle + { x = 150, y = 270, vals = { 7 }, min = 0, max = 100, scale = 100 }, + { x = 150, y = 290, vals = { 8 }, min = 0, max = 100, scale = 100 }, + { x = 150, y = 310, vals = { 15 }, min = 0, max = 2, table = { [0] = "OFF", "SCALE", "CLIP" } }, + { x = 150, y = 330, vals = { 16 }, min = 25, max = 100 }, + -- TPA + { x = 150, y = 370, vals = { 6 }, min = 0, max = 100, scale = 100 }, + { x = 150, y = 390, vals = { 9, 10 }, min = 1000, max = 2000 }, + }, +} diff --git a/src/SCRIPTS/BF/NV14/rescue.lua b/src/SCRIPTS/BF/NV14/rescue.lua new file mode 100644 index 00000000..ec85cd86 --- /dev/null +++ b/src/SCRIPTS/BF/NV14/rescue.lua @@ -0,0 +1,36 @@ +return { + read = 135, -- MSP_GPS_RESCUE + write = 225, -- MSP_SET_GPS_RESCUE + title = "GPS Rescue", + reboot = false, + eepromWrite = true, + minBytes = 16, + requiredVersion = 1.041, + text = { + { t = "Min Sats.", x = 10, y = 40 }, + { t = "Angle", x = 10, y = 80 }, + { t = "Initial Altitude", x = 10, y = 120 }, + { t = "Descent Distance", x = 10, y = 160 }, + { t = "Ground Speed", x = 10, y = 200 }, + + { t = "Snty.", x = 10, y = 240 }, + { t = "Throttle", x = 10, y = 280 }, + { t = "Min", x = 10, y = 320 }, + { t = "Hover", x = 10, y = 360 }, + { t = "Max", x = 10, y = 400 }, + }, + fields = { + { x = 260, y = 40, min = 0, max = 50, vals = { 16 } }, + { x = 260, y = 80, min = 0, max = 200, vals = { 1,2 } }, + { x = 260, y = 120, min = 20, max = 100, vals = { 3,4 } }, + { x = 260, y = 160, min = 30, max = 500, vals = { 5,6 } }, + { x = 260, y = 200, min = 30, max =3000, vals = { 7,8 } }, + + + { x = 260, y = 240, min = 0, max = 2 , vals = { 15 } ,table = { [0]="OFF","ON","FS_ONLY"}}, + { x = 260, y = 320, min = 1000, max = 2000, vals = { 9,10 } }, + { x = 260, y = 360, min = 1000, max = 2000, vals = { 13,14 } }, + { x = 260, y = 400, min = 1000, max = 2000, vals = { 11,12 } }, + + }, +} diff --git a/src/SCRIPTS/BF/NV14/rx.lua b/src/SCRIPTS/BF/NV14/rx.lua new file mode 100644 index 00000000..6e23bdff --- /dev/null +++ b/src/SCRIPTS/BF/NV14/rx.lua @@ -0,0 +1,24 @@ +return { + read = 44, -- MSP_RX_CONFIG + write = 45, -- MSP_SET_RX_CONFIG + title = "RX", + reboot = false, + eepromWrite = true, + minBytes = 23, + text= { + { t = "Stick Min", x = 36, y = 68 }, + { t = "Stick Mid", x = 36, y = 110 }, + { t = "Stick Max", x = 36, y = 155 }, + { t = "Cam Angle", x = 36, y = 200 }, + { t = "Interp", x = 36, y = 242 }, + { t = "Interp Int", x = 36, y = 284 } + }, + fields = { + { x = 150, y = 68, min = 1000, max = 2000, vals = { 6, 7 }, to = MIDSIZE }, + { x = 150, y = 110, min = 1000, max = 2000, vals = { 4, 5 }, to = MIDSIZE }, + { x = 150, y = 155, min = 1000, max = 2000, vals = { 2, 3 }, to = MIDSIZE }, + { x = 150, y = 200, min = 0, max = 50, vals = { 23 }, to = MIDSIZE }, + { x = 150, y = 242, min = 0, max = 3, vals = { 13 }, to = MIDSIZE, table={ [0]="Off", "Preset", "Auto", "Manual"} }, + { x = 150, y = 284, min = 1, max = 50, vals = { 14 }, to = MIDSIZE } + }, +} diff --git a/src/SCRIPTS/BF/NV14/vtx.lua b/src/SCRIPTS/BF/NV14/vtx.lua new file mode 100644 index 00000000..1aae0762 --- /dev/null +++ b/src/SCRIPTS/BF/NV14/vtx.lua @@ -0,0 +1,269 @@ + +return { + read = 88, -- MSP_VTX_CONFIG + write = 89, -- MSP_VTX_SET_CONFIG + eepromWrite = true, + reboot = false, + title = "VTX", + minBytes = 5, + prevBandVal = 0, + prevChanVal = 0, + prevFreqVal = 0, + lastFreqUpdTS = 0, + freqModCounter = 0, + text= { + { t = "Band", x = 36, y = 155 }, + { t = "Channel", x = 36, y = 200 }, + { t = "Power", x = 36, y = 242 }, + { t = "Pit", x = 36, y = 284 }, + { t = "Proto", x = 36, y = 68 }, + { t = "Freq", x = 36, y = 110 }, + }, + fields = { + -- Band + { x = 150, y = 155, min=0, max=5, vals = { 2 }, to = MIDSIZE, + table = { [0]="U", "A", "B", "E", "F", "R" }, + upd = function(self) self.handleBandChanUpdate(self) end }, + -- Channel + { x = 150, y = 200, min=1, max=8, vals = { 3 }, to = MIDSIZE, + upd = function(self) self.handleBandChanUpdate(self) end }, + -- Power + { x = 150, y = 242, min=1, vals = { 4 }, to = MIDSIZE, + upd = function(self) self.updatePowerTable(self) end }, + -- Pit mode + { x = 150, y = 284, min=0, max=1, vals = { 5 }, to = MIDSIZE, + table = { [0]="OFF", "ON" } }, + -- Proto + { x = 150, y = 68, vals = { 1 }, to = MIDSIZE, + write = false, ro = true, + table = { [1]="RTC6705",[3]="SmartAudio",[4]="Tramp",[255]="None"} }, + -- Freq + { x = 150, y = 110, min = 5000, max = 5999, vals = { 6 }, to = MIDSIZE, + upd = function(self) self.handleFreqValUpdate(self) end }, + }, + freqLookup = { + { 5865, 5845, 5825, 5805, 5785, 5765, 5745, 5725 }, -- Boscam A + { 5733, 5752, 5771, 5790, 5809, 5828, 5847, 5866 }, -- Boscam B + { 5705, 5685, 5665, 5645, 5885, 5905, 5925, 5945 }, -- Boscam E + { 5740, 5760, 5780, 5800, 5820, 5840, 5860, 5880 }, -- FatShark + { 5658, 5695, 5732, 5769, 5806, 5843, 5880, 5917 }, -- RaceBand + }, + postLoad = function (self) + if (self.values[2] or 0) < 0 or (self.values[3] or 0) == 0 or (self.values[4] or 0) == 0 then + self.values = {} + else + self.prevBandVal = 0 -- reset value trackers + self.prevChanVal = 0 + self.prevFreqVal = 0 + local rFreq + if (self.values[7] or 0) > 0 then + rFreq = math.floor(self.values[6] + (self.values[7] * 256)) + else + rFreq = 0 + end + if (self.values[2] or 0) > 0 then -- band != 0 + if rFreq > 0 then + self.prevFreqVal = rFreq + self.prevBandVal = self.values[2] + self.prevChanVal = self.values[3] + self.fields[1].min = 0 -- make sure 'U' band allowed + self.eepromWrite = true + self.fields[6].value = rFreq + self.values[6] = rFreq + else -- if user freq not supported then + self.fields[1].min = 1 -- don't allow 'U' band + self.eepromWrite = false -- don't write EEPROM on older Betaflight versions + end + else -- band == 0 + if rFreq > 0 then + self.prevFreqVal = rFreq + self.fields[1].min = 0 -- make sure 'U' band allowed + self.eepromWrite = true + self.fields[6].value = rFreq + self.values[6] = rFreq + -- set chan via freq / 100 + self.prevChanVal = clipValue(math.floor((rFreq - 5100) / 100), + self.fields[2].min, self.fields[2].max) + self.fields[2].value = self.prevChanVal + self.values[3] = self.prevChanVal + else + self.values = {} + end + end + end + end, + preSave = function(self) + local valsTemp = {} + if self.values then + local channel + if self.values[2] > 0 then -- band != 0 + channel = (self.values[2]-1)*8 + self.values[3]-1 + elseif self.fields[6].value then -- band == 0 + channel = self.fields[6].value + else + channel = 24 + end + valsTemp[1] = bit32.band(channel,0xFF) + valsTemp[2] = bit32.rshift(channel,8) + valsTemp[3] = self.values[4] + valsTemp[4] = self.values[5] + end + return valsTemp + end, + -- find closest value in freq table that is above/below given freq + findNextInFreqTable = function(self, newFreq) + local startBand + local endBand + local incFlag -- freq increasing or decreasing + if newFreq > self.prevFreqVal then + incFlag = 1 + startBand = 1 + endBand = self.fields[1].max + else + incFlag = -1 + startBand = self.fields[1].max + endBand = 1 + end + local curBand = self.values[2] + local curChan = self.values[3] + local selBand = 0 + local selChan = 0 + local selFreq = 0 + local diffVal = 9999 + local fVal + local minChan = self.fields[2].min + local maxChan = self.fields[2].max + -- need to scan bands in same "direction" as 'incFlag' + -- so same-freq selections will be handled properly (F8 & R7) + for band=startBand,endBand,incFlag do + for chan=minChan,maxChan do + if band ~= curBand or chan ~= curChan then -- don't reselect same band/chan + fVal = self.freqLookup[band][chan] + if incFlag > 0 then + if fVal >= self.prevFreqVal and fVal - self.prevFreqVal < diffVal then + -- if same freq then only select if "next" band: + if fVal ~= self.prevFreqVal or band > curBand then + selBand = band + selChan = chan + selFreq = fVal + diffVal = fVal - self.prevFreqVal + end + end + else + if fVal <= self.prevFreqVal and self.prevFreqVal - fVal < diffVal then + -- if same freq then only select if "previous" band: + if fVal ~= self.prevFreqVal or band < curBand then + selBand = band + selChan = chan + selFreq = fVal + diffVal = self.prevFreqVal - fVal + end + end + end + end + end + end + return selFreq, selBand, selChan + end, + -- returns the next user-frequency value in MHz; implements an + -- "exponential" modification rate so dialing in values is faster + getNextUserFreqValue = function(self, newFreq) + local now = getTime() -- track rate of change for possible mod speedup + if now < self.lastFreqUpdTS + 15 then + self.freqModCounter = self.freqModCounter + (15-(self.lastFreqUpdTS-now)) -- increase counter for mod speedup + else + self.freqModCounter = 0 -- no mod speedup + end + local uFreq + if self.freqModCounter > 65 then -- rate is fast enough; do mod speedup + if newFreq > self.prevFreqVal then + uFreq = clipValue(newFreq + math.floor(self.freqModCounter / 65), + self.fields[6].min, self.fields[6].max) + else + uFreq = clipValue(newFreq - math.floor(self.freqModCounter / 65), + self.fields[6].min, self.fields[6].max) + end + else + uFreq = newFreq + end + self.lastFreqUpdTS = now + return uFreq + end, + updatePowerTable = function(self) + if self.values and not self.fields[3].table then + if self.values[1] == 1 then -- RTC6705 + self.fields[3].table = { 25, 200 } + self.fields[3].max = 2 + self.fields[4].t = nil -- don't display Pit field + self.fields[4].table = { [0]="", "" } + elseif self.values[1] == 3 then -- SmartAudio + self.fields[3].table = { 25, 200, 500, 800 } + self.fields[3].max = 4 + elseif self.values[1] == 4 then -- Tramp + self.fields[3].table = { 25, 100, 200, 400, 600 } + self.fields[3].max = 5 + elseif self.values[1] == 255 then -- None/Unknown + self.fields[3].t = nil -- don't display Power field + self.fields[3].max = 1 + self.fields[3].table = { [1]="" } + self.fields[4].t = nil -- don't display Pit field + self.fields[4].table = { [0]="", "" } + end + end + end, + handleBandChanUpdate = function(self) + if (#(self.values) or 0) >= self.minBytes then + if (self.values[3] or 0) > 0 then + if self.values[2] ~= self.prevBandVal or self.values[3] ~= self.prevChanVal then + if self.values[2] > 0 then -- band != 0 + self.prevFreqVal = self.freqLookup[self.values[2]][self.values[3]] + else -- band == 0; set freq via channel*100 + self.prevFreqVal = math.floor(5100 + (self.values[3] * 100)) + end + self.fields[6].value = self.prevFreqVal + self.values[6] = self.prevFreqVal + self.prevBandVal = self.values[2] + self.prevChanVal = self.values[3] + end + end + end + end, + handleFreqValUpdate = function(self) + if (#(self.values) or 0) >= self.minBytes and (self.fields[6].value or 0) > 0 then + local newFreq = self.fields[6].value + if newFreq ~= self.prevFreqVal then + if self.values[2] == 0 then + -- band == 0 + local uFreq = self.getNextUserFreqValue(self, newFreq) + self.prevFreqVal = uFreq + if uFreq ~= newFreq then + self.fields[6].value = uFreq + self.values[6] = uFreq + end + -- set channel value via freq/100 + self.prevChanVal = clipValue(math.floor((self.prevFreqVal - 5100) / 100), + self.fields[2].min, self.fields[2].max) + self.fields[2].value = self.prevChanVal + self.values[3] = self.prevChanVal + else + -- band != 0; find closest freq in table that is above/below dialed freq + local selFreq, selBand, selChan = self.findNextInFreqTable(self, newFreq) + if selFreq > 0 then + self.prevFreqVal = selFreq + self.prevBandVal = selBand + self.prevChanVal = selChan + self.fields[6].value = selFreq -- using new freq from table + self.values[6] = selFreq + self.fields[1].value = self.prevBandVal -- set band value for freq + self.values[2] = self.prevBandVal + self.fields[2].value = self.prevChanVal -- set channel value for freq + self.values[3] = self.prevChanVal + else + self.fields[6].value = self.prevFreqVal -- if no match then revert freq + self.values[6] = self.prevFreqVal + end + end + end + end + end +} \ No newline at end of file diff --git a/src/SCRIPTS/BF/events.lua b/src/SCRIPTS/BF/events.lua index e66d14c4..eedecb76 100644 --- a/src/SCRIPTS/BF/events.lua +++ b/src/SCRIPTS/BF/events.lua @@ -16,7 +16,7 @@ return plus = EVT_PLUS_REPT }, release = { - enter = EVT_ENTER_BREAK, + enter = EVT_ENTER_BREAK or EVT_ROT_BREAK, exit = EVT_EXIT_BREAK, menu = EVT_MENU_BREAK or EVT_RIGHT_BREAK, minus = EVT_MINUS_BREAK, diff --git a/src/SCRIPTS/BF/radios.lua b/src/SCRIPTS/BF/radios.lua index 4d1e994e..b5dde5d2 100644 --- a/src/SCRIPTS/BF/radios.lua +++ b/src/SCRIPTS/BF/radios.lua @@ -19,8 +19,14 @@ local supportedPlatforms = { }, horus = { - templateHome=SCRIPT_HOME.."/HORUS/", - preLoad=SCRIPT_HOME.."/HORUS/horuspre.lua", + templateHome = SCRIPT_HOME.."/HORUS/", + preLoad = SCRIPT_HOME.."/HORUS/horuspre.lua", + resolution = lcdResolution.high + }, + nv14 = + { + templateHome = SCRIPT_HOME.."/NV14/", + preLoad = SCRIPT_HOME.."/NV14/nv14pre.lua", resolution = lcdResolution.high }, } @@ -38,6 +44,7 @@ local supportedRadios = ["x9e"] = supportedPlatforms.x9, ["x10"] = supportedPlatforms.horus, ["x12s"] = supportedPlatforms.horus, + ["NV14"] = supportedPlatforms.nv14, } local ver, rad, maj, min, rev = getVersion()