CF/BF - improve readability by reformating the structures.

10.3.x-maintenance
Hydra 2017-04-09 20:35:30 +01:00 committed by Michael Keller
parent 2618d6dafc
commit bf0fcb5643
1 changed files with 187 additions and 188 deletions

375
js/fc.js
View File

@ -57,50 +57,50 @@ var SENSOR_CONFIG;
var FC = { var FC = {
resetState: function() { resetState: function() {
CONFIG = { CONFIG = {
apiVersion: "0.0.0", apiVersion: "0.0.0",
flightControllerIdentifier: '', flightControllerIdentifier: '',
flightControllerVersion: '', flightControllerVersion: '',
version: 0, version: 0,
buildInfo: '', buildInfo: '',
multiType: 0, multiType: 0,
msp_version: 0, // not specified using semantic versioning msp_version: 0, // not specified using semantic versioning
capability: 0, capability: 0,
cycleTime: 0, cycleTime: 0,
i2cError: 0, i2cError: 0,
activeSensors: 0, activeSensors: 0,
mode: 0, mode: 0,
profile: 0, profile: 0,
uid: [0, 0, 0], uid: [0, 0, 0],
accelerometerTrims: [0, 0], accelerometerTrims: [0, 0],
name: '', name: '',
numProfiles: 3, numProfiles: 3,
rateProfile: 0, rateProfile: 0,
boardType: 0, boardType: 0,
}; };
FEATURE_CONFIG = { FEATURE_CONFIG = {
features: 0, features: 0,
}; };
MIXER_CONFIG = { MIXER_CONFIG = {
mixer: 0, mixer: 0,
}; };
BOARD_ALIGNMENT_CONFIG = { BOARD_ALIGNMENT_CONFIG = {
roll: 0, roll: 0,
pitch: 0, pitch: 0,
yaw: 0, yaw: 0,
}; };
LED_STRIP = []; LED_STRIP = [];
LED_COLORS = []; LED_COLORS = [];
LED_MODE_COLORS = []; LED_MODE_COLORS = [];
PID = { PID = {
controller: 0 controller: 0
}; };
PID_names = []; PID_names = [];
PIDs = new Array(10); PIDs = new Array(10);
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
PIDs[i] = new Array(3); PIDs[i] = new Array(3);
@ -111,249 +111,248 @@ var FC = {
// defaults // defaults
// roll, pitch, yaw, throttle, aux 1, ... aux n // roll, pitch, yaw, throttle, aux 1, ... aux n
RC = { RC = {
active_channels: 0, active_channels: 0,
channels: new Array(32) channels: new Array(32),
}; };
RC_tuning = { RC_tuning = {
RC_RATE: 0, RC_RATE: 0,
RC_EXPO: 0, RC_EXPO: 0,
roll_pitch_rate: 0, // pre 1.7 api only roll_pitch_rate: 0, // pre 1.7 api only
roll_rate: 0, roll_rate: 0,
pitch_rate: 0, pitch_rate: 0,
yaw_rate: 0, yaw_rate: 0,
dynamic_THR_PID: 0, dynamic_THR_PID: 0,
throttle_MID: 0, throttle_MID: 0,
throttle_EXPO: 0, throttle_EXPO: 0,
dynamic_THR_breakpoint: 0, dynamic_THR_breakpoint: 0,
RC_YAW_EXPO: 0, RC_YAW_EXPO: 0,
rcYawRate: 0 rcYawRate: 0,
}; };
AUX_CONFIG = []; AUX_CONFIG = [];
AUX_CONFIG_IDS = []; AUX_CONFIG_IDS = [];
MODE_RANGES = []; MODE_RANGES = [];
ADJUSTMENT_RANGES = []; ADJUSTMENT_RANGES = [];
SERVO_CONFIG = []; SERVO_CONFIG = [];
SERVO_RULES = []; SERVO_RULES = [];
SERIAL_CONFIG = { SERIAL_CONFIG = {
ports: [], ports: [],
// pre 1.6 settings // pre 1.6 settings
mspBaudRate: 0, mspBaudRate: 0,
gpsBaudRate: 0, gpsBaudRate: 0,
gpsPassthroughBaudRate: 0, gpsPassthroughBaudRate: 0,
cliBaudRate: 0, cliBaudRate: 0,
}; };
SENSOR_DATA = { SENSOR_DATA = {
gyroscope: [0, 0, 0], gyroscope: [0, 0, 0],
accelerometer: [0, 0, 0], accelerometer: [0, 0, 0],
magnetometer: [0, 0, 0], magnetometer: [0, 0, 0],
altitude: 0, altitude: 0,
sonar: 0, sonar: 0,
kinematics: [0.0, 0.0, 0.0], kinematics: [0.0, 0.0, 0.0],
debug: [0, 0, 0, 0] debug: [0, 0, 0, 0],
}; };
MOTOR_DATA = new Array(8); MOTOR_DATA = new Array(8);
SERVO_DATA = new Array(8); SERVO_DATA = new Array(8);
GPS_DATA = { GPS_DATA = {
fix: 0, fix: 0,
numSat: 0, numSat: 0,
lat: 0, lat: 0,
lon: 0, lon: 0,
alt: 0, alt: 0,
speed: 0, speed: 0,
ground_course: 0, ground_course: 0,
distanceToHome: 0, distanceToHome: 0,
ditectionToHome: 0, ditectionToHome: 0,
update: 0, update: 0,
// baseflight specific gps stuff chn: [],
chn: [], svid: [],
svid: [], quality: [],
quality: [], cno: []
cno: []
}; };
ANALOG = { ANALOG = {
voltage: 0, voltage: 0,
mAhdrawn: 0, mAhdrawn: 0,
rssi: 0, rssi: 0,
amperage: 0, amperage: 0,
last_received_timestamp: Date.now() // FIXME this code lies, it's never been received at this point last_received_timestamp: Date.now() // FIXME this code lies, it's never been received at this point
}; };
VOLTAGE_METERS = []; VOLTAGE_METERS = [];
VOLTAGE_METER_CONFIGS = []; VOLTAGE_METER_CONFIGS = [];
CURRENT_METERS = []; CURRENT_METERS = [];
CURRENT_METER_CONFIGS = []; CURRENT_METER_CONFIGS = [];
BATTERY_STATE = {}; BATTERY_STATE = {};
BATTERY_CONFIG = { BATTERY_CONFIG = {
vbatmincellvoltage: 0, vbatmincellvoltage: 0,
vbatmaxcellvoltage: 0, vbatmaxcellvoltage: 0,
vbatwarningcellvoltage: 0, vbatwarningcellvoltage: 0,
capacity: 0, capacity: 0,
voltageMeterSource: 0, voltageMeterSource: 0,
currentMeterSource: 0 currentMeterSource: 0,
}; };
ARMING_CONFIG = { ARMING_CONFIG = {
auto_disarm_delay: 0, auto_disarm_delay: 0,
disarm_kill_switch: 0 disarm_kill_switch: 0,
}; };
FC_CONFIG = { FC_CONFIG = {
loopTime: 0 loopTime: 0
}; };
MISC = { MISC = {
// DEPRECATED = only used to store values that are written back to the fc as-is, do NOT use for any other purpose // DEPRECATED = only used to store values that are written back to the fc as-is, do NOT use for any other purpose
failsafe_throttle: 0, failsafe_throttle: 0,
gps_baudrate: 0, gps_baudrate: 0,
multiwiicurrentoutput: 0, multiwiicurrentoutput: 0,
placeholder2: 0, placeholder2: 0,
vbatscale: 0, vbatscale: 0,
vbatmincellvoltage: 0, vbatmincellvoltage: 0,
vbatmaxcellvoltage: 0, vbatmaxcellvoltage: 0,
vbatwarningcellvoltage: 0, vbatwarningcellvoltage: 0,
}; };
MOTOR_CONFIG = { MOTOR_CONFIG = {
minthrottle: 0, minthrottle: 0,
maxthrottle: 0, maxthrottle: 0,
mincommand: 0, mincommand: 0,
}; };
GPS_CONFIG = { GPS_CONFIG = {
provider: 0, provider: 0,
ublox_sbas: 0, ublox_sbas: 0,
auto_config: 0, auto_config: 0,
auto_baud: 0, auto_baud: 0,
}; };
COMPASS_CONFIG = { COMPASS_CONFIG = {
mag_declination: 0, // not checked mag_declination: 0,
}; };
RSSI_CONFIG = { RSSI_CONFIG = {
channel: 0, channel: 0,
}; };
MOTOR_3D_CONFIG = { MOTOR_3D_CONFIG = {
deadband3d_low: 0, deadband3d_low: 0,
deadband3d_high: 0, deadband3d_high: 0,
neutral: 0, neutral: 0,
}; };
DATAFLASH = { DATAFLASH = {
ready: false, ready: false,
supported: false, supported: false,
sectors: 0, sectors: 0,
totalSize: 0, totalSize: 0,
usedSize: 0 usedSize: 0
}; };
SDCARD = { SDCARD = {
supported: false, supported: false,
state: 0, state: 0,
filesystemLastError: 0, filesystemLastError: 0,
freeSizeKB: 0, freeSizeKB: 0,
totalSizeKB: 0, totalSizeKB: 0,
}; };
BLACKBOX = { BLACKBOX = {
supported: false, supported: false,
blackboxDevice: 0, blackboxDevice: 0,
blackboxRateNum: 1, blackboxRateNum: 1,
blackboxRateDenom: 1 blackboxRateDenom: 1,
}; };
TRANSPONDER = { TRANSPONDER = {
supported: false, supported: false,
data: [], data: [],
provider: 0, provider: 0,
providers: [] providers: [],
}; };
RC_DEADBAND_CONFIG = { RC_DEADBAND_CONFIG = {
deadband: 0, deadband: 0,
yaw_deadband: 0, yaw_deadband: 0,
alt_hold_deadband: 0, alt_hold_deadband: 0,
deadband3d_throttle: 0 deadband3d_throttle: 0,
}; };
SENSOR_ALIGNMENT = { SENSOR_ALIGNMENT = {
align_gyro: 0, align_gyro: 0,
align_acc: 0, align_acc: 0,
align_mag: 0 align_mag: 0,
}; };
PID_ADVANCED_CONFIG = { PID_ADVANCED_CONFIG = {
gyro_sync_denom: 0, gyro_sync_denom: 0,
pid_process_denom: 0, pid_process_denom: 0,
use_unsyncedPwm: 0, use_unsyncedPwm: 0,
fast_pwm_protocol: 0, fast_pwm_protocol: 0,
motor_pwm_rate: 0, motor_pwm_rate: 0,
digitalIdlePercent: 0, digitalIdlePercent: 0,
gyroUse32kHz: 0 gyroUse32kHz: 0,
}; };
FILTER_CONFIG = { FILTER_CONFIG = {
gyro_soft_lpf_hz: 0, gyro_soft_lpf_hz: 0,
dterm_lpf_hz: 0, dterm_lpf_hz: 0,
yaw_lpf_hz: 0, yaw_lpf_hz: 0,
gyro_soft_notch_hz_1: 0, gyro_soft_notch_hz_1: 0,
gyro_soft_notch_cutoff_1: 0, gyro_soft_notch_cutoff_1: 0,
dterm_notch_hz: 0, dterm_notch_hz: 0,
dterm_notch_cutoff: 0, dterm_notch_cutoff: 0,
gyro_soft_notch_hz_2: 0, gyro_soft_notch_hz_2: 0,
gyro_soft_notch_cutoff_2: 0 gyro_soft_notch_cutoff_2: 0,
}; };
ADVANCED_TUNING = { ADVANCED_TUNING = {
rollPitchItermIgnoreRate: 0, rollPitchItermIgnoreRate: 0,
yawItermIgnoreRate: 0, yawItermIgnoreRate: 0,
yaw_p_limit: 0, yaw_p_limit: 0,
deltaMethod: 0, deltaMethod: 0,
vbatPidCompensation: 0, vbatPidCompensation: 0,
ptermSetpointWeight: 0, ptermSetpointWeight: 0,
dtermSetpointWeight: 0, dtermSetpointWeight: 0,
toleranceBand: 0, toleranceBand: 0,
toleranceBandReduction: 0, toleranceBandReduction: 0,
itermThrottleGain: 0, itermThrottleGain: 0,
pidMaxVelocity: 0, pidMaxVelocity: 0,
pidMaxVelocityYaw: 0, pidMaxVelocityYaw: 0,
levelAngleLimit: 0, levelAngleLimit: 0,
levelSensitivity: 0 levelSensitivity: 0,
}; };
SENSOR_CONFIG = { SENSOR_CONFIG = {
acc_hardware: 0, acc_hardware: 0,
baro_hardware: 0, baro_hardware: 0,
mag_hardware: 0 mag_hardware: 0,
}; };
RX_CONFIG = { RX_CONFIG = {
serialrx_provider: 0, serialrx_provider: 0,
stick_max: 0, stick_max: 0,
stick_center: 0, stick_center: 0,
stick_min: 0, stick_min: 0,
spektrum_sat_bind: 0, spektrum_sat_bind: 0,
rx_min_usec: 0, rx_min_usec: 0,
rx_max_usec: 0, rx_max_usec: 0,
rcInterpolation: 0, rcInterpolation: 0,
rcInterpolationInterval:0, rcInterpolationInterval: 0,
airModeActivateThreshold: 0, airModeActivateThreshold: 0,
rxSpiProtocol: 0, rxSpiProtocol: 0,
rxSpiId: 0, rxSpiId: 0,
rxSpiRfChannelCount: 0, rxSpiRfChannelCount: 0,
fpvCamAngleDegrees: 0 fpvCamAngleDegrees: 0,
}; };
FAILSAFE_CONFIG = { FAILSAFE_CONFIG = {
@ -362,7 +361,7 @@ var FC = {
failsafe_throttle: 0, failsafe_throttle: 0,
failsafe_kill_switch: 0, failsafe_kill_switch: 0,
failsafe_throttle_low_delay: 0, failsafe_throttle_low_delay: 0,
failsafe_procedure: 0 failsafe_procedure: 0.
}; };
RXFAIL_CONFIG = []; RXFAIL_CONFIG = [];