Replacing “blink on landing” overlay code for new VTX code

10.3.x-maintenance
sheaivey 2017-06-10 12:17:00 -07:00
parent e9febfa6e0
commit cce9cfa9f9
3 changed files with 118 additions and 122 deletions

View File

@ -64,9 +64,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
CONFIG.activeSensors = data.readU16(); CONFIG.activeSensors = data.readU16();
CONFIG.mode = data.readU32(); CONFIG.mode = data.readU32();
CONFIG.profile = data.readU8(); CONFIG.profile = data.readU8();
TABS.pid_tuning.checkUpdateProfile(false); TABS.pid_tuning.checkUpdateProfile(false);
sensor_status(CONFIG.activeSensors); sensor_status(CONFIG.activeSensors);
$('span.i2c-error').text(CONFIG.i2cError); $('span.i2c-error').text(CONFIG.i2cError);
$('span.cycle-time').text(CONFIG.cycleTime); $('span.cycle-time').text(CONFIG.cycleTime);
@ -81,28 +81,28 @@ MspHelper.prototype.process_data = function(dataHandler) {
if (semver.gte(CONFIG.apiVersion, "1.16.0")) { if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
CONFIG.numProfiles = data.readU8(); CONFIG.numProfiles = data.readU8();
CONFIG.rateProfile = data.readU8(); CONFIG.rateProfile = data.readU8();
TABS.pid_tuning.checkUpdateProfile(true); TABS.pid_tuning.checkUpdateProfile(true);
} }
sensor_status(CONFIG.activeSensors); sensor_status(CONFIG.activeSensors);
$('span.i2c-error').text(CONFIG.i2cError); $('span.i2c-error').text(CONFIG.i2cError);
$('span.cycle-time').text(CONFIG.cycleTime); $('span.cycle-time').text(CONFIG.cycleTime);
$('span.cpu-load').text(chrome.i18n.getMessage('statusbar_cpu_load', [CONFIG.cpuload])); $('span.cpu-load').text(chrome.i18n.getMessage('statusbar_cpu_load', [CONFIG.cpuload]));
break; break;
case MSPCodes.MSP_RAW_IMU: case MSPCodes.MSP_RAW_IMU:
// 512 for mpu6050, 256 for mma // 512 for mpu6050, 256 for mma
// currently we are unable to differentiate between the sensor types, so we are goign with 512 // currently we are unable to differentiate between the sensor types, so we are goign with 512
SENSOR_DATA.accelerometer[0] = data.read16() / 512; SENSOR_DATA.accelerometer[0] = data.read16() / 512;
SENSOR_DATA.accelerometer[1] = data.read16() / 512; SENSOR_DATA.accelerometer[1] = data.read16() / 512;
SENSOR_DATA.accelerometer[2] = data.read16() / 512; SENSOR_DATA.accelerometer[2] = data.read16() / 512;
// properly scaled // properly scaled
SENSOR_DATA.gyroscope[0] = data.read16() * (4 / 16.4); SENSOR_DATA.gyroscope[0] = data.read16() * (4 / 16.4);
SENSOR_DATA.gyroscope[1] = data.read16() * (4 / 16.4); SENSOR_DATA.gyroscope[1] = data.read16() * (4 / 16.4);
SENSOR_DATA.gyroscope[2] = data.read16() * (4 / 16.4); SENSOR_DATA.gyroscope[2] = data.read16() * (4 / 16.4);
// no clue about scaling factor // no clue about scaling factor
SENSOR_DATA.magnetometer[0] = data.read16() / 1090; SENSOR_DATA.magnetometer[0] = data.read16() / 1090;
SENSOR_DATA.magnetometer[1] = data.read16() / 1090; SENSOR_DATA.magnetometer[1] = data.read16() / 1090;
@ -165,7 +165,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
var voltageMeter = {}; var voltageMeter = {};
voltageMeter.id = data.readU8(); voltageMeter.id = data.readU8();
voltageMeter.voltage = data.readU8() / 10.0; voltageMeter.voltage = data.readU8() / 10.0;
VOLTAGE_METERS.push(voltageMeter) VOLTAGE_METERS.push(voltageMeter)
} }
break; break;
@ -177,23 +177,23 @@ MspHelper.prototype.process_data = function(dataHandler) {
currentMeter.id = data.readU8(); currentMeter.id = data.readU8();
currentMeter.mAhDrawn = data.readU16(); // mAh currentMeter.mAhDrawn = data.readU16(); // mAh
currentMeter.amperage = data.readU16() / 1000; // A currentMeter.amperage = data.readU16() / 1000; // A
CURRENT_METERS.push(currentMeter); CURRENT_METERS.push(currentMeter);
} }
break; break;
case MSPCodes.MSP_BATTERY_STATE: case MSPCodes.MSP_BATTERY_STATE:
BATTERY_STATE.cellCount = data.readU8(); BATTERY_STATE.cellCount = data.readU8();
BATTERY_STATE.capacity = data.readU16(); // mAh BATTERY_STATE.capacity = data.readU16(); // mAh
BATTERY_STATE.voltage = data.readU8() / 10.0; // V BATTERY_STATE.voltage = data.readU8() / 10.0; // V
BATTERY_STATE.mAhDrawn = data.readU16(); // mAh BATTERY_STATE.mAhDrawn = data.readU16(); // mAh
BATTERY_STATE.amperage = data.readU16() / 100; // A BATTERY_STATE.amperage = data.readU16() / 100; // A
break; break;
case MSPCodes.MSP_VOLTAGE_METER_CONFIG: case MSPCodes.MSP_VOLTAGE_METER_CONFIG:
VOLTAGE_METER_CONFIGS = []; VOLTAGE_METER_CONFIGS = [];
var voltage_meter_count = data.readU8(); var voltage_meter_count = data.readU8();
for (var i = 0; i < voltage_meter_count; i++) { for (var i = 0; i < voltage_meter_count; i++) {
var subframe_length = data.readU8(); var subframe_length = data.readU8();
if (subframe_length != 5) { if (subframe_length != 5) {
@ -207,7 +207,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
voltageMeterConfig.vbatscale = data.readU8(); voltageMeterConfig.vbatscale = data.readU8();
voltageMeterConfig.vbatresdivval = data.readU8(); voltageMeterConfig.vbatresdivval = data.readU8();
voltageMeterConfig.vbatresdivmultiplier = data.readU8(); voltageMeterConfig.vbatresdivmultiplier = data.readU8();
VOLTAGE_METER_CONFIGS.push(voltageMeterConfig); VOLTAGE_METER_CONFIGS.push(voltageMeterConfig);
} }
} }
@ -219,7 +219,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
for (var i = 0; i < current_meter_count; i++) { for (var i = 0; i < current_meter_count; i++) {
var currentMeterConfig = {}; var currentMeterConfig = {};
var subframe_length = data.readU8(); var subframe_length = data.readU8();
if (subframe_length != 6) { if (subframe_length != 6) {
for (var j = 0; j < subframe_length; j++) { for (var j = 0; j < subframe_length; j++) {
data.readU8(); data.readU8();
@ -229,12 +229,12 @@ MspHelper.prototype.process_data = function(dataHandler) {
currentMeterConfig.sensorType = data.readU8(); currentMeterConfig.sensorType = data.readU8();
currentMeterConfig.scale = data.readU16(); currentMeterConfig.scale = data.readU16();
currentMeterConfig.offset = data.readU16(); currentMeterConfig.offset = data.readU16();
CURRENT_METER_CONFIGS.push(currentMeterConfig); CURRENT_METER_CONFIGS.push(currentMeterConfig);
} }
} }
break; break;
case MSPCodes.MSP_BATTERY_CONFIG: case MSPCodes.MSP_BATTERY_CONFIG:
BATTERY_CONFIG.vbatmincellvoltage = data.readU8() / 10; // 10-50 BATTERY_CONFIG.vbatmincellvoltage = data.readU8() / 10; // 10-50
BATTERY_CONFIG.vbatmaxcellvoltage = data.readU8() / 10; // 10-50 BATTERY_CONFIG.vbatmaxcellvoltage = data.readU8() / 10; // 10-50
@ -242,7 +242,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
BATTERY_CONFIG.capacity = data.readU16(); BATTERY_CONFIG.capacity = data.readU16();
BATTERY_CONFIG.voltageMeterSource = data.readU8(); BATTERY_CONFIG.voltageMeterSource = data.readU8();
BATTERY_CONFIG.currentMeterSource = data.readU8(); BATTERY_CONFIG.currentMeterSource = data.readU8();
break; break;
case MSPCodes.MSP_RC_TUNING: case MSPCodes.MSP_RC_TUNING:
RC_tuning.RC_RATE = parseFloat((data.readU8() / 100).toFixed(2)); RC_tuning.RC_RATE = parseFloat((data.readU8() / 100).toFixed(2));
@ -285,7 +285,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
} }
} }
break; break;
case MSPCodes.MSP_ARMING_CONFIG: case MSPCodes.MSP_ARMING_CONFIG:
if (semver.gte(CONFIG.apiVersion, "1.8.0")) { if (semver.gte(CONFIG.apiVersion, "1.8.0")) {
ARMING_CONFIG.auto_disarm_delay = data.readU8(); ARMING_CONFIG.auto_disarm_delay = data.readU8();
@ -317,7 +317,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
MISC.vbatmincellvoltage = data.readU8() / 10; // 10-50 MISC.vbatmincellvoltage = data.readU8() / 10; // 10-50
MISC.vbatmaxcellvoltage = data.readU8() / 10; // 10-50 MISC.vbatmaxcellvoltage = data.readU8() / 10; // 10-50
MISC.vbatwarningcellvoltage = data.readU8() / 10; // 10-50 MISC.vbatwarningcellvoltage = data.readU8() / 10; // 10-50
break; break;
case MSPCodes.MSP_MOTOR_CONFIG: case MSPCodes.MSP_MOTOR_CONFIG:
MOTOR_CONFIG.minthrottle = data.readU16(); // 0-2000 MOTOR_CONFIG.minthrottle = data.readU16(); // 0-2000
MOTOR_CONFIG.maxthrottle = data.readU16(); // 0-2000 MOTOR_CONFIG.maxthrottle = data.readU16(); // 0-2000
@ -347,13 +347,13 @@ MspHelper.prototype.process_data = function(dataHandler) {
break; break;
case MSPCodes.MSP_BOXNAMES: case MSPCodes.MSP_BOXNAMES:
AUX_CONFIG = []; // empty the array as new data is coming in AUX_CONFIG = []; // empty the array as new data is coming in
var buff = []; var buff = [];
for (var i = 0; i < data.byteLength; i++) { for (var i = 0; i < data.byteLength; i++) {
var char = data.readU8(); var char = data.readU8();
if (char == 0x3B) { // ; (delimeter char) if (char == 0x3B) { // ; (delimeter char)
AUX_CONFIG.push(String.fromCharCode.apply(null, buff)); // convert bytes into ASCII and save as strings AUX_CONFIG.push(String.fromCharCode.apply(null, buff)); // convert bytes into ASCII and save as strings
// empty buffer // empty buffer
buff = []; buff = [];
} else { } else {
@ -363,13 +363,13 @@ MspHelper.prototype.process_data = function(dataHandler) {
break; break;
case MSPCodes.MSP_PIDNAMES: case MSPCodes.MSP_PIDNAMES:
PID_names = []; // empty the array as new data is coming in PID_names = []; // empty the array as new data is coming in
var buff = []; var buff = [];
for (var i = 0; i < data.byteLength; i++) { for (var i = 0; i < data.byteLength; i++) {
var char = data.readU8(); var char = data.readU8();
if (char == 0x3B) { // ; (delimeter char) if (char == 0x3B) { // ; (delimeter char)
PID_names.push(String.fromCharCode.apply(null, buff)); // convert bytes into ASCII and save as strings PID_names.push(String.fromCharCode.apply(null, buff)); // convert bytes into ASCII and save as strings
// empty buffer // empty buffer
buff = []; buff = [];
} else { } else {
@ -379,14 +379,14 @@ MspHelper.prototype.process_data = function(dataHandler) {
break; break;
case MSPCodes.MSP_BOXIDS: case MSPCodes.MSP_BOXIDS:
AUX_CONFIG_IDS = []; // empty the array as new data is coming in AUX_CONFIG_IDS = []; // empty the array as new data is coming in
for (var i = 0; i < data.byteLength; i++) { for (var i = 0; i < data.byteLength; i++) {
AUX_CONFIG_IDS.push(data.readU8()); AUX_CONFIG_IDS.push(data.readU8());
} }
break; break;
case MSPCodes.MSP_SERVO_MIX_RULES: case MSPCodes.MSP_SERVO_MIX_RULES:
break; break;
case MSPCodes.MSP_SERVO_CONFIGURATIONS: case MSPCodes.MSP_SERVO_CONFIGURATIONS:
SERVO_CONFIG = []; // empty the array as new data is coming in SERVO_CONFIG = []; // empty the array as new data is coming in
if (semver.gte(CONFIG.apiVersion, "1.33.0")) { if (semver.gte(CONFIG.apiVersion, "1.33.0")) {
@ -402,7 +402,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
'indexOfChannelToForward': data.readU8(), 'indexOfChannelToForward': data.readU8(),
'reversedInputSources': data.readU32() 'reversedInputSources': data.readU32()
}; };
SERVO_CONFIG.push(arr); SERVO_CONFIG.push(arr);
} }
} }
@ -419,7 +419,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
'indexOfChannelToForward': data.readU8(), 'indexOfChannelToForward': data.readU8(),
'reversedInputSources': data.readU32() 'reversedInputSources': data.readU32()
}; };
SERVO_CONFIG.push(arr); SERVO_CONFIG.push(arr);
} }
} }
@ -436,11 +436,11 @@ MspHelper.prototype.process_data = function(dataHandler) {
'indexOfChannelToForward': undefined, 'indexOfChannelToForward': undefined,
'reversedInputSources': 0 'reversedInputSources': 0
}; };
SERVO_CONFIG.push(arr); SERVO_CONFIG.push(arr);
} }
} }
if (semver.eq(CONFIG.apiVersion, '1.10.0')) { if (semver.eq(CONFIG.apiVersion, '1.10.0')) {
// drop two unused servo configurations due to MSP rx buffer to small) // drop two unused servo configurations due to MSP rx buffer to small)
while (SERVO_CONFIG.length > 8) { while (SERVO_CONFIG.length > 8) {
@ -453,7 +453,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
RC_DEADBAND_CONFIG.deadband = data.readU8(); RC_DEADBAND_CONFIG.deadband = data.readU8();
RC_DEADBAND_CONFIG.yaw_deadband = data.readU8(); RC_DEADBAND_CONFIG.yaw_deadband = data.readU8();
RC_DEADBAND_CONFIG.alt_hold_deadband = data.readU8(); RC_DEADBAND_CONFIG.alt_hold_deadband = data.readU8();
if (semver.gte(CONFIG.apiVersion, "1.17.0")) { if (semver.gte(CONFIG.apiVersion, "1.17.0")) {
RC_DEADBAND_CONFIG.deadband3d_throttle = data.readU16(); RC_DEADBAND_CONFIG.deadband3d_throttle = data.readU16();
} }
@ -530,7 +530,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
case MSPCodes.MSP_GPS_SV_INFO: case MSPCodes.MSP_GPS_SV_INFO:
if (data.byteLength > 0) { if (data.byteLength > 0) {
var numCh = data.readU8(); var numCh = data.readU8();
for (var i = 0; i < numCh; i++) { for (var i = 0; i < numCh; i++) {
GPS_DATA.chn[i] = data.readU8(); GPS_DATA.chn[i] = data.readU8();
GPS_DATA.svid[i] = data.readU8(); GPS_DATA.svid[i] = data.readU8();
@ -539,10 +539,10 @@ MspHelper.prototype.process_data = function(dataHandler) {
} }
} }
break; break;
case MSPCodes.MSP_RX_MAP: case MSPCodes.MSP_RX_MAP:
RC_MAP = []; // empty the array as new data is coming in RC_MAP = []; // empty the array as new data is coming in
for (var i = 0; i < data.byteLength; i++) { for (var i = 0; i < data.byteLength; i++) {
RC_MAP.push(data.readU8()); RC_MAP.push(data.readU8());
} }
@ -550,32 +550,32 @@ MspHelper.prototype.process_data = function(dataHandler) {
case MSPCodes.MSP_SET_RX_MAP: case MSPCodes.MSP_SET_RX_MAP:
console.log('RCMAP saved'); console.log('RCMAP saved');
break; break;
case MSPCodes.MSP_MIXER_CONFIG: case MSPCodes.MSP_MIXER_CONFIG:
MIXER_CONFIG.mixer = data.readU8(); MIXER_CONFIG.mixer = data.readU8();
break; break;
case MSPCodes.MSP_FEATURE_CONFIG: case MSPCodes.MSP_FEATURE_CONFIG:
FEATURE_CONFIG.features.setMask(data.readU32()); FEATURE_CONFIG.features.setMask(data.readU32());
updateTabList(FEATURE_CONFIG.features); updateTabList(FEATURE_CONFIG.features);
break; break;
case MSPCodes.MSP_BOARD_ALIGNMENT_CONFIG: case MSPCodes.MSP_BOARD_ALIGNMENT_CONFIG:
BOARD_ALIGNMENT_CONFIG.roll = data.read16(); // -180 - 360 BOARD_ALIGNMENT_CONFIG.roll = data.read16(); // -180 - 360
BOARD_ALIGNMENT_CONFIG.pitch = data.read16(); // -180 - 360 BOARD_ALIGNMENT_CONFIG.pitch = data.read16(); // -180 - 360
BOARD_ALIGNMENT_CONFIG.yaw = data.read16(); // -180 - 360 BOARD_ALIGNMENT_CONFIG.yaw = data.read16(); // -180 - 360
break; break;
case MSPCodes.MSP_SET_REBOOT: case MSPCodes.MSP_SET_REBOOT:
console.log('Reboot request accepted'); console.log('Reboot request accepted');
break; break;
case MSPCodes.MSP_API_VERSION: case MSPCodes.MSP_API_VERSION:
CONFIG.mspProtocolVersion = data.readU8(); CONFIG.mspProtocolVersion = data.readU8();
CONFIG.apiVersion = data.readU8() + '.' + data.readU8() + '.0'; CONFIG.apiVersion = data.readU8() + '.' + data.readU8() + '.0';
break; break;
case MSPCodes.MSP_FC_VARIANT: case MSPCodes.MSP_FC_VARIANT:
var identifier = ''; var identifier = '';
for (var i = 0; i < 4; i++) { for (var i = 0; i < 4; i++) {
@ -583,11 +583,11 @@ MspHelper.prototype.process_data = function(dataHandler) {
} }
CONFIG.flightControllerIdentifier = identifier; CONFIG.flightControllerIdentifier = identifier;
break; break;
case MSPCodes.MSP_FC_VERSION: case MSPCodes.MSP_FC_VERSION:
CONFIG.flightControllerVersion = data.readU8() + '.' + data.readU8() + '.' + data.readU8(); CONFIG.flightControllerVersion = data.readU8() + '.' + data.readU8() + '.' + data.readU8();
break; break;
case MSPCodes.MSP_BUILD_INFO: case MSPCodes.MSP_BUILD_INFO:
var dateLength = 11; var dateLength = 11;
var buff = []; var buff = [];
@ -595,14 +595,14 @@ MspHelper.prototype.process_data = function(dataHandler) {
buff.push(data.readU8()); buff.push(data.readU8());
} }
buff.push(32); // ascii space buff.push(32); // ascii space
var timeLength = 8; var timeLength = 8;
for (var i = 0; i < timeLength; i++) { for (var i = 0; i < timeLength; i++) {
buff.push(data.readU8()); buff.push(data.readU8());
} }
CONFIG.buildInfo = String.fromCharCode.apply(null, buff); CONFIG.buildInfo = String.fromCharCode.apply(null, buff);
break; break;
case MSPCodes.MSP_BOARD_INFO: case MSPCodes.MSP_BOARD_INFO:
var identifier = ''; var identifier = '';
for (var i = 0; i < 4; i++) { for (var i = 0; i < 4; i++) {
@ -617,7 +617,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
} }
break; break;
case MSPCodes.MSP_NAME: case MSPCodes.MSP_NAME:
CONFIG.name = ''; CONFIG.name = '';
var char; var char;
@ -625,11 +625,11 @@ MspHelper.prototype.process_data = function(dataHandler) {
CONFIG.name += String.fromCharCode(char); CONFIG.name += String.fromCharCode(char);
} }
break; break;
case MSPCodes.MSP_SET_CHANNEL_FORWARDING: case MSPCodes.MSP_SET_CHANNEL_FORWARDING:
console.log('Channel forwarding saved'); console.log('Channel forwarding saved');
break; break;
case MSPCodes.MSP_CF_SERIAL_CONFIG: case MSPCodes.MSP_CF_SERIAL_CONFIG:
if (semver.lt(CONFIG.apiVersion, "1.6.0")) { if (semver.lt(CONFIG.apiVersion, "1.6.0")) {
SERIAL_CONFIG.ports = []; SERIAL_CONFIG.ports = [];
@ -649,7 +649,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
SERIAL_CONFIG.ports = []; SERIAL_CONFIG.ports = [];
var bytesPerPort = 1 + 2 + (1 * 4); var bytesPerPort = 1 + 2 + (1 * 4);
var serialPortCount = data.byteLength / bytesPerPort; var serialPortCount = data.byteLength / bytesPerPort;
for (var i = 0; i < serialPortCount; i++) { for (var i = 0; i < serialPortCount; i++) {
var serialPort = { var serialPort = {
identifier: data.readU8(), identifier: data.readU8(),
@ -659,21 +659,21 @@ MspHelper.prototype.process_data = function(dataHandler) {
telemetry_baudrate: self.BAUD_RATES[data.readU8()], telemetry_baudrate: self.BAUD_RATES[data.readU8()],
blackbox_baudrate: self.BAUD_RATES[data.readU8()] blackbox_baudrate: self.BAUD_RATES[data.readU8()]
} }
SERIAL_CONFIG.ports.push(serialPort); SERIAL_CONFIG.ports.push(serialPort);
} }
} }
break; break;
case MSPCodes.MSP_SET_CF_SERIAL_CONFIG: case MSPCodes.MSP_SET_CF_SERIAL_CONFIG:
console.log('Serial config saved'); console.log('Serial config saved');
break; break;
case MSPCodes.MSP_MODE_RANGES: case MSPCodes.MSP_MODE_RANGES:
MODE_RANGES = []; // empty the array as new data is coming in MODE_RANGES = []; // empty the array as new data is coming in
var modeRangeCount = data.byteLength / 4; // 4 bytes per item. var modeRangeCount = data.byteLength / 4; // 4 bytes per item.
for (var i = 0; i < modeRangeCount; i++) { for (var i = 0; i < modeRangeCount; i++) {
var modeRange = { var modeRange = {
id: data.readU8(), id: data.readU8(),
@ -686,12 +686,12 @@ MspHelper.prototype.process_data = function(dataHandler) {
MODE_RANGES.push(modeRange); MODE_RANGES.push(modeRange);
} }
break; break;
case MSPCodes.MSP_ADJUSTMENT_RANGES: case MSPCodes.MSP_ADJUSTMENT_RANGES:
ADJUSTMENT_RANGES = []; // empty the array as new data is coming in ADJUSTMENT_RANGES = []; // empty the array as new data is coming in
var adjustmentRangeCount = data.byteLength / 6; // 6 bytes per item. var adjustmentRangeCount = data.byteLength / 6; // 6 bytes per item.
for (var i = 0; i < adjustmentRangeCount; i++) { for (var i = 0; i < adjustmentRangeCount; i++) {
var adjustmentRange = { var adjustmentRange = {
slotIndex: data.readU8(), slotIndex: data.readU8(),
@ -706,7 +706,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
ADJUSTMENT_RANGES.push(adjustmentRange); ADJUSTMENT_RANGES.push(adjustmentRange);
} }
break; break;
case MSPCodes.MSP_RX_CONFIG: case MSPCodes.MSP_RX_CONFIG:
RX_CONFIG.serialrx_provider = data.readU8(); RX_CONFIG.serialrx_provider = data.readU8();
RX_CONFIG.stick_max = data.readU16(); RX_CONFIG.stick_max = data.readU16();
@ -736,7 +736,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
RX_CONFIG.airModeActivateThreshold = 0; RX_CONFIG.airModeActivateThreshold = 0;
} }
break; break;
case MSPCodes.MSP_FAILSAFE_CONFIG: case MSPCodes.MSP_FAILSAFE_CONFIG:
FAILSAFE_CONFIG.failsafe_delay = data.readU8(); FAILSAFE_CONFIG.failsafe_delay = data.readU8();
FAILSAFE_CONFIG.failsafe_off_delay = data.readU8(); FAILSAFE_CONFIG.failsafe_off_delay = data.readU8();
@ -747,10 +747,10 @@ MspHelper.prototype.process_data = function(dataHandler) {
FAILSAFE_CONFIG.failsafe_procedure = data.readU8(); FAILSAFE_CONFIG.failsafe_procedure = data.readU8();
} }
break; break;
case MSPCodes.MSP_RXFAIL_CONFIG: case MSPCodes.MSP_RXFAIL_CONFIG:
RXFAIL_CONFIG = []; // empty the array as new data is coming in RXFAIL_CONFIG = []; // empty the array as new data is coming in
var channelCount = data.byteLength / 3; var channelCount = data.byteLength / 3;
for (var i = 0; i < channelCount; i++) { for (var i = 0; i < channelCount; i++) {
var rxfailChannel = { var rxfailChannel = {
@ -760,7 +760,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
RXFAIL_CONFIG.push(rxfailChannel); RXFAIL_CONFIG.push(rxfailChannel);
} }
break; break;
case MSPCodes.MSP_ADVANCED_CONFIG: case MSPCodes.MSP_ADVANCED_CONFIG:
PID_ADVANCED_CONFIG.gyro_sync_denom = data.readU8(); PID_ADVANCED_CONFIG.gyro_sync_denom = data.readU8();
PID_ADVANCED_CONFIG.pid_process_denom = data.readU8(); PID_ADVANCED_CONFIG.pid_process_denom = data.readU8();
@ -769,7 +769,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
PID_ADVANCED_CONFIG.motor_pwm_rate = data.readU16(); PID_ADVANCED_CONFIG.motor_pwm_rate = data.readU16();
if (semver.gte(CONFIG.apiVersion, "1.24.0")) { if (semver.gte(CONFIG.apiVersion, "1.24.0")) {
PID_ADVANCED_CONFIG.digitalIdlePercent = data.readU16() / 100; PID_ADVANCED_CONFIG.digitalIdlePercent = data.readU16() / 100;
if (semver.gte(CONFIG.apiVersion, "1.25.0")) { if (semver.gte(CONFIG.apiVersion, "1.25.0")) {
PID_ADVANCED_CONFIG.gyroUse32kHz = data.readU8(); PID_ADVANCED_CONFIG.gyroUse32kHz = data.readU8();
} }
@ -818,41 +818,41 @@ MspHelper.prototype.process_data = function(dataHandler) {
SENSOR_CONFIG.baro_hardware = data.readU8(); SENSOR_CONFIG.baro_hardware = data.readU8();
SENSOR_CONFIG.mag_hardware = data.readU8(); SENSOR_CONFIG.mag_hardware = data.readU8();
break; break;
case MSPCodes.MSP_LED_STRIP_CONFIG: case MSPCodes.MSP_LED_STRIP_CONFIG:
LED_STRIP = []; LED_STRIP = [];
var ledDirectionLetters = ['n', 'e', 's', 'w', 'u', 'd']; // in LSB bit order var ledDirectionLetters = ['n', 'e', 's', 'w', 'u', 'd']; // in LSB bit order
var ledFunctionLetters = ['i', 'w', 'f', 'a', 't', 'r', 'c', 'g', 's', 'b', 'l']; // in LSB bit order var ledFunctionLetters = ['i', 'w', 'f', 'a', 't', 'r', 'c', 'g', 's', 'b', 'l']; // in LSB bit order
var ledBaseFunctionLetters = ['c', 'f', 'a', 'l', 's', 'g', 'r']; // in LSB bit var ledBaseFunctionLetters = ['c', 'f', 'a', 'l', 's', 'g', 'r']; // in LSB bit
var ledOverlayLetters = ['t', 'o', 'b', 'n', 'i', 'w']; // in LSB bit var ledOverlayLetters = ['t', 'o', 'b', 'v', 'i', 'w']; // in LSB bit
var ledCount = data.byteLength / 7; // v1.4.0 and below incorrectly reported 4 bytes per led. var ledCount = data.byteLength / 7; // v1.4.0 and below incorrectly reported 4 bytes per led.
if (semver.gte(CONFIG.apiVersion, "1.20.0")) if (semver.gte(CONFIG.apiVersion, "1.20.0"))
ledCount = data.byteLength / 4; ledCount = data.byteLength / 4;
for (var i = 0; i < ledCount; i++) { for (var i = 0; i < ledCount; i++) {
if (semver.lt(CONFIG.apiVersion, "1.20.0")) { if (semver.lt(CONFIG.apiVersion, "1.20.0")) {
var directionMask = data.readU16(); var directionMask = data.readU16();
var directions = []; var directions = [];
for (var directionLetterIndex = 0; directionLetterIndex < ledDirectionLetters.length; directionLetterIndex++) { for (var directionLetterIndex = 0; directionLetterIndex < ledDirectionLetters.length; directionLetterIndex++) {
if (bit_check(directionMask, directionLetterIndex)) { if (bit_check(directionMask, directionLetterIndex)) {
directions.push(ledDirectionLetters[directionLetterIndex]); directions.push(ledDirectionLetters[directionLetterIndex]);
} }
} }
var functionMask = data.readU16(); var functionMask = data.readU16();
var functions = []; var functions = [];
for (var functionLetterIndex = 0; functionLetterIndex < ledFunctionLetters.length; functionLetterIndex++) { for (var functionLetterIndex = 0; functionLetterIndex < ledFunctionLetters.length; functionLetterIndex++) {
if (bit_check(functionMask, functionLetterIndex)) { if (bit_check(functionMask, functionLetterIndex)) {
functions.push(ledFunctionLetters[functionLetterIndex]); functions.push(ledFunctionLetters[functionLetterIndex]);
} }
} }
var led = { var led = {
directions: directions, directions: directions,
functions: functions, functions: functions,
@ -860,11 +860,11 @@ MspHelper.prototype.process_data = function(dataHandler) {
y: data.readU8(), y: data.readU8(),
color: data.readU8() color: data.readU8()
}; };
LED_STRIP.push(led); LED_STRIP.push(led);
} else { } else {
var mask = data.readU32(); var mask = data.readU32();
var functionId = (mask >> 8) & 0xF; var functionId = (mask >> 8) & 0xF;
var functions = []; var functions = [];
for (var baseFunctionLetterIndex = 0; baseFunctionLetterIndex < ledBaseFunctionLetters.length; baseFunctionLetterIndex++) { for (var baseFunctionLetterIndex = 0; baseFunctionLetterIndex < ledBaseFunctionLetters.length; baseFunctionLetterIndex++) {
@ -873,14 +873,14 @@ MspHelper.prototype.process_data = function(dataHandler) {
break; break;
} }
} }
var overlayMask = (mask >> 12) & 0x3F; var overlayMask = (mask >> 12) & 0x3F;
for (var overlayLetterIndex = 0; overlayLetterIndex < ledOverlayLetters.length; overlayLetterIndex++) { for (var overlayLetterIndex = 0; overlayLetterIndex < ledOverlayLetters.length; overlayLetterIndex++) {
if (bit_check(overlayMask, overlayLetterIndex)) { if (bit_check(overlayMask, overlayLetterIndex)) {
functions.push(ledOverlayLetters[overlayLetterIndex]); functions.push(ledOverlayLetters[overlayLetterIndex]);
} }
} }
var directionMask = (mask >> 22) & 0x3F; var directionMask = (mask >> 22) & 0x3F;
var directions = []; var directions = [];
for (var directionLetterIndex = 0; directionLetterIndex < ledDirectionLetters.length; directionLetterIndex++) { for (var directionLetterIndex = 0; directionLetterIndex < ledDirectionLetters.length; directionLetterIndex++) {
@ -896,7 +896,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
directions: directions, directions: directions,
parameters: (mask >> 28) & 0xF parameters: (mask >> 28) & 0xF
}; };
LED_STRIP.push(led); LED_STRIP.push(led);
} }
} }
@ -905,13 +905,13 @@ MspHelper.prototype.process_data = function(dataHandler) {
console.log('Led strip config saved'); console.log('Led strip config saved');
break; break;
case MSPCodes.MSP_LED_COLORS: case MSPCodes.MSP_LED_COLORS:
LED_COLORS = []; LED_COLORS = [];
var colorCount = data.byteLength / 4; var colorCount = data.byteLength / 4;
for (var i = 0; i < colorCount; i++) { for (var i = 0; i < colorCount; i++) {
var color = { var color = {
h: data.readU16(), h: data.readU16(),
s: data.readU8(), s: data.readU8(),
@ -919,20 +919,20 @@ MspHelper.prototype.process_data = function(dataHandler) {
}; };
LED_COLORS.push(color); LED_COLORS.push(color);
} }
break; break;
case MSPCodes.MSP_SET_LED_COLORS: case MSPCodes.MSP_SET_LED_COLORS:
console.log('Led strip colors saved'); console.log('Led strip colors saved');
break; break;
case MSPCodes.MSP_LED_STRIP_MODECOLOR: case MSPCodes.MSP_LED_STRIP_MODECOLOR:
if (semver.gte(CONFIG.apiVersion, "1.19.0")) { if (semver.gte(CONFIG.apiVersion, "1.19.0")) {
LED_MODE_COLORS = []; LED_MODE_COLORS = [];
var colorCount = data.byteLength / 3; var colorCount = data.byteLength / 3;
for (var i = 0; i < colorCount; i++) { for (var i = 0; i < colorCount; i++) {
var mode_color = { var mode_color = {
mode: data.readU8(), mode: data.readU8(),
direction: data.readU8(), direction: data.readU8(),
@ -945,7 +945,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
case MSPCodes.MSP_SET_LED_STRIP_MODECOLOR: case MSPCodes.MSP_SET_LED_STRIP_MODECOLOR:
console.log('Led strip mode colors saved'); console.log('Led strip mode colors saved');
break; break;
case MSPCodes.MSP_DATAFLASH_SUMMARY: case MSPCodes.MSP_DATAFLASH_SUMMARY:
if (data.byteLength >= 13) { if (data.byteLength >= 13) {
var flags = data.readU8(); var flags = data.readU8();
@ -972,7 +972,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
break; break;
case MSPCodes.MSP_SDCARD_SUMMARY: case MSPCodes.MSP_SDCARD_SUMMARY:
var flags = data.readU8(); var flags = data.readU8();
SDCARD.supported = (flags & 0x01) != 0; SDCARD.supported = (flags & 0x01) != 0;
SDCARD.state = data.readU8(); SDCARD.state = data.readU8();
SDCARD.filesystemLastError = data.readU8(); SDCARD.filesystemLastError = data.readU8();
@ -993,30 +993,30 @@ MspHelper.prototype.process_data = function(dataHandler) {
if (semver.gte(CONFIG.apiVersion, "1.33.0")) { if (semver.gte(CONFIG.apiVersion, "1.33.0")) {
var providerCount = data.readU8(); var providerCount = data.readU8();
bytesRemaining--; bytesRemaining--;
TRANSPONDER.supported = providerCount > 0; TRANSPONDER.supported = providerCount > 0;
TRANSPONDER.providers = []; TRANSPONDER.providers = [];
for (var i = 0; i < providerCount; i++) { for (var i = 0; i < providerCount; i++) {
var provider = { var provider = {
id: data.readU8(), id: data.readU8(),
dataLength: data.readU8() dataLength: data.readU8()
}; };
bytesRemaining -= 2; bytesRemaining -= 2;
TRANSPONDER.providers.push(provider); TRANSPONDER.providers.push(provider);
} }
TRANSPONDER.provider = data.readU8(); TRANSPONDER.provider = data.readU8();
bytesRemaining--; bytesRemaining--;
} else { } else {
TRANSPONDER.supported = (data.readU8() & 1) != 0; TRANSPONDER.supported = (data.readU8() & 1) != 0;
bytesRemaining--; bytesRemaining--;
// only ILAP was supported prior to 1.33.0 // only ILAP was supported prior to 1.33.0
TRANSPONDER.providers = [{ TRANSPONDER.providers = [{
id: 1, // ILAP id: 1, // ILAP
dataLength: 6 dataLength: 6
}]; }];
TRANSPONDER.provider = TRANSPONDER.providers[0].id; TRANSPONDER.provider = TRANSPONDER.providers[0].id;
} }
@ -1034,7 +1034,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
case MSPCodes.MSP_SET_ADJUSTMENT_RANGE: case MSPCodes.MSP_SET_ADJUSTMENT_RANGE:
console.log('Adjustment range saved'); console.log('Adjustment range saved');
break; break;
case MSPCodes.MSP_PID_CONTROLLER: case MSPCodes.MSP_PID_CONTROLLER:
PID.controller = data.readU8(); PID.controller = data.readU8();
break; break;
@ -1241,7 +1241,7 @@ MspHelper.prototype.crunch = function(code) {
.push8(BATTERY_CONFIG.voltageMeterSource) .push8(BATTERY_CONFIG.voltageMeterSource)
.push8(BATTERY_CONFIG.currentMeterSource); .push8(BATTERY_CONFIG.currentMeterSource);
break; break;
// FIXME - Needs updating before it can be used. // FIXME - Needs updating before it can be used.
// case MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG: // case MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG:
// buffer.push8(MISC.vbatscale) // buffer.push8(MISC.vbatscale)
// .push8(Math.round(BATTERY_CONFIG.vbatmincellvoltage * 10)) // .push8(Math.round(BATTERY_CONFIG.vbatmincellvoltage * 10))
@ -1292,7 +1292,7 @@ MspHelper.prototype.crunch = function(code) {
case MSPCodes.MSP_SET_TRANSPONDER_CONFIG: case MSPCodes.MSP_SET_TRANSPONDER_CONFIG:
if (semver.gte(CONFIG.apiVersion, "1.33.0")) { if (semver.gte(CONFIG.apiVersion, "1.33.0")) {
buffer.push8(TRANSPONDER.provider); // buffer.push8(TRANSPONDER.provider); //
} }
for (var i = 0; i < TRANSPONDER.data.length; i++) { for (var i = 0; i < TRANSPONDER.data.length; i++) {
buffer.push8(TRANSPONDER.data[i]); buffer.push8(TRANSPONDER.data[i]);
@ -1534,7 +1534,7 @@ MspHelper.prototype.sendServoConfigurations = function(onCompleteCallback) {
.push16(servoConfiguration.max) .push16(servoConfiguration.max)
.push16(servoConfiguration.middle) .push16(servoConfiguration.middle)
.push8(servoConfiguration.rate); .push8(servoConfiguration.rate);
if (semver.gte(CONFIG.apiVersion, "1.33.0")) { if (semver.gte(CONFIG.apiVersion, "1.33.0")) {
buffer.push8(servoConfiguration.angleAtMin) buffer.push8(servoConfiguration.angleAtMin)
.push8(servoConfiguration.angleAtMax); .push8(servoConfiguration.angleAtMax);
@ -1658,7 +1658,7 @@ MspHelper.prototype.sendLedStripConfig = function(onCompleteCallback) {
var ledDirectionLetters = ['n', 'e', 's', 'w', 'u', 'd']; // in LSB bit order var ledDirectionLetters = ['n', 'e', 's', 'w', 'u', 'd']; // in LSB bit order
var ledFunctionLetters = ['i', 'w', 'f', 'a', 't', 'r', 'c', 'g', 's', 'b', 'l']; // in LSB bit order var ledFunctionLetters = ['i', 'w', 'f', 'a', 't', 'r', 'c', 'g', 's', 'b', 'l']; // in LSB bit order
var ledBaseFunctionLetters = ['c', 'f', 'a', 'l', 's', 'g', 'r']; // in LSB bit var ledBaseFunctionLetters = ['c', 'f', 'a', 'l', 's', 'g', 'r']; // in LSB bit
var ledOverlayLetters = ['t', 'o', 'b', 'n', 'i', 'w']; // in LSB bit var ledOverlayLetters = ['t', 'o', 'b', 'v', 'i', 'w']; // in LSB bit
var buffer = []; var buffer = [];

View File

@ -55,8 +55,8 @@
<button class="funcClearAll">Clear ALL</button> <button class="funcClearAll">Clear ALL</button>
<div class="section">LED Functions</div> <div class="section">LED Functions</div>
<div class="select"> <div class="select">
<span class="color_section">Function</span> <span class="color_section">Function</span>
<select class="functionSelect"> <select class="functionSelect">
@ -70,7 +70,7 @@
<option value="function-r" class="">Ring</option> <option value="function-r" class="">Ring</option>
</select> </select>
</div> </div>
<div class="modifiers"> <div class="modifiers">
<span class="color_section">Color modifier</span> <span class="color_section">Color modifier</span>
@ -94,25 +94,17 @@
<span class="labelSelect">Throttle</span> <span class="labelSelect">Throttle</span>
</label> </label>
</div> </div>
<div class="checkbox extra_functions20"> <div class="checkbox extra_functions20">
<input type="checkbox" name="LarsonScanner" class="toggle function-o" /> <input type="checkbox" name="LarsonScanner" class="toggle function-o" />
<label> <span>Larson scanner</span></label> <label> <span>Larson scanner</span></label>
</div> </div>
</div>
<div class="blinkers extra_functions20">
<span class="color_section">Blink</span>
<div class="checkbox blinkOverlay"> <div class="checkbox blinkOverlay">
<input type="checkbox" name="blink" class="toggle function-b" /> <input type="checkbox" name="blink" class="toggle function-b" />
<label> <span>Blink always</span></label> <label> <span>Blink always</span></label>
</div> </div>
<div class="checkbox landingBlinkOverlay">
<input type="checkbox" name="landingBlink" class="toggle function-n" />
<label> <span>Blink on landing</span></label>
</div>
</div> </div>
<div class="overlays"> <div class="overlays">
<span class="color_section">Overlay</span> <span class="color_section">Overlay</span>
<div class="checkbox warningOverlay"> <div class="checkbox warningOverlay">
@ -123,11 +115,15 @@
<input type="checkbox" name="Indicator" class="toggle function-i" /> <input type="checkbox" name="Indicator" class="toggle function-i" />
<label> <span>Indicator (uses position on matrix)</span></label> <label> <span>Indicator (uses position on matrix)</span></label>
</div> </div>
<div class="checkbox vtxOverlay">
<input type="checkbox" name="Vtx" class="toggle function-v" />
<label> <span>VTX (uses vtx frequency to assign color)</span></label>
</div>
</div> </div>
<div class="mode_colors"> <div class="mode_colors">
<div class="section">Mode colors</div> <div class="section">Mode colors</div>
<select class="modeSelect"> <select class="modeSelect">
<option value="0">Orientation</option> <option value="0">Orientation</option>
<option value="1">Headfree</option> <option value="1">Headfree</option>
@ -144,7 +140,7 @@
<button class="mode_color-0-4 dir-u">U</button> <button class="mode_color-0-4 dir-u">U</button>
<button class="mode_color-0-5 dir-d">D</button> <button class="mode_color-0-5 dir-d">D</button>
</div> </div>
<div class="section">LED Orientation ('Modes &amp; Orientation') and Color</div> <div class="section">LED Orientation ('Modes &amp; Orientation') and Color</div>
<div class="directions"> <div class="directions">
<button class="dir-n">N</button> <button class="dir-n">N</button>
@ -154,7 +150,7 @@
<button class="dir-u">U</button> <button class="dir-u">U</button>
<button class="dir-d">D</button> <button class="dir-d">D</button>
</div> </div>
<div class="colors"> <div class="colors">
<button class="color-0" title="black">0</button> <button class="color-0" title="black">0</button>
<button class="color-1" title="white">1</button> <button class="color-1" title="white">1</button>
@ -185,7 +181,7 @@
<button class="mode_color-6-6" title="orange">GPS: no lock</button> <button class="mode_color-6-6" title="orange">GPS: no lock</button>
<button class="mode_color-6-7" title="green">GPS: locked</button> <button class="mode_color-6-7" title="green">GPS: locked</button>
</div> </div>
<div class="section">LED Strip Wiring</div> <div class="section">LED Strip Wiring</div>
<div class="wiringMode"> <div class="wiringMode">
<button class="funcWire w100">Wire Ordering Mode</button> <button class="funcWire w100">Wire Ordering Mode</button>
@ -196,11 +192,11 @@
</div> </div>
<p>LEDs without wire ordering number will not be saved.</p> <p>LEDs without wire ordering number will not be saved.</p>
</div> </div>
<div class="colorControls"> <div class="colorControls">
</div> </div>
<div class="clear-both"></div> <div class="clear-both"></div>
</div> </div>
<div class="content_toolbar"> <div class="content_toolbar">

View File

@ -18,7 +18,7 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
} else { } else {
TABS.led_strip.functions = ['i', 'w', 'f', 'a', 't', 'r', 'c', 'g', 's', 'b', 'l', 'o', 'n']; TABS.led_strip.functions = ['i', 'w', 'f', 'a', 't', 'r', 'c', 'g', 's', 'b', 'l', 'o', 'n'];
TABS.led_strip.baseFuncs = ['c', 'f', 'a', 'l', 's', 'g', 'r']; TABS.led_strip.baseFuncs = ['c', 'f', 'a', 'l', 's', 'g', 'r'];
TABS.led_strip.overlays = ['t', 'o', 'b', 'n', 'i', 'w']; TABS.led_strip.overlays = ['t', 'o', 'b', 'v', 'i', 'w'];
} }
TABS.led_strip.wireMode = false; TABS.led_strip.wireMode = false;