diff options
Diffstat (limited to 'src/character.c')
-rw-r--r-- | src/character.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/character.c b/src/character.c index 658f0be..8a42370 100644 --- a/src/character.c +++ b/src/character.c @@ -1,10 +1,12 @@ #include "character.h" -const char character_luminance_map [] = {' ', ' ', '.', ',', '`', '-', '~', '"', '*', ':', ';', '<', '!', '/', '?', '%', '&', '=', '$', '#'}; -//const char map[] = {' ', '`', '.', ',', ':', ';', '\"', '+', '#', '@'}; +const char *default_character_map=" .,-~\"*:;<!/?%&=$#"; +//const char *default_character_map=" `.,:;/+#@"; -char calc_char(uint8_t _c , uint8_t _min, uint8_t _max) +char calc_char(uint8_t _c , uint8_t _min, uint8_t _max, char *_custom_map) { - float c = (float)(_c) / (_max - _min); - return character_luminance_map [(int)((sizeof(character_luminance_map)-1) * (c))]; + const char *map = _custom_map == 0 ? default_character_map : _custom_map; + + float c = (float)(_c) / (_max - _min); + return map [(int)( strlen( map ) * (c))]; } |