The fastest way to get started with your own spaying script is to use existing code and to modify it. The iMatrixSpray has two boards inside: a Raspberry Pi board which is programmed to run the web server and to assemble the code (gcode format) which is then send to a second board for execution on the hardware. This process of downloading the gcode to the 2nd board is also what you see on the left side of the user interface once you start the spray.
Obviously, you could modify the web server code to fit your specific needs. Much simpler and faster is to generate a gcode file on your computer and upload this to the device for execution. You may test this process by using you favorite text editor to generate a file with some name .gcode (e.g. “helloworld.gcode”). Place some code into the file, e.g.
G28
G1Z-50
G1Z0
and upload the file to the raspberry pi by dragging it on the web interface. Now you can select and execute this file.
To get a “real” spray protocol, I recommend to start by modifying the existing Python script which is used to generate the gcode file. It can be found here: https://github.com/stoeckli/iMatrixSpray/blob/master/octoprint/server.py
Some constants are a the top (lines 43) and the spray code starts at line 344. Extract the code into your favorite Python development environment and start modifying the program to generate a file to your needs.
A word of caution: use water to test the spay, as the matrix solution might clog you capillary if you don’t wash it properly after the spray… Also, you might want to detach the spay head from the moving parts if you test some fun stuff.