diff --git a/css/style.css b/css/style.css index c0a9626392..1eb124c51a 100644 --- a/css/style.css +++ b/css/style.css @@ -451,7 +451,49 @@ a:hover { .tab-auxiliary_configuration .update.active:hover { cursor: pointer; background-color: #13d81d; - } + } +.tab-motor_outputs { +} + .tab-motor_outputs .right.servos { + margin-right: -10px; + } + .tab-motor_outputs .titles { + height: 20px; + } + .tab-motor_outputs .titles li { + float: left; + width: 42px; + margin-right: 10px; + + text-align: center; + } + .tab-motor_outputs .titles .active { + color: green; + } + .tab-motor_outputs .m-block { + float: left; + + width: 40px; + height: 330px; + + margin-right: 10px; + + border: 1px solid silver; + background-color: #e9e9e9; + } + .tab-motor_outputs .indicator { + position: absolute; + margin-top: 330px; + + width: 40px; + height: 0px; + } + .tab-motor_outputs p { + margin-top: 20px; + padding: 5px; + + border: 1px dotted silver; + } /* Flotr related styles */ .flotr-legend { diff --git a/js/main.js b/js/main.js index e32757c83b..52cbd8337f 100644 --- a/js/main.js +++ b/js/main.js @@ -25,12 +25,14 @@ $(document).ready(function() { $('#content').load("./tabs/receiver.html", tab_initialize_receiver); } else if ($(this).parent().hasClass('tab_auxiliary_configuration')) { $('#content').load("./tabs/auxiliary_configuration.html", tab_initialize_auxiliary_configuration); + } else if ($(this).parent().hasClass('tab_motor_outputs')) { + $('#content').load("./tabs/motor_outputs.html", tab_initialize_motor_outputs); } } }); // temporary - //$('#content').load("./tabs/auxiliary_configuration.html", tab_initialize_auxiliary_configuration); + //$('#content').load("./tabs/motor_outputs.html", tab_initialize_motor_outputs); }); function disable_timers() { diff --git a/js/serial_backend.js b/js/serial_backend.js index 0a1718a0f7..bef52fbda0 100644 --- a/js/serial_backend.js +++ b/js/serial_backend.js @@ -85,6 +85,9 @@ var SENSOR_DATA = { altitude: 0 }; +var MOTOR_DATA = new Array(8); +var SERVO_DATA = new Array(8); + $(document).ready(function() { port_picker = $('div#port-picker .port select'); baud_picker = $('div#port-picker #baud'); @@ -134,6 +137,11 @@ $(document).ready(function() { clearTimeout(connection_delay); clearInterval(serial_poll); + clearInterval(port_usage_poll); + + // Change port utilization to 0 + $('span.port-usage').html('0%'); + $(this).text('Connect'); $(this).removeClass('active'); @@ -162,6 +170,7 @@ function onOpen(openInfo) { connection_delay = setTimeout(function() { // start polling serial_poll = setInterval(readPoll, 10); + port_usage_poll = setInterval(port_usage, 1000); // request configuration data send_message(MSP_codes.MSP_IDENT, MSP_codes.MSP_IDENT); @@ -203,6 +212,7 @@ var message_length_received = 0; var message_buffer; var message_buffer_uint8_view; var message_checksum = 0; +var char_counter = 0; function onCharRead(readInfo) { if (readInfo && readInfo.bytesRead > 0 && readInfo.data) { @@ -272,6 +282,8 @@ function onCharRead(readInfo) { message_state = 0; break; } + + char_counter++; } } } @@ -326,6 +338,46 @@ function process_message(code, data) { CONFIG.version = parseFloat((view.getUint8(0) / 100).toFixed(2)); CONFIG.multiType = view.getUint8(1); + $('.software-version').html(CONFIG.version); + + // TODO: utilize this info + switch (CONFIG.multiType) { + case 1: // TRI + break; + case 2: // QUAD+ + break; + case 3: // QUAD X + break; + case 4: // BI + break; + case 5: // GIMBAL + break; + case 6: // Y6 + break; + case 7: // HEX 6 + break; + case 8: // FLYING_WING + break; + case 9: // Y4 + break; + case 10: // HEX6 X + break; + case 11: // OCTO X8 + case 12: + case 13: + break; + case 14: // AIRPLANE + break; + case 15: // Heli 120 + break; + case 16: // Heli 90 + break; + case 17: // Vtail + break; + case 18: // HEX6 H + break; + } + // IDENT received, show the tab content $('#tabs li a:first').click(); break; @@ -351,10 +403,20 @@ function process_message(code, data) { SENSOR_DATA.magnetometer[2] = view.getInt16(16, 1) / 3; break; case MSP_codes.MSP_SERVO: - console.log(data); + var needle = 0; + for (var i = 0; i < SERVO_DATA.length; i++) { + SERVO_DATA[i] = view.getUint16(needle, 1); + + needle += 2; + } break; case MSP_codes.MSP_MOTOR: - console.log(data); + var needle = 0; + for (var i = 0; i < MOTOR_DATA.length; i++) { + MOTOR_DATA[i] = view.getUint16(needle, 1); + + needle += 2; + } break; case MSP_codes.MSP_RC: RC.roll = view.getUint16(0, 1); @@ -498,6 +560,14 @@ function process_message(code, data) { } } +function port_usage() { + var port_usage = (char_counter * 10 / selected_baud) * 100; + $('span.port-usage').html(parseInt(port_usage) + '%'); + + // reset counter + char_counter = 0; +} + function sensor_status(sensors_detected) { var e_sensor_status = $('div#sensor-status'); diff --git a/main.html b/main.html index c68d9beccb..1b5d794119 100644 --- a/main.html +++ b/main.html @@ -14,7 +14,8 @@ - + +
+ Some info goes here +
+