diff --git a/css/style.css b/css/style.css index ac5e7e20..74aef0ae 100644 --- a/css/style.css +++ b/css/style.css @@ -203,18 +203,18 @@ a:hover { border: 1px dotted silver; } -table.pid_tuning { +.tab-pid_tuning table { width: 100%; border-collapse:collapse; } - table.pid_tuning, table.pid_tuning th, table.pid_tuning td { + .tab-pid_tuning table, .tab-pid_tuning table th, .tab-pid_tuning table td { padding: 5px; border: 1px solid #8b8b8b; } - table.pid_tuning tr:nth-child(odd) { + .tab-pid_tuning table tr:nth-child(odd) { background-color: #ececec; } - table.pid_tuning input { + .tab-pid_tuning table input { width: 130px; height: 18px; line-height: 18px; @@ -223,27 +223,12 @@ table.pid_tuning { border: 1px solid silver; text-align: right; } - table.pid_tuning a.update { - display: block; - - width: 60px; - height: 18px; - line-height: 18px; - - color: white; - text-align: center; - - border: 1px solid silver; - background-color: #078814; - } - table.pid_tuning a.update:hover { - text-decoration: none; - background-color: #13b723; - } .tab-pid_tuning .update { display: block; float: right; + margin-top: 20px; + width: 120px; height: 60px; line-height: 60px; @@ -266,6 +251,11 @@ table.pid_tuning { cursor: pointer; background-color: #13d81d; } + .tab-pid_tuning .rate-tpa { + float: left; + width: 400px; + margin-top: 20px; + } .tab-receiver { } .tab-receiver .bars ul { diff --git a/js/main.js b/js/main.js index 50cd43de..83f7114f 100644 --- a/js/main.js +++ b/js/main.js @@ -26,6 +26,9 @@ $(document).ready(function() { } } }); + + // temporary + //$('#content').load("./tabs/pid_tuning.html", tab_initialize_pid_tuning); }); function disable_timers() { diff --git a/js/serial_backend.js b/js/serial_backend.js index 45134a5a..99989181 100644 --- a/js/serial_backend.js +++ b/js/serial_backend.js @@ -65,6 +65,16 @@ var RC = { AUX4: 0 }; +var RC_tuning = { + RC_RATE: 0, + RC_EXPO: 0, + roll_pitch_rate: 0, + yaw_rate: 0, + dynamic_THR_PID: 0, + throttle_MID: 0, + throttle_EXPO: 0, +}; + var SENSOR_DATA = { gyroscope: [0, 0, 0], accelerometer: [0, 0, 0], @@ -154,6 +164,7 @@ function onOpen(openInfo) { send_message(MSP_codes.MSP_IDENT, MSP_codes.MSP_IDENT); send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS); send_message(MSP_codes.MSP_PID, MSP_codes.MSP_PID); + send_message(MSP_codes.MSP_RC_TUNING, MSP_codes.MSP_RC_TUNING); }, connection_delay * 1000); } @@ -260,9 +271,9 @@ function onCharRead(readInfo) { } } -function send_message(code, data, bytes_n) { +function send_message(code, data) { if (typeof data === 'object') { - var size = 6 + bytes_n; + var size = 6 + data.length; // 6 bytes for protocol overhead var checksum = 0; var bufferOut = new ArrayBuffer(size); @@ -275,10 +286,11 @@ function send_message(code, data, bytes_n) { bufView[4] = code; // code checksum = bufView[3] ^ bufView[4]; - for (var i = 5; i < data.length; i++) { - bufView[i] = data[i - 5]; + + for (var i = 0; i < data.length; i++) { + bufView[i + 5] = data[i]; - checksum ^= bufView[i]; + checksum ^= bufView[i + 5]; } bufView[5 + data.length] = checksum; @@ -289,7 +301,7 @@ function send_message(code, data, bytes_n) { bufView[0] = 36; // $ bufView[1] = 77; // M bufView[2] = 60; // < - bufView[3] = bytes_n; // data length + bufView[3] = 0; // data length bufView[4] = code; // code bufView[5] = data; // data bufView[6] = bufView[3] ^ bufView[4] ^ bufView[5]; // checksum @@ -366,7 +378,13 @@ function process_message(code, data) { console.log(data); break; case MSP_codes.MSP_RC_TUNING: - console.log(data); + RC_tuning.RC_RATE = parseFloat((view.getUint8(0) / 100).toFixed(2)); + RC_tuning.RC_EXPO = parseFloat((view.getUint8(1) / 100).toFixed(2)); + RC_tuning.roll_pitch_rate = parseFloat((view.getUint8(2) / 100).toFixed(2)); + RC_tuning.yaw_rate = parseFloat((view.getUint8(3) / 100).toFixed(2)); + RC_tuning.dynamic_THR_PID = parseFloat((view.getUint8(4) / 100).toFixed(2)); + RC_tuning.throttle_MID = parseFloat((view.getUint8(5) / 100).toFixed(2)); + RC_tuning.throttle_EXPO = parseFloat((view.getUint8(6) / 100).toFixed(2)); break; case MSP_codes.MSP_PID: // PID data arrived, we need to scale it and save to appropriate bank / array @@ -428,7 +446,7 @@ function process_message(code, data) { console.log(data); break; case MSP_codes.MSP_SET_RC_TUNING: - console.log(data); + console.log('RC Tuning saved'); break; case MSP_codes.MSP_ACC_CALIBRATION: console.log('Accel calibration executed'); diff --git a/tabs/pid_tuning.html b/tabs/pid_tuning.html index 44b7265b..2b928d14 100644 --- a/tabs/pid_tuning.html +++ b/tabs/pid_tuning.html @@ -12,7 +12,6 @@
ROLL rate & PITCH rate | +YAW rate | +TPA | +
---|---|---|
+ | + | + |