Update UI for Colour

Update for negative translation
Change default UI values
This commit is contained in:
Mee2001 2021-06-15 11:25:10 +01:00
parent ec55c24a7c
commit ca662990b7
3 changed files with 68 additions and 32 deletions

View file

@ -75,9 +75,9 @@ var command = (function(){
var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o}; var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o};
var parser = {trace: function trace () { }, var parser = {trace: function trace () { },
yy: {}, yy: {},
symbols_: {"error":2,"command":3,"expr":4,"EOF":5,"move":6,"whitespace":7,"distance":8,"heading_angle":9,"percentage":10,"stop":11,"pstop":12,"stop_duration":13,"charge_to":14,"telemetry_reset":15,"help":16,"$accept":0,"$end":1}, symbols_: {"error":2,"command":3,"expr":4,"EOF":5,"move":6,"whitespace":7,"distance":8,"heading_angle":9,"percentage":10,"stop":11,"pstop":12,"stop_duration":13,"charge_to":14,"colour":15,"colour_name":16,"telemetry_reset":17,"help":18,"$accept":0,"$end":1},
terminals_: {2:"error",5:"EOF",6:"move",7:"whitespace",8:"distance",9:"heading_angle",10:"percentage",11:"stop",12:"pstop",13:"stop_duration",14:"charge_to",15:"telemetry_reset",16:"help"}, terminals_: {2:"error",5:"EOF",6:"move",7:"whitespace",8:"distance",9:"heading_angle",10:"percentage",11:"stop",12:"pstop",13:"stop_duration",14:"charge_to",15:"colour",16:"colour_name",17:"telemetry_reset",18:"help"},
productions_: [0,[3,2],[4,7],[4,1],[4,3],[4,3],[4,1],[4,1]], productions_: [0,[3,2],[4,7],[4,1],[4,3],[4,3],[4,3],[4,1],[4,1]],
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {
/* this == yyval */ /* this == yyval */
@ -110,18 +110,24 @@ case 5:
break; break;
case 6: case 6:
telRst(); var inColour = String($$[$0]);
colourCmd(inColour);
break; break;
case 7: case 7:
telRst();
break;
case 8:
printHelpDetails(); printHelpDetails();
break; break;
} }
}, },
table: [{3:1,4:2,6:[1,3],11:[1,4],12:[1,5],14:[1,6],15:[1,7],16:[1,8]},{1:[3]},{5:[1,9]},{7:[1,10]},{5:[2,3]},{7:[1,11]},{7:[1,12]},{5:[2,6]},{5:[2,7]},{1:[2,1]},{8:[1,13]},{13:[1,14]},{10:[1,15]},{7:[1,16]},{5:[2,4]},{5:[2,5]},{9:[1,17]},{7:[1,18]},{10:[1,19]},{5:[2,2]}], table: [{3:1,4:2,6:[1,3],11:[1,4],12:[1,5],14:[1,6],15:[1,7],17:[1,8],18:[1,9]},{1:[3]},{5:[1,10]},{7:[1,11]},{5:[2,3]},{7:[1,12]},{7:[1,13]},{7:[1,14]},{5:[2,7]},{5:[2,8]},{1:[2,1]},{8:[1,15]},{13:[1,16]},{10:[1,17]},{16:[1,18]},{7:[1,19]},{5:[2,4]},{5:[2,5]},{5:[2,6]},{9:[1,20]},{7:[1,21]},{10:[1,22]},{5:[2,2]}],
defaultActions: {4:[2,3],7:[2,6],8:[2,7],9:[2,1],14:[2,4],15:[2,5],19:[2,2]}, defaultActions: {4:[2,3],8:[2,7],9:[2,8],10:[2,1],16:[2,4],17:[2,5],18:[2,6],22:[2,2]},
parseError: function parseError (str, hash) { parseError: function parseError (str, hash) {
if (hash.recoverable) { if (hash.recoverable) {
this.trace(str); this.trace(str);
@ -612,20 +618,24 @@ case 6:return 12
break; break;
case 7:return 11 case 7:return 11
break; break;
case 8:return 16 case 8:return 18
break; break;
case 9:return 14 case 9:return 14
break; break;
case 10:return 15 case 10:return 17
break; break;
case 11:return 5 case 11:return 15
break; break;
case 12:return 'invalid_command' case 12:return 16
break;
case 13:return 5
break;
case 14:return 'invalid_command'
break; break;
} }
}, },
rules: [/^(?:\s)/,/^(?:\b[0-9]+mm\b)/,/^(?:\b([0-9]|[1-8][0-9]|9[0-9]|[12][0-9]{2}|3[0-4][0-9]|35[0-9])deg\b)/,/^(?:\b([0-9]|[1-8][0-9]|9[0-9]|100)%)/,/^(?:\b[0-9]+s\b)/,/^(?:\bmove\b)/,/^(?:\bpstop\b)/,/^(?:\bstop\b)/,/^(?:\bhelp\b)/,/^(?:\bcharge\sto\b)/,/^(?:\btelemetry\sreset\b)/,/^(?:$)/,/^(?:.)/], rules: [/^(?:\s)/,/^(?:(-[0-9]+mm|[0-9]+mm))/,/^(?:([0-9]|[1-8][0-9]|9[0-9]|[12][0-9]{2}|3[0-4][0-9]|35[0-9])deg\b)/,/^(?:([0-9]|[1-8][0-9]|9[0-9]|100)%)/,/^(?:[0-9]+s\b)/,/^(?:move\b)/,/^(?:pstop\b)/,/^(?:stop\b)/,/^(?:help\b)/,/^(?:charge\sto\b)/,/^(?:telemetry\sreset\b)/,/^(?:colour\b)/,/^(?:(red|blue|green|pink|orange))/,/^(?:$)/,/^(?:.)/],
conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12],"inclusive":true}} conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14],"inclusive":true}}
}); });
return lexer; return lexer;
})(); })();

View file

@ -139,19 +139,19 @@
<td style="text-align: center;" colspan="6"><strong> Set Heading to: </strong><strong id="SetHeading" style="font-size: 18px;">270</strong><strong>&#176;</strong></td> <td style="text-align: center;" colspan="6"><strong> Set Heading to: </strong><strong id="SetHeading" style="font-size: 18px;">270</strong><strong>&#176;</strong></td>
</tr> </tr>
<tr> <tr>
<td colspan="6"><input type ="range" min="0" max="359" value="270" class="slider" id="HdgSlider"></td> <td colspan="6"><input type ="range" min="0" max="359" value="180" class="slider" id="HdgSlider"></td>
</tr> </tr>
<tr> <tr>
<td style="text-align: center;" colspan="6"><strong>Set Translation to: </strong><strong id="SetTrans" style="font-size: 18px;">180</strong><strong>mm</strong></td> <td style="text-align: center;" colspan="6"><strong>Set Translation to: </strong><strong id="SetTrans" style="font-size: 18px;">180</strong><strong>mm</strong></td>
</tr> </tr>
<tr> <tr>
<td colspan="6"><input type ="range" min="0" max="1000" value="100" class="slider" id="TranSlider"></td> <td colspan="6"><input type ="range" min="-200" max="100" value="0" class="slider" id="TranSlider"></td>
</tr> </tr>
<tr> <tr>
<td style="text-align: center;" colspan="6"><strong>Set Speed to: </strong><strong id="SetSpd" style="font-size: 18px;">50</strong><strong>%</strong></td> <td style="text-align: center;" colspan="6"><strong>Set Speed to: </strong><strong id="SetSpd" style="font-size: 18px;">50</strong><strong>%</strong></td>
</tr> </tr>
<tr> <tr>
<td colspan="6"><input type ="range" min="0" max="100" value="50" class="slider" id="SpdSlider"></td> <td colspan="6"><input type ="range" min="0" max="100" value="100" class="slider" id="SpdSlider"></td>
</tr> </tr>
<tr> <tr>
<td colspan="6"><button onclick="setCmdMode(1); moveCmd(setTransto, setHdgto, setSpdto);">Send<br>Command</button></td> <td colspan="6"><button onclick="setCmdMode(1); moveCmd(setTransto, setHdgto, setSpdto);">Send<br>Command</button></td>
@ -235,6 +235,7 @@
var reqSpeed = 0; var reqSpeed = 0;
var reqCharge = 0; var reqCharge = 0;
var pstop_time = 0; var pstop_time = 0;
var hunt_colour = "";
var state = 0; var state = 0;
var batteryVoltage = 0; var batteryVoltage = 0;
@ -293,7 +294,7 @@
} }
function send_data() { function send_data() {
var raw_data = '{"Cid":' + command_id + ',"mode":' + mode + ',"rH":' + reqHeading + ',"rD":' + reqDistance + ',"rS":' + reqSpeed + ',"rC":' + reqCharge + ',"pSt":' + pstop_time + '}'; var raw_data = '{"Cid":' + command_id + ',"mode":' + mode + ',"rH":' + reqHeading + ',"rD":' + reqDistance + ',"rS":' + reqSpeed + ',"rC":' + reqCharge + ',"pSt":' + pstop_time + ',"col":' + hunt_colour + '}';
connection.send(raw_data); connection.send(raw_data);
console.log(raw_data); console.log(raw_data);
} }
@ -351,6 +352,7 @@
reqCharge = 0; reqCharge = 0;
pstop_time = 0; pstop_time = 0;
tel_rst = 0; tel_rst = 0;
hunt_colour = "";
send_data(); send_data();
updateCommandBuffer(); updateCommandBuffer();
command_id++; command_id++;
@ -364,6 +366,7 @@
reqCharge = 0; reqCharge = 0;
pstop_time = 0; pstop_time = 0;
tel_rst = 0; tel_rst = 0;
hunt_colour = "";
send_data(); send_data();
command_id = 1; command_id = 1;
updateCommandBuffer(); updateCommandBuffer();
@ -377,6 +380,7 @@
reqCharge = 0; reqCharge = 0;
pstop_time = pstp_tme; pstop_time = pstp_tme;
tel_rst = 0; tel_rst = 0;
hunt_colour = "";
send_data(); send_data();
updateCommandBuffer(); updateCommandBuffer();
command_id++; command_id++;
@ -390,6 +394,7 @@
reqCharge = chrglvl; reqCharge = chrglvl;
pstop_time = 0; pstop_time = 0;
tel_rst = 0; tel_rst = 0;
hunt_colour = "";
send_data(); send_data();
updateCommandBuffer(); updateCommandBuffer();
command_id++; command_id++;
@ -402,6 +407,20 @@
reqSpeed = 0; reqSpeed = 0;
reqCharge = 0; reqCharge = 0;
pstop_time = 0; pstop_time = 0;
hunt_colour = "";
send_data();
updateCommandBuffer();
command_id++;
}
function colourCmd(clrName){
mode = 4;
reqDistance = 0;
reqHeading = 0;
reqSpeed = 0;
reqCharge = 0;
pstop_time = 0;
hunt_colour = clrName;
send_data(); send_data();
updateCommandBuffer(); updateCommandBuffer();
command_id++; command_id++;
@ -417,7 +436,7 @@
} }
} }
var setHdgto = 270; var setHdgto = 180;
var hdg_slider = document.getElementById("HdgSlider"); var hdg_slider = document.getElementById("HdgSlider");
var hdg_output = document.getElementById("SetHeading"); var hdg_output = document.getElementById("SetHeading");
hdg_output.innerHTML = hdg_slider.value; hdg_output.innerHTML = hdg_slider.value;
@ -426,7 +445,7 @@
setHdgto = this.value; setHdgto = this.value;
} }
var setTransto = 100; var setTransto = 0;
var tran_slider = document.getElementById("TranSlider"); var tran_slider = document.getElementById("TranSlider");
var tran_output = document.getElementById("SetTrans"); var tran_output = document.getElementById("SetTrans");
tran_output.innerHTML = tran_slider.value; tran_output.innerHTML = tran_slider.value;
@ -435,7 +454,7 @@
setTransto = this.value; setTransto = this.value;
} }
var setSpdto = 50; var setSpdto = 100;
var spd_slider = document.getElementById("SpdSlider"); var spd_slider = document.getElementById("SpdSlider");
var spd_output = document.getElementById("SetSpd"); var spd_output = document.getElementById("SetSpd");
spd_output.innerHTML = spd_slider.value; spd_output.innerHTML = spd_slider.value;

View file

@ -2,16 +2,18 @@
%% %%
\s return 'whitespace' \s return 'whitespace'
\b[0-9]+"mm"\b return 'distance' ("-"[0-9]+"mm"|[0-9]+"mm") return 'distance'
\b([0-9]|[1-8][0-9]|9[0-9]|[12][0-9]{2}|3[0-4][0-9]|35[0-9])"deg"\b return 'heading_angle' ([0-9]|[1-8][0-9]|9[0-9]|[12][0-9]{2}|3[0-4][0-9]|35[0-9])"deg" return 'heading_angle'
\b([0-9]|[1-8][0-9]|9[0-9]|100)"%" return 'percentage' ([0-9]|[1-8][0-9]|9[0-9]|100)"%" return 'percentage'
\b[0-9]+"s"\b return 'stop_duration' [0-9]+"s" return 'stop_duration'
\bmove\b return 'move' move return 'move'
\bpstop\b return 'pstop' pstop return 'pstop'
\bstop\b return 'stop' stop return 'stop'
\bhelp\b return 'help' help return 'help'
\bcharge\sto\b return 'charge_to' charge\sto return 'charge_to'
\btelemetry\sreset\b return 'telemetry_reset' telemetry\sreset return 'telemetry_reset'
colour return 'colour'
("red"|"blue"|"green"|"pink"|"orange") return 'colour_name'
<<EOF>> return 'EOF' <<EOF>> return 'EOF'
. return 'invalid_command' . return 'invalid_command'
@ -47,6 +49,11 @@ expr
var inChrg = Number(String($3).substr(0, ((String($3).length) - 1))); var inChrg = Number(String($3).substr(0, ((String($3).length) - 1)));
chrgCmd(inChrg); chrgCmd(inChrg);
} }
| colour whitespace colour_name
{
var inColour = String($3);
colourCmd(inColour);
}
| telemetry_reset | telemetry_reset
{ {
telRst(); telRst();