diff --git a/spark.cc b/spark.cc new file mode 100644 index 0000000..7a7d774 --- /dev/null +++ b/spark.cc @@ -0,0 +1,22 @@ +#include +#include + +#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]; +} + diff --git a/spark.h b/spark.h new file mode 100644 index 0000000..e400446 --- /dev/null +++ b/spark.h @@ -0,0 +1,7 @@ +#ifndef SPARK_H_ +#define SPARK_H_ + +char * getSparkByPrecentage(unsigned); +char * getSparkByValue(unsigned, unsigned); + +#endif