Suppose that a given type of 2-axis XY machine normally has one or both of its axes oriented in the opposite direction than "conventional". It would be nice if the machine definition could encapsulate this.
A straightforward approach might be to specify the command in the machine definition (.ini) file as: movexy = "SM,%d,-%x,-%y".
However, this will not actually work because this block is interpreted by cmdstr as serialCommand(cmdstr('movexy', change));where that function is defined as
function cmdstr(name, values) {
if (!name || !cncserver.bot.commands[name]) return ''; // Sanity check
var out = cncserver.bot.commands[name];
for(var v in values) {
out = out.replace('%' + v, values[v]);
}
return out;
}
This function works well for many types of possible tweaks to the command strings. For example, it allows the X and Y coordinates to be swapped easily. However, this particular tweaked command string won't work with it: When the change values are negative, it would be interpreted somewhat like "SM,<duration>,--<abs(x change)>,--<abs(y change)>".
One approach would be to detect the "double negative" there and remove it. Another would be to forbid this "-%s" syntax, and add a separate option in the settings for default orientation.
Suppose that a given type of 2-axis XY machine normally has one or both of its axes oriented in the opposite direction than "conventional". It would be nice if the machine definition could encapsulate this.
A straightforward approach might be to specify the command in the machine definition (.ini) file as:
movexy = "SM,%d,-%x,-%y"
.However, this will not actually work because this block is interpreted by cmdstr as
serialCommand(cmdstr('movexy', change));
where that function is defined asThis function works well for many types of possible tweaks to the command strings. For example, it allows the X and Y coordinates to be swapped easily. However, this particular tweaked command string won't work with it: When the change values are negative, it would be interpreted somewhat like
"SM,<duration>,--<abs(x change)>,--<abs(y change)>"
.One approach would be to detect the "double negative" there and remove it. Another would be to forbid this "-%s" syntax, and add a separate option in the settings for default orientation.