This commit is contained in:
David Walsh
2019-03-27 19:01:55 -04:00
parent 56b04ef0bc
commit 713e696ef6
2 changed files with 0 additions and 101 deletions

View File

@@ -1,62 +1,5 @@
$("#myImage").click ( function (evt) {
var jThis = $(this);
var offsetFromParent = jThis.position ();
var topThickness = (jThis.outerHeight(true) - jThis.height() ) / 2;
var leftThickness = (jThis.outerWidth (true) - jThis.width () ) / 2;
//--- (x,y) coordinates of the mouse click relative to the image.
var x = evt.pageX - offsetFromParent.left - leftThickness;
var y = evt.pageY - offsetFromParent.top - topThickness;
ReportDims ();
$('#rez').append ('<p>User clicked at: ' + x + ', ' + y + ' (x,y).</p>')
} );
function ReportDims () {
w = $("#myImage").width ();
h = $("#myImage").height ();
$('#rez').text ('The image is ' + w + ' by ' + h + ' (w by h).');
}
ReportDims ();
function updateVoltage(voltage)
{
var voltage_min = 9.5;
var voltage_max = 12.5;
var voltage_range = voltage_max - voltage_min;
var voltage_percentage = (voltage - voltage_min) / voltage_range * 100;
var voltage_string = "";
voltage_string = voltage_string.concat(voltage_percentage);
voltage_string = voltage_string.substring(0,4);
voltage_string = voltage_string.concat('%');
document.getElementById("VoltageDisplay").style.width = voltage_string;
document.getElementById("VoltageDisplay").innerHTML = voltage_string;
if (voltage_percentage < 50 && voltage_percentage > 25 ) {
document.getElementById("VoltageDisplay").className = "progress-bar progress-bar-warning"
}
else if ( voltage_percentage <= 25)
{
document.getElementById("VoltageDisplay").className = "progress-bar progress-bar-danger"
var sound = document.getElementById("audio");
sound.play()
console.log("Pay Sound")
}
else
{
document.getElementById("VoltageDisplay").className = "progress-bar progress-bar-success"
}
};
function updateTopicsGUI()
{

View File

@@ -1,44 +0,0 @@
function sendRosMessageExample()
{
publishStringExample(String(document.getElementById("sendRosMessageExample").value))
}
function update_sendRosMessageExample(msg)
{
document.getElementById("recievedMessageDiv").innerHTML = msg
}
function update_ProgressBar(value)
{
// This would be a great way of getting a float or int from a rosTopic and displaying it.
// I would suggest storing the data as a data field in the ros_scripts then updating it every 500 or 1000 ms rather than updating the gui every time you recieve a message
var num_string = "";
num_string = num_string.concat(value);
num_string = num_string.substring(0,4);
num_string = num_string.concat("%");
doc = document.getElementById("progressBar1");
doc.style.width = num_string;
doc.innerHTML = num_string;
if (value < 50 && value > 25 ) {
doc.className = "progress-bar progress-bar-warning";
}
else if ( value <= 25)
{
doc.className = "progress-bar progress-bar-danger";
}
else
{
doc.className = "progress-bar progress-bar-success";
}
}
window.setInterval(function(){
update_ProgressBar(Math.random() * 100);
}, 1000);