Previously the setting the alarm would overwrite the overflow callback and vice versa. Since we can only set one alarm in hardware, always set the alarm to the closest event of the two.
We can't read back the alarm, so just store it in a variable.
We can't set the hardware counter directly, so always add an offset.