thermferm/rdconfig.c

changeset 71
a09c5cdc4022
parent 69
df5d983dab1b
child 72
f7cb53c50ee1
equal deleted inserted replaced
70:920eface3ec5 71:a09c5cdc4022
122 int wrconfig(char *config) 122 int wrconfig(char *config)
123 { 123 {
124 int rc = 0; 124 int rc = 0;
125 FILE *fp; 125 FILE *fp;
126 w1_therm *tmp1; 126 w1_therm *tmp1;
127 #ifdef HAVE_WIRINGPI_H 127 units_list *tmp3;
128 rc_switch *tmp2;
129 #endif
130 128
131 if (getenv((char *)"USER") == NULL) { 129 if (getenv((char *)"USER") == NULL) {
132 mypath = xstrcpy((char *)"/root"); 130 mypath = xstrcpy((char *)"/root");
133 } else { 131 } else {
134 mypath = xstrcpy(getenv((char *)"HOME")); 132 mypath = xstrcpy(getenv((char *)"HOME"));
146 144
147 fprintf(fp, "# Configuration file for thermferm %s\n", VERSION); 145 fprintf(fp, "# Configuration file for thermferm %s\n", VERSION);
148 fprintf(fp, "\n"); 146 fprintf(fp, "\n");
149 147
150 #ifdef HAVE_WIRINGPI_H 148 #ifdef HAVE_WIRINGPI_H
151 fprintf(fp, "# Radio controllers 433 MHz.\n");
152 fprintf(fp, "#\n");
153 fprintf(fp, "tx433 %d\n", Config.tx433);
154 fprintf(fp, "\n");
155
156 fprintf(fp, "# LCD display\n"); 149 fprintf(fp, "# LCD display\n");
157 fprintf(fp, "#\n"); 150 fprintf(fp, "#\n");
158 fprintf(fp, "lcd_cols %d\n", Config.lcd_cols); 151 fprintf(fp, "lcd_cols %d\n", Config.lcd_cols);
159 fprintf(fp, "lcd_rows %d\n", Config.lcd_rows); 152 fprintf(fp, "lcd_rows %d\n", Config.lcd_rows);
160 fprintf(fp, "\n"); 153 fprintf(fp, "\n");
166 for (tmp1 = Config.w1therms; tmp1; tmp1 = tmp1->next) { 159 for (tmp1 = Config.w1therms; tmp1; tmp1 = tmp1->next) {
167 fprintf(fp, "w1therm %s %d %s %s\n", tmp1->master, tmp1->bus, tmp1->name, tmp1->alias); 160 fprintf(fp, "w1therm %s %d %s %s\n", tmp1->master, tmp1->bus, tmp1->name, tmp1->alias);
168 } 161 }
169 fprintf(fp, "\n"); 162 fprintf(fp, "\n");
170 163
171 #ifdef HAVE_WIRINGPI_H 164 fprintf(fp, "# Fermenter Units.\n");
172 fprintf(fp, "# RC switches that we want to control.\n");
173 fprintf(fp, "#\n"); 165 fprintf(fp, "#\n");
174 fprintf(fp, "# kwd address alias\n"); 166 for (tmp3 = Config.units; tmp3; tmp3 = tmp3->next) {
175 for (tmp2 = Config.rcswitch; tmp2; tmp2 = tmp2->next) { 167 fprintf(fp, "unit_uid %s\n", tmp3->uid);
176 fprintf(fp, "rcswitch %s %s\n", tmp2->address, tmp2->alias); 168 if (tmp3->name)
177 } 169 fprintf(fp, "unit_name %s\n", tmp3->name);
178 fprintf(fp, "\n"); 170 if (tmp3->volume > 0.0)
179 #endif 171 fprintf(fp, "unit_volume %.1f\n", tmp3->volume);
172 if (tmp3->air_address)
173 fprintf(fp, "unit_air_address %s\n", tmp3->air_address);
174 if (tmp3->beer_address)
175 fprintf(fp, "unit_beer_address %s\n", tmp3->beer_address);
176 if (tmp3->io_address)
177 fprintf(fp, "unit_io_address %s\n", tmp3->io_address);
178 fprintf(fp, "unit_heater_available %s\n", tmp3->heater_available ? "yes":"no");
179 fprintf(fp, "unit_cooler_available %s\n", tmp3->cooler_available ? "yes":"no");
180 fprintf(fp, "unit_fan_available %s\n", tmp3->fan_available ? "yes":"no");
181 fprintf(fp, "unit_light_available %s\n", tmp3->light_available ? "yes":"no");
182 fprintf(fp, "unit_mode %d\n", tmp3->mode);
183 if (tmp3->profile) {
184 fprintf(fp, "unit_profile %s\n", tmp3->profile);
185 fprintf(fp, "unit_prof_started %d\n", (int)tmp3->prof_started);
186 }
187 }
188 fprintf(fp, "\n");
180 189
181 fprintf(fp, "# Control Settings.\n"); 190 fprintf(fp, "# Control Settings.\n");
182 fprintf(fp, "#\n"); 191 fprintf(fp, "#\n");
183 fprintf(fp, "cs_mode %c\n", Config.cs_mode); 192 fprintf(fp, "cs_mode %c\n", Config.cs_mode);
184 fprintf(fp, "cs_beerSet %.1f\n", Config.cs_beerSet); 193 fprintf(fp, "cs_beerSet %.1f\n", Config.cs_beerSet);

mercurial