So I overhauled my old controller and software for the third time to support this significant upgrade. While I was at it, I wanted to achieve a few other things:
- Custom PCB
- Better joystick
- Custom library for implementing buttons and touch control
- Faster screen refresh rate
Custom PCB:
To start with, here's the custom PCB I designed. This was a first for me and surprisingly not as difficult as I expected once you get a handle of the software (Eagle). It was also relatively cheap, about 30 euro for three boards if I remember correctly. I could also order most of the components with the PCBs. You can see I had fun trying to fill in the empty space with some macro related images. It has a Arduino Mega / Due / Grand Central M4 shield form factor so it can plug directly into the headers of those boards. This was key for me to keep the overall size of the electronics at a minimum and even when used in conjunction with a screen it's quite small and tidy.
Here is the progression (from right to left) of the boards I've created for my macro setup over the past two years. The custom PCB is smaller, neater, and fits more on the board. It also says TMC2130 but supports the TMC5160 board with no modifications. Custom Arduino Library
This was another challenge and another first for me as I'm not a software developer and consider myself OK at Arduino things.
My previous touch-screen implementation worked well but the code was spaghetti - all the button placements and touch detection was hardcoded across dozens of parts of the program. If I moved a button, I had to update the dimensions and locations for that button and others across multiple files, as well as the co-ordinates that would trigger the button based on a touch input.
The new library aimed to solve that by having the user create the button once with several additional parameters and then taking care off drawing the button, detecting touch, changing button state, calling other functions, writing text, centering text, overwriting text etc via other simple functions. So far it works very well and supports all of my use cases such as shared buttons on multiple "screens", inter-dependent buttons, bitmaps as buttons, fast text replacement and refresh rate, toggle and momentary buttons, joystick navigation etc.
The library can be found on my github here. I'm not good at writing code for others but have included a fairly comprehensive example taken from my main program. If you're not a fan of touch screens, you can also use another input such as a joystick or arrow-key buttons to navigate through your screens, menus, buttons, and inputs. This is enabled in addition to touch in the example code but I don't use it myself for my main program.
Video of me demonstrating the user interface, joystick control, stallGuard homing, etc: https://www.youtube.com/watch?v=Nf2cB-ZaPhQ
I haven't finished configuring the stepper driver yet, it's still too noisy for my tastes at high velocities (for stepping it's dead quiet) but the current config is good enough for testing at the moment. There's also a few bugs left to squash and I hadn't connected the flash setup for this demo (hence the flash test and flash buttons having no effect).
Lastly, you can find the code for my current program and user interface here: https://github.com/camdey/MacroStepper
It's not quite finished but definitely in a working state with a few small bugs and improvements to be made. Once I finish the physical setup for my motorized rail, I'll probably post them as updates to this thread to keep it all in one place.
The files for the PCB can also be found at the above github repo - feel free to use or adapt (for non-commercial purposes) if you find them useful.