Spark graph functions

This commit is contained in:
l0ner 2014-04-14 22:32:03 +02:00
parent ccf33e2a26
commit 0857cdbfe4
2 changed files with 29 additions and 0 deletions

22
spark.cc Normal file

@ -0,0 +1,22 @@
#include <string>
#include <cstring>
#include "spark.h"
char getSparkByPrecentage(unsigned value) {
char ticks = " ▁▂▃▄▅▆▇█9";
unsigned tickVal = (float(value) / 10);
return ticks[tickVal];
}
char getSparkByValue(unsigned value, unsigned max) {
char ticks = " ▁▂▃▄▅▆▇█9";
unsigned tickVal = (float(value) / float(max) * 10);
return ticks[tickVal];
}

7
spark.h Normal file

@ -0,0 +1,7 @@
#ifndef SPARK_H_
#define SPARK_H_
char * getSparkByPrecentage(unsigned);
char * getSparkByValue(unsigned, unsigned);
#endif