From 375324e5f4c0cc0a4137c60df03334d1bef92fff Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 24 Sep 2019 10:15:41 +0200 Subject: input_gadgets.c: Luftfeuchte und Taupunkt ausgewertet --- input_gadgets.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/input_gadgets.c b/input_gadgets.c index f525eb4..863baab 100644 --- a/input_gadgets.c +++ b/input_gadgets.c @@ -979,6 +979,7 @@ char *gadgets_retrieve_humidity(char *output, int max_len, double fh_temperature MemoryStruct chunk; int ret_val; double temperature, humidity; + char *ende = output; chunk.memory = malloc(1); chunk.size = 0; @@ -1008,7 +1009,6 @@ char *gadgets_retrieve_humidity(char *output, int max_len, double fh_temperature free(chunk.memory); if (res != CURLE_COULDNT_RESOLVE_HOST && res != CURLE_COULDNT_CONNECT) return NULL; - char *ende = output; if (max_len > 0) ende += snprintf(ende, max_len, "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", 0xEE, 0x01, 0xEE, 0x02, 0xEE, 0x01, 0xEE, 0x02, 0xEE, 0x05, 0xEE, 0x06, 0xEE, 0x05, 0xEE, 0x06); return ende; @@ -1038,7 +1038,22 @@ char *gadgets_retrieve_humidity(char *output, int max_len, double fh_temperature snprintf(tmp_str, 11, "%.*s", (int)(rm[2].rm_eo - rm[2].rm_so), (char*)(chunk.memory + rm[2].rm_so)); temperature = atof(tmp_str); - output += snprintf(output, max_len, "%f -> %f; %f -> %f", fh_temperature, temperature, fh_humidity, humidity); + humidity *= maximale_luftfeuchte(temperature); + fh_humidity *= maximale_luftfeuchte(fh_temperature); + + if ((output + max_len - ende > 0) && (temperature <= taupunkt(fh_humidity))) + ende += snprintf(ende, max_len, "!TP %.1f K; ", taupunkt(fh_humidity) - temperature); + if ((output + max_len - ende > 0) && (temperature <= taupunkt(humidity))) + ende += snprintf(ende, max_len, "!TP %.1f K; ", taupunkt(humidity) - temperature); + if (output + max_len - ende > 0) + ende += snprintf(ende, max_len, "%.0f %%", humidity * 100 / fh_humidity); free(chunk.memory); - return output; + + while (output < ende) { + if (*output == '.') + *output = ','; + output++; + } + + return ende; } -- cgit v1.2.3-54-g00ecf