Air Quality Monitor
Portable C application for collecting, storing, and analyzing air quality sensor readings
Loading...
Searching...
No Matches
configure_limits.c
1#include "core/aqm_platform.h"
2#include "core/globals.h"
3#include <stdio.h>
4#include <stdlib.h>
5#include <string.h>
6
7void configure_limits(void) {
8 aqm_flush_stdin();
9
10 printf("Configure pollutant limits and collection settings (press Enter to keep current value):\n");
11
12 char input[64];
13
14 printf("PM2.5 limit (current: %.4f): ", limit_pm25);
15 if (fgets(input, sizeof(input), stdin) && strlen(input) > 1) {
16 float temp;
17 if (aqm_parse_float(input, &temp))
18 limit_pm25 = temp;
19 }
20
21 printf("PM10 limit (current: %.4f): ", limit_pm10);
22 if (fgets(input, sizeof(input), stdin) && strlen(input) > 1) {
23 float temp;
24 if (aqm_parse_float(input, &temp))
25 limit_pm10 = temp;
26 }
27
28 printf("CO limit (current: %.4f): ", limit_co);
29 if (fgets(input, sizeof(input), stdin) && strlen(input) > 1) {
30 float temp;
31 if (aqm_parse_float(input, &temp))
32 limit_co = temp;
33 }
34
35 printf("NO2 limit (current: %.6f): ", limit_no2);
36 if (fgets(input, sizeof(input), stdin) && strlen(input) > 1) {
37 float temp;
38 if (aqm_parse_float(input, &temp))
39 limit_no2 = temp;
40 }
41
42 printf("O3 limit (current: %.6f): ", limit_o3);
43 if (fgets(input, sizeof(input), stdin) && strlen(input) > 1) {
44 float temp;
45 if (aqm_parse_float(input, &temp))
46 limit_o3 = temp;
47 }
48
49 printf("SO2 limit (current: %.6f): ", limit_so2);
50 if (fgets(input, sizeof(input), stdin) && strlen(input) > 1) {
51 float temp;
52 if (aqm_parse_float(input, &temp))
53 limit_so2 = temp;
54 }
55
56 printf("Data collection interval in seconds (current: %d): ", collection_interval);
57 if (fgets(input, sizeof(input), stdin) && strlen(input) > 1) {
58 int temp;
59 if (aqm_parse_int(input, &temp) && temp >= 1)
60 collection_interval = temp;
61 }
62
63 printf("Data retention period in days (current: %d): ", retention_period);
64 if (fgets(input, sizeof(input), stdin) && strlen(input) > 1) {
65 int temp;
66 if (aqm_parse_int(input, &temp) && temp >= 1)
67 retention_period = temp;
68 }
69
70 if (collection_interval < 1)
71 collection_interval = 1;
72 if (retention_period < 1)
73 retention_period = 1;
74
75 printf("Configuration updated.\n");
76}