https://mbed.org/users/embeddedartists/code/EALib/#d868b74fd08e