Extend firmware

* encapsulate in classes
* automatic calculation of shift bitmasks from pin numbers