Riverdi 70

Dependencies:   mbed HYT FT813

Revision:
0:e46c1282b39f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TFT/display.StringsTransforming.cpp	Thu Jun 18 13:18:02 2020 +0000
@@ -0,0 +1,51 @@
+#include "display.h"
+
+/**************************************************************************************************************************
+************************** Transform humiditity / temperature float value to string ***************************************
+**************************************************************************************************************************/
+// If isTemp = 0, string includes
+// 1. current humididty
+// 3. " %"
+
+// If isTemp = 1, string includes
+// 1. "-" (optional),
+// 2. current temperature with decimal mark
+// 3. " С"
+void Display::CreateStringTempHum(char *str, float number, bool isTemp)
+{
+    short int multipedNumber = (short int)(number * 100);
+    char strCnt = 0;
+    if (isTemp) {
+        if (multipedNumber < 0) {
+            multipedNumber = -multipedNumber;
+            str[strCnt] = '-';
+            strCnt++;
+        }
+    }
+    if (multipedNumber >= 10000) {
+        str[strCnt] = '0' + (multipedNumber % 100000) / 10000;
+        strCnt++;
+    }
+    if (multipedNumber >= 1000) {
+        str[strCnt] = '0' + (multipedNumber % 10000) / 1000;
+        strCnt++;
+    }
+    if (multipedNumber >= 100) {
+        str[strCnt] = '0' + (multipedNumber % 1000) / 100;
+        strCnt++;
+    }
+    if (isTemp) {
+        str[strCnt] = '.';
+        strCnt++;
+        str[strCnt] = '0' + (multipedNumber % 100) / 10;
+        strCnt++;
+        str[strCnt] = ' ';
+        strCnt++;
+        str[strCnt] = 'C';
+        strCnt++;
+    } else {
+        str[strCnt] = '%';
+        strCnt++;
+    }
+    str[strCnt] = 0;
+}
\ No newline at end of file