summaryrefslogtreecommitdiff
path: root/input_gadgets.c
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-09-24 10:15:41 +0200
committerErich Eckner <git@eckner.net>2019-09-24 10:15:41 +0200
commit375324e5f4c0cc0a4137c60df03334d1bef92fff (patch)
tree1de873641e4dd53f6b1bf1c362ff971401a36df0 /input_gadgets.c
parent35add888583b649d8b5af650389ddf05a75598b8 (diff)
downloadanzeige-375324e5f4c0cc0a4137c60df03334d1bef92fff.tar.xz
input_gadgets.c: Luftfeuchte und Taupunkt ausgewertet
Diffstat (limited to 'input_gadgets.c')
-rw-r--r--input_gadgets.c21
1 files 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;
}