#include class Wattlight { volatile unsigned int count; volatile unsigned long us, oldus; volatile boolean haveold; public: unsigned int oldcount; unsigned long avgus; Wattlight (); inline __attribute__((always_inline)) void interrupt () { us = micros(); // Granularity only 4 us, this can be improved. if (haveold) { count++; } else { oldus = us; haveold = true; } } unsigned int pulses (); void readout (); };