fix an old use of char instead of stringbuf for a report
add millis to all reports at creation
Merge pull request #153 from Pinoccio/report-millis

Report millis
Remove incorrect logic around pin reports firing
Revert "Remove incorrect logic around pin reports firing"

This reverts commit ee48a168fb03b3e1437db986578bf81c17bb9eb9.

This code is about to be rewritten anyway and reverting this commit
makes rebasing the ongoing pin mode restructure work easier.
Make getRegisterPinMode always return the actual pin mode

Previously, it returned -1 for disabled pins, but thats mixing up
physical pin modes with logical ones.

Note that this method is not currently used, but it might be again in
the future.
Add constants for pin modes

There were already some constants, but these were a mix of the Arduino
pin mode constants and some extra defines). This unifies this to a
separate enum with PINMODE_* constants, which are used everywhere
Pinoccio pinmodes are used.

In setMode(), the Pinoccio and Arduino modes are still interchanged,
this will be fixed next.
Don't mix pinmode constants in PinoccioScout::setMode

Previously, the Pinoccio pin modes were sometimes used as Arduino
pinmodes. This worked, because INPUT/OUTPUT/INPUT_PULLUP overlap, but
it's not very elegant. Now, a switch is used to map all the supported
PINMODE_* constants into the proper pinMode argument instead.

Also, the pin value is now also determined in a switch, to prevent
calling pinRead while it's not actually needed. As an extra advantage,
this calls pinRead after changing the pinmode, so when changing to
OUTPUT, the value read should better reflect the actual output value.
Introduce a new "UNSET" pin mode

This is similar to the existing "DISABLED" mode, except that the actual
pin modes aren't touched (should default to INPUT, though) and a pin can
never be set to UNSET again (unless through a reboot).

This new mode is needed for properly supporting the "make all other pins
disconnected" later.
Let getPinMode return PINMODE_UNSET for other pins

Previously, it would only work for the Dx and Ax pins, and return an
undefined value for other pins. Now it returns PINMODE_UNSET for those
other pins.
Introduce a "DISCONNECTED" pin mode

This pin mode is used for pins that are not connected to anything (e.g.
floating). Normally these pins cause extra power usage when their value
voltage floats halfway the high and low levels (due to static
electricity or other noise). This causes the input gates to switch
between high and low states frequently, causing extra power draw.

By marking these pins as disconnected, we can enable the internal pullup
on those pins and prevent wasting power. Quick measurement shows a
fairly stable 25mA draw (through USB, without battery with nothing else
connected) when all disconnected pins are marked as such. Otherwise, the
power draw fluctuates between 26 and 32mA, depending on the environment.

Note that we cannot default to enabling the pullups, since during
startup we can't be sure that pins are actually floating. Enabling the
pullup on pins that have something connected to them can actually cause
problems (relays switching on, leds lighting up dimly).
Make isPinReserved work for all pins

Currently, the function is only called for the Dx and Ax pins. It used
to only look at backpacks for deciding about reserved pins, but now it
also knows about the pins that are connected to something on the
Pinoccio Scout board itself (fuel gauge, serial port, led, etc).

These pins are hardcoded for now, this should be generalized later on.
Add pin.othersdisconnected bitlash function

This allows quickly switching all pins that have no pin mode yet to the
"DISCONNECTED" pin mode. Calling this after setting up the pin modes
helps to reduce power usage.
Use newly added D0-D8 constants
Simplify is{Digital,Analog,PWM}Pin
Merge digital and analog pin state and mode arrays

Instead of separate arrays for analog and digital, there is now a single
array for all pins. This allows storing info about the special pins
(like MISO, MOSI, TX1, etc.) as well, in the future also allowing
controlling those pins through the pin functions (though now only the
D2-D8 and A0-A7 part of the array is used).
Merge updateDigitalPinState and updateAnalogPinState

Now that the pin state and mode arrays are merged, these functions are
nearly identical so they can just be merged.
Let pinWrite work for special pins as well

Previously, it would only work for D2-D8 and A0-A7. Now, it doesn't care
wether a pin is digital or analog or special, it just works based on the
pin mode.
Let pinRead work for special pins as well

Previously, it only worked for D2-D8 and A0-A7, but now it just looks at
the pin mode without distinguising between digital and special pins. It
does still treat analog pins differently, by calling analogRead instead
of digitalRead on them.
Let getPinFromArg support special pins

Previously, it only allowed passing in the pin numbers of the D2-D8 and
A0-A7 pins. Now, it allows any valid pin number, which enables using all
the pin bitlash functions to work with all special pins too.

Note that pin names are still only supported for the regular pins,
accessing special pins works by passing in their pin number directly.