Riverdi 70

Dependencies:   mbed HYT FT813

Committer:
vitlog
Date:
Thu Jun 18 13:18:02 2020 +0000
Revision:
0:e46c1282b39f
Riverdi EVE 70

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vitlog 0:e46c1282b39f 1 #include "display.h"
vitlog 0:e46c1282b39f 2
vitlog 0:e46c1282b39f 3 /**************************************************************************************************************************
vitlog 0:e46c1282b39f 4 ************************** Transform humiditity / temperature float value to string ***************************************
vitlog 0:e46c1282b39f 5 **************************************************************************************************************************/
vitlog 0:e46c1282b39f 6 // If isTemp = 0, string includes
vitlog 0:e46c1282b39f 7 // 1. current humididty
vitlog 0:e46c1282b39f 8 // 3. " %"
vitlog 0:e46c1282b39f 9
vitlog 0:e46c1282b39f 10 // If isTemp = 1, string includes
vitlog 0:e46c1282b39f 11 // 1. "-" (optional),
vitlog 0:e46c1282b39f 12 // 2. current temperature with decimal mark
vitlog 0:e46c1282b39f 13 // 3. " С"
vitlog 0:e46c1282b39f 14 void Display::CreateStringTempHum(char *str, float number, bool isTemp)
vitlog 0:e46c1282b39f 15 {
vitlog 0:e46c1282b39f 16 short int multipedNumber = (short int)(number * 100);
vitlog 0:e46c1282b39f 17 char strCnt = 0;
vitlog 0:e46c1282b39f 18 if (isTemp) {
vitlog 0:e46c1282b39f 19 if (multipedNumber < 0) {
vitlog 0:e46c1282b39f 20 multipedNumber = -multipedNumber;
vitlog 0:e46c1282b39f 21 str[strCnt] = '-';
vitlog 0:e46c1282b39f 22 strCnt++;
vitlog 0:e46c1282b39f 23 }
vitlog 0:e46c1282b39f 24 }
vitlog 0:e46c1282b39f 25 if (multipedNumber >= 10000) {
vitlog 0:e46c1282b39f 26 str[strCnt] = '0' + (multipedNumber % 100000) / 10000;
vitlog 0:e46c1282b39f 27 strCnt++;
vitlog 0:e46c1282b39f 28 }
vitlog 0:e46c1282b39f 29 if (multipedNumber >= 1000) {
vitlog 0:e46c1282b39f 30 str[strCnt] = '0' + (multipedNumber % 10000) / 1000;
vitlog 0:e46c1282b39f 31 strCnt++;
vitlog 0:e46c1282b39f 32 }
vitlog 0:e46c1282b39f 33 if (multipedNumber >= 100) {
vitlog 0:e46c1282b39f 34 str[strCnt] = '0' + (multipedNumber % 1000) / 100;
vitlog 0:e46c1282b39f 35 strCnt++;
vitlog 0:e46c1282b39f 36 }
vitlog 0:e46c1282b39f 37 if (isTemp) {
vitlog 0:e46c1282b39f 38 str[strCnt] = '.';
vitlog 0:e46c1282b39f 39 strCnt++;
vitlog 0:e46c1282b39f 40 str[strCnt] = '0' + (multipedNumber % 100) / 10;
vitlog 0:e46c1282b39f 41 strCnt++;
vitlog 0:e46c1282b39f 42 str[strCnt] = ' ';
vitlog 0:e46c1282b39f 43 strCnt++;
vitlog 0:e46c1282b39f 44 str[strCnt] = 'C';
vitlog 0:e46c1282b39f 45 strCnt++;
vitlog 0:e46c1282b39f 46 } else {
vitlog 0:e46c1282b39f 47 str[strCnt] = '%';
vitlog 0:e46c1282b39f 48 strCnt++;
vitlog 0:e46c1282b39f 49 }
vitlog 0:e46c1282b39f 50 str[strCnt] = 0;
vitlog 0:e46c1282b39f 51 }