PSoC 4 – an exciting low-cost platform

I started using microcontrollers with the Arduino / ATMega platforms because of the simple IDE and the large amount of additional material available.

Now I discovered a new platform and started building projects on it. Its the PSoC 4 family made by Cypress. You get a prototyping board with an ARM processor and everything you need to start for less than 5 €, the software is free. One of the included features is support for capacitive sensing without additional components.

These boards will replace Arduinos in some of my future projects.

Polygon | new version 2.0.7 and 3.0.7

Polygon logoAfter one and a half year I released new versions of my packages for polygon handling. There are no big changes, just some patches that have accumulated over the time. Most important are:

  • fixed some methods to work with instances of subclasses
  • fixed a bug in the SVG export (rgb), thanks to Diederik van Lierop
  • fixed a bug with exceptions in the initialisation, thanks to Diederik van Lierop
  • fixed a bug in gpc: replace on DBL_EPSILON with variable GPC_EPSILON, thanks to Peter Vavaroutsos
  • code changes to work with future versions of numpy (#define NPY_NO_DEPRECATED_API NPY_1_8_API_VERSION
  • added optional labels to SVG export and changed default colors, thanks to Diederik van Lierop (Polygon 3.0.7 only)

Packages can be found on bitbucket (Polygon2, Polygon3) and pypi (Polygon2, Polygon3).



Polygon | problems with nested and overlapping structures

Polygon is not able to handle nested and overlapping contours correctly. This is because the underlying structures and  functions of GPC have only a flat list of contours (solids and holes) without any hierarchy. A hole is not bound to a single solid but is valid for the whole Polygon. If your Polygon object contains more than one solid contour and at least one hole you may not get the results you expected.

One big problem is that it’s very easy to create such Polygon objects using standard operations! An example (thanks to Willie Maddox) illustrates this:

from Polygon import Polygon
poly3 = Polygon(((-3,-3),(-3,3),(3,3),(3,-3)))
poly2 = Polygon(((-2,-2),(-2,2),(2,2),(2,-2)))
poly1 = Polygon(((-1,-1),(-1,1),(1,1),(1,-1)))
p = poly3 - poly2 + poly1

p will be a square (poly3) with a hole (poly2) and a second solid contour (poly1) inside the hole:

 0:Contour: [0:1.0, -1.0] [1:-1.0, -1.0] [2:-1.0, 1.0] [3:1.0, 1.0]
 1:Hole : [0:2.0, 2.0] [1:-2.0, 2.0] [2:-2.0, -2.0] [3:2.0, -2.0]
 2:Contour: [0:3.0, -3.0] [1:-3.0, -3.0] [2:-3.0, 3.0] [3:3.0, 3.0]

But the hole is not bound to the outer contour, it is valid for the inner contour as well and covers it completely. If you do further operations with this Polygon the results may be wrong. p.isInside(0,0) will return False because the point is inside a hole, even if it is inside a second solid contour.

You may use the method p.simplify() to make the Polygon p valid for further operations, but you  may lose overlapping contours. The method first adds all solid contours and then substracts all holes. In the example above the inner solid contour is lost:

 0:Hole : [0:2.0, 2.0] [1:-2.0, 2.0] [2:-2.0, -2.0] [3:2.0, -2.0]
 1:Contour: [0:3.0, -3.0] [1:-3.0, -3.0] [2:-3.0, 3.0] [3:3.0, 3.0]

Unfortunately there is no easy way to change this behaviour. The main problem is located in the data structures of GPC, which is a core component of Polygon and can’t be replaced easily.

The Project Hosting Odyssey

I moved the hosting of my software projects again: from GitHub to bitbucket. My GitHub repositories will be available in the near future, but I will use bitbucket for development (until further notice 😉 ).

I must confess that I always used the free offers and never spent any money on project hosting. So I got a lot for free and should not complain. But all offers proved to be suboptimal or did not exist long enough to be a reliable platform.

After some self-hosted RCS,  CVS and SVN repositories (many years ago) I moved to This pretty good service was closing after some years. One of my projects then moved to BerliOS. This service was announced to close as well, so I used this as a chance to switch to git and moved all my projects to GitHub.

After some time I needed a private repository for a closed-source project. Private repositories are not part of the free plan on GitHub, so I used bitbucket in parallel. Now that GitHub has decided to close the download area, I needed to find download hosting for packages. Instead of  using three different services I decided to move all my projects  to bitbucket today.

Some of my older projects (like Polygon) now outlived  a lot of different platforms and version control systems.

Polygon | new version 2.0.6 and 3.0.6

Polygon logoI just released the new version of my packages for polygon handling with Python 2 and Python 3. There are only small changes, the most important ones are:

  1. moved development and downloads from GitHub to bitbucket after GitHub closed the download area,
  2. renamed the packages from Polygon to Polygon2 and Polygon3 to avoid confusion, especially on pypi,
  3. added a Douglas-Peucker simplification routine to Polygon3.

From now on I will implement new features in Polygon3 while Polygon2 will receive bugfixes only.

Binary packages for Windows will follow. I currently can’t compile x64 binaries for Python 3.3 because neither my Visual Studio 2008 nor Visual Studio 2010 Express supports this. I would appreciate any help for this or the contribution of packages.



GitHub downloads closed

My favourite development hoster GitHub has closed the download area for packages. Older uploads will be available for a while, but no new uploads are accepted. This was a bad decision, project hosting without a download area is not really attractive anymore!

I will check the different options to host packages for my projects. In the meantime everything will be available in my own download area.

One option is to move away from GitHub to bitbucket or a similar service.

DyMat | HDF5 export and other Modelica/Python projects

DyMat_logoAfter the request of a user I added a very simple HDF5 export to my DyMat package. The code is already in the github repository and will be part of the next release.

If you are interested in the handling of Modelica simulations with Python you should also have a look at these packages:

Happy new year!

SunnyWebBox | version 0.3 with UDP and Python 3

I’ve updated the code for my python package to communicate with a Sunny WebBox. The two most important changes of version 0.3 are:

  • support for UDP stream communication
  • support for python 3.x

The communication protocols are documented very poorly. I had to use trial-and-error a lot and collect information from different sources to get this working. The UDP-based protocol finally works but seems to be pretty weak.

The package is used for several months now to monitor a photovoltaic plant, but was still not tested with a wider range of devices. Use It with care!