Closed Festivejelly closed 10 months ago
PS Sorry about the formatting changes VS code does it automatically, ive tried to limit it where I can. Im not sure what the original formatting rules were but VS code constantly wants to change it.
@Festivejelly thanks for this PR. Please minimize the diff to the minimally necessary lines and keep the style consistent. This repo is monitored by a lot of people and we should be respectful of their attention :) Thanks!
lll go through it tonight and revert the formatting.
Okay fixed the formatting. Though I do think the whole file needs a proper formatting pass. I can see it being an annoyance to people who it could impact.
@Festivejelly sorry, I took a stab at the task myself as I didn't want to tire you with too many nitpicks. Please check if the latest h4.ino works for you? There are a few minor changes to your proposal - only 1 keycode can be sent per line e.g. =185\n
and version reporting looks like ...|Id:H4V10>
Seems to be okay. Probably works better having 1 keycode per line as then I can listen for an OK.
Curious about this section though:
} else if (serialInKeycode) {
if (charCode < 32) {
if (serialKeycode == 0) {
serialKeycode = keycodeCommand.toInt();
Serial.println(serialKeycode);
} else {
Serial.println("slower");
}
serialInKeycode = false;
keycodeCommand = "";
} else {
keycodeCommand += receivedChar;
}
}
Why does it print "slower"?
There's a theoretical edge case possible where previous key is not processed by the time the next one is received. I don't think it's realistic since serial is much slower than key processing but left it there just in case. If it happens, you can just put a 1ms delay between sending the keys in JS.
Makes sense. I was going to put a delay in any way. Looks good. Ill do some testing on it, but from what I tested on my PR it seemed to work quite well indeed.
I think it will be really handy for people not comfortable writing Gcode, which I hope my new tool will help with. But the built in functions to the nano work really well so I thought it would be nice to have a way of having a one click method of using those operations.
Closing this as functionality has been added.
This PR is to add the capability to send key events over serial.
The gcode task will look for the "=" command and add any key events in that command to a queue which gets processed by the processKeyPadEvent function.
For example if you wanted to set all of the endstops to the current position you would send:
=135,143,134,144
These are these key codes after bit setting (by adding 128) which means they become "isPressed"
define B_STOPL 7
define B_STOPR 15
define B_STOPU 6
define B_STOPD 16
Im in the middle of building a UI that helps simplify this which will have a wizard for each function. The UI backend will be responsible for handling which keycodes are used but in order to be able to do that I needed this API.
It seems to work well for me so far. I'll be doing a check in the UI to make sure that the controller is using at least version 10.
Let me know if you have any ideas for changes or any concerns. I think it will be useful when my UI companion app is finished.