Posts

Showing posts from June, 2012

Moving code from ESP8266 to ESP32

Image
A while ago I made a mashup of Dan Royer's code CNC 2 Axis Demo with my own code for trapezoidal motion stepper and servo control for ESP8266.

I assumed porting the code to the ESP32 would be trivial, and that was true for the most part: changes like library name being Wifi.h instead of Wifi8266.h were not a problem. UDP now does not like multicharacter writes but you can use print instead. So far so good.

However, when it came to the interrupt code I was stuck with the stepper interrupt causing an exception sometimes. And to make things weirder, the servo interrupt worked flawlessly (both of them had the IRAM_ATTR directive if you ask me).

Going little by little, I could narrow down the culprit to a floating point operation during the interrupt, that would cause problems sometimes but not always. Browsing around I found this post. Where the solution was simple: do not use floats within the interrupt routines but doubles. The reason was the float calculation would be performed by…

Hello Java Topology Suite

Image
There is always a better way, in my case, the better way was to get rid of my crappy implementation and to let others do the work for polygon buffering. And trust me, I tried to patch my simple implementation and next I tried to use the better but still not error-proof JavaGeom one. I ended up using the fine implementation of Java Topology Suite, that worked like a charm (once I managed to understand the subtle details of how things work over there).  So now you can see how the gray color lines are an accurate offset of blue polygons in my software. It did not hurt that JTS is a pure-Java library, so my tool will be multi-platform the easy way. I learned along the process that though SWIG framework does include Java bindings for CGAL library, it does not provide full access to all library functions and, once again, polygon buffer seems to be one of the parts missing. Besides, CGAL install is platform specific (though CGAL is still a terrific library).

Along the process I have learned …