diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2022-01-05 02:18:16 +0100 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2022-01-05 02:18:16 +0100 |
commit | d9b9b3e71397a2da9e16cbee75c4954105237363 (patch) | |
tree | 79d4be62e5357868b5af75301017553d3e8b692c /src/helpers.c | |
parent | 01227e76785845dae377a8808146ff51209f727a (diff) | |
download | analog_instruments-d9b9b3e71397a2da9e16cbee75c4954105237363.tar.gz |
p command working to change PWM
refactgored pwm code
Diffstat (limited to 'src/helpers.c')
-rw-r--r-- | src/helpers.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/helpers.c b/src/helpers.c new file mode 100644 index 0000000..b8c3373 --- /dev/null +++ b/src/helpers.c @@ -0,0 +1,27 @@ +/* + * src/helpers.c + * (c) 2022 Jonas Gunz <himself@jonasgunz.de> + * License: All rights reserved. + */ + +#include "helpers.h" + +uint8_t hex_to_byte(char c[]) { + uint8_t ret = hex_to_halfbyte(c[0]); + ret += 16 * hex_to_halfbyte(c[1]); + + return ret; +} + +uint8_t hex_to_halfbyte(char c) { + uint8_t ret = 0; + + if ( c >= 48 && c <= 57) + ret = c-48; + else if (c >= 65 && c <= 70) + ret = c-55; + else if (c >= 97 && c <= 102) + ret = c-87; + + return ret; +} |