mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 06:15:16 +03:00
dangerous things that people want...
This commit is contained in:
parent
8d18b6f10e
commit
86aa6a282c
2 changed files with 34 additions and 34 deletions
30
js/gui.js
30
js/gui.js
|
@ -230,35 +230,7 @@ GUI_control.prototype.tab_switch_cleanup = function(callback) {
|
|||
GUI.interval_remove('motor_pull');
|
||||
GUI.interval_remove('status_pull');
|
||||
|
||||
// only enforce mincommand if necessary
|
||||
if (MOTOR_DATA != undefined) {
|
||||
var update = false;
|
||||
|
||||
for (var i = 0; i < MOTOR_DATA.length; i++) {
|
||||
if (MOTOR_DATA[i] > MISC.mincommand) {
|
||||
update = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (update) {
|
||||
// send data to mcu
|
||||
var buffer_out = [];
|
||||
|
||||
for (var i = 0; i < 8; i++) {
|
||||
buffer_out.push(lowByte(MISC.mincommand));
|
||||
buffer_out.push(highByte(MISC.mincommand));
|
||||
}
|
||||
|
||||
MSP.send_message(MSP_codes.MSP_SET_MOTOR, buffer_out, false, function() {
|
||||
if (callback) callback();
|
||||
});
|
||||
} else {
|
||||
if (callback) callback();
|
||||
}
|
||||
} else {
|
||||
if (callback) callback();
|
||||
}
|
||||
if (callback) callback();
|
||||
break;
|
||||
case 'sensors':
|
||||
GUI.interval_kill_all();
|
||||
|
|
|
@ -70,14 +70,40 @@ function tab_initialize_motor_outputs() {
|
|||
$('div.sliders input').prop('disabled', true);
|
||||
|
||||
// change all values to default
|
||||
$('div.sliders input').val(1000);
|
||||
$('div.values li:not(:last)').html(1000);
|
||||
$('div.sliders input').val(MISC.mincommand);
|
||||
|
||||
// trigger change event so values are sent to mcu
|
||||
$('div.sliders input').trigger('input');
|
||||
}
|
||||
});
|
||||
|
||||
// check if motors are already spinning
|
||||
var motors_running = false;
|
||||
|
||||
for (var i = 0; i < MOTOR_DATA.length; i++) {
|
||||
if (MOTOR_DATA[i] > MISC.mincommand) {
|
||||
motors_running = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (motors_running) {
|
||||
// motors are running, enable test mode and adjust sliders to current values
|
||||
$('div.notice input[type="checkbox"]').click();
|
||||
|
||||
var sliders = $('div.sliders input:not(.master)');
|
||||
|
||||
for (var i = 0; i < MOTOR_DATA.length; i++) {
|
||||
if (MOTOR_DATA[i] > 0) {
|
||||
sliders.eq(i).val(MOTOR_DATA[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// only fire events when all values are set
|
||||
sliders.trigger('input');
|
||||
}
|
||||
|
||||
|
||||
// data pulling functions used inside interval timer
|
||||
function get_motor_data() {
|
||||
MSP.send_message(MSP_codes.MSP_MOTOR, false, false, get_servo_data);
|
||||
|
@ -87,18 +113,20 @@ function tab_initialize_motor_outputs() {
|
|||
MSP.send_message(MSP_codes.MSP_SERVO, false, false, update_ui);
|
||||
}
|
||||
|
||||
var full_block_scale = MISC.maxthrottle - MISC.mincommand;
|
||||
function update_ui() {
|
||||
var block_height = $('div.m-block:first').height();
|
||||
|
||||
for (var i = 0; i < MOTOR_DATA.length; i++) {
|
||||
var data = MOTOR_DATA[i] - 1000;
|
||||
var margin_top = block_height - (data * (block_height / 1000));
|
||||
var height = (data * (block_height / 1000));
|
||||
var data = MOTOR_DATA[i] - MISC.mincommand;
|
||||
var margin_top = block_height - (data * (block_height / full_block_scale));
|
||||
var height = (data * (block_height / full_block_scale));
|
||||
var color = parseInt(data * 0.256);
|
||||
|
||||
$('.motor-' + i + ' .indicator').css({'margin-top' : margin_top + 'px', 'height' : height + 'px', 'background-color' : 'rgb(' + color + ',0,0)'});
|
||||
}
|
||||
|
||||
// servo indicators are still using old (not flexible block scale), it will be changed in the future accordingly
|
||||
for (var i = 0; i < SERVO_DATA.length; i++) {
|
||||
var data = SERVO_DATA[i] - 1000;
|
||||
var margin_top = block_height - (data * (block_height / 1000));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue