Largely-updated documentation

Added a large amount of internal commenting and docstrings to the
arduino code to make it more maintainable.