up_n_down: improve EEPROM access pattern

The original program writes to fixed EEPROM locations, stressing the
first two cells only. Let's do it differently:

1. All configuration is kept in a single data structure.
2. The EEPROM memory space is divided into slots.
3. Each slot has a sequence number.
4. A new slot is always used to write the configuration, and it gets
   the next highest available sequence number.
5. Number of slots is not a multiple of the highest sequence number.
6. Both sequence numbers and slot numbers can overflow eventually, but
   thanks to point 5, there will always be a "gap" after the last
   sequence number.

The configuration is read once at startup, and written once before
switching off, and only if any values actually changed.

I employed a few other clever tricks:

The sequence number 255 is never used, so there are only 255 sequence
numbers, which greatly helps satisfy point 5 above. But by choosing 255,
which is the default content of an EEPROM cell after erase, it can also
be used to detect uninitialised cells.

Finding the gap on startup is implemented as a binary search, rather than
a sequential search. With 512 bytes and a 4-byte slot, 9 steps are needed
to find the gap (as opposed to an average of 256 for a sequential search).

The binary search algorithm was designed to minimise EEPROM accesses.
That's why there are separate variables for sequence numbers.

The modulo 255 operation is a mock implementation optimised for speed. It
only works correctly in a limited range, and in fact also produces
positive remainders for negative numbers, but all these quirks are
desired for the purposes of determining whether there is a gap in the
sequence numbers.