Another attempt at a c version of the py adafruit code