thermferm/thermferm.c

changeset 578
d694abd9d809
parent 576
fbc6012405f1
child 582
ba340e00aab2
--- a/thermferm/thermferm.c	Mon Jan 21 17:11:50 2019 +0100
+++ b/thermferm/thermferm.c	Thu Feb 07 14:59:47 2019 +0100
@@ -150,8 +150,6 @@
 #endif
     slcdClear(slcdHandle);
     slcdPosition(slcdHandle, 0, 0);
-
-    syslog(LOG_NOTICE, "from menu %d to menu %d", setupmenu, menu);
     setupmenu = menu;
 
     switch (menu) {
@@ -230,14 +228,27 @@
 				slcdPuts(slcdHandle, "New mode BEER");
 				break;
 
-	case MENU_BEER_TEMP:	
-#ifdef HAVE_WIRINGPI_H				
-				lcdPuts(lcdHandle, "Set beer temp");
+	case MENU_BEER_TEMP_LO:
+#ifdef HAVE_WIRINGPI_H
+				lcdPuts(lcdHandle, "Set beer low");
 				lcdPosition(lcdHandle, 0, 1);
 #endif
-				slcdPuts(slcdHandle, "Set beer temp");
+				slcdPuts(slcdHandle, "Set beer low");
 				slcdPosition(slcdHandle, 0, 1);
+				snprintf(buf, Config.lcd_cols, "Set %.1f", temp_temp);
+#ifdef HAVE_WIRINGPI_H
+				lcdPuts(lcdHandle, buf);
+#endif
+				slcdPuts(slcdHandle, buf);
+				break;
 
+        case MENU_BEER_TEMP_HI:
+#ifdef HAVE_WIRINGPI_H
+				lcdPuts(lcdHandle, "Set beer high");
+				lcdPosition(lcdHandle, 0, 1);
+#endif
+				slcdPuts(slcdHandle, "Set beer high");
+				slcdPosition(slcdHandle, 0, 1);
 				snprintf(buf, Config.lcd_cols, "Set %.1f", temp_temp);
 #ifdef HAVE_WIRINGPI_H
 				lcdPuts(lcdHandle, buf);
@@ -252,12 +263,26 @@
 				slcdPuts(slcdHandle, "New mode FRIDGE");
 				break;
 
-	case MENU_FRIDGE_TEMP:	
-#ifdef HAVE_WIRINGPI_H				
-				lcdPuts(lcdHandle, "Set fridge temp");
+	case MENU_FRIDGE_TEMP_LO:
+#ifdef HAVE_WIRINGPI_H
+				lcdPuts(lcdHandle, "Set fridge low");
 				lcdPosition(lcdHandle, 0, 1);
 #endif
-				slcdPuts(slcdHandle, "Set fridge temp");
+				slcdPuts(slcdHandle, "Set fridge low");
+				slcdPosition(slcdHandle, 0, 1);
+				snprintf(buf, Config.lcd_cols, "Set %.1f", temp_temp);
+#ifdef HAVE_WIRINGPI_H
+				lcdPuts(lcdHandle, buf);
+#endif
+				slcdPuts(slcdHandle, buf);
+				break;
+
+        case MENU_FRIDGE_TEMP_HI:
+#ifdef HAVE_WIRINGPI_H
+				lcdPuts(lcdHandle, "Set fridge high");
+				lcdPosition(lcdHandle, 0, 1);
+#endif
+				slcdPuts(slcdHandle, "Set fridge high");
 				slcdPosition(slcdHandle, 0, 1);
 				snprintf(buf, Config.lcd_cols, "Set %.1f", temp_temp);
 #ifdef HAVE_WIRINGPI_H
@@ -578,8 +603,8 @@
 			    go_menu(MENU_MODE_NONE);
 			if (key == KEY_ENTER) {
 			    if (current_unit->mode == UNITMODE_FRIDGE) {
-				temp_temp = current_unit->fridge_set;
-				go_menu(MENU_FRIDGE_TEMP);
+				temp_temp = current_unit->fridge_set_lo;
+				go_menu(MENU_FRIDGE_TEMP_LO);
 			    } else {
 			    	change_mode(UNITMODE_FRIDGE);
 			    	go_menu(MENU_MODE_FRIDGE);
@@ -587,23 +612,49 @@
 			}
 			break;
 
-	case MENU_FRIDGE_TEMP:
+	case MENU_FRIDGE_TEMP_LO:
+			if (key == KEY_ESCAPE) {
+			    temp_temp = current_unit->fridge_set_hi;
+			    go_menu(MENU_FRIDGE_TEMP_HI);
+			}
+			if (key == KEY_DOWN) {
+			    if (temp_temp > current_unit->temp_set_min)
+				temp_temp -= 0.1;
+			    go_menu(MENU_FRIDGE_TEMP_LO);
+			}
+			if (key == KEY_UP) {
+			    if (temp_temp < current_unit->temp_set_max)
+				temp_temp += 0.1;
+			    go_menu(MENU_FRIDGE_TEMP_LO);
+			}
+			if (key == KEY_CONFIRM) {
+			    if (temp_temp != current_unit->fridge_set_lo) {
+				syslog(LOG_NOTICE, "Fridge temp low changed from %.1f to %.1f from the panel", current_unit->fridge_set_lo, temp_temp);
+				current_unit->fridge_set_lo = temp_temp;
+				current_unit->mqtt_flag |= MQTT_FLAG_DATA;
+			    }
+			    temp_temp = current_unit->fridge_set_hi;
+			    go_menu(MENU_FRIDGE_TEMP_HI);
+			}
+			break;
+
+	case MENU_FRIDGE_TEMP_HI:
 			if (key == KEY_ESCAPE)
 			    go_menu(MENU_MODE_FRIDGE);
 			if (key == KEY_DOWN) {
 			    if (temp_temp > current_unit->temp_set_min)
 				temp_temp -= 0.1;
-			    go_menu(MENU_FRIDGE_TEMP);
+			    go_menu(MENU_FRIDGE_TEMP_HI);
 			}
 			if (key == KEY_UP) {
 			    if (temp_temp < current_unit->temp_set_max)
 				temp_temp += 0.1;
-			    go_menu(MENU_FRIDGE_TEMP);
+			    go_menu(MENU_FRIDGE_TEMP_HI);
 			}
 			if (key == KEY_CONFIRM) {
-			    if (temp_temp != current_unit->fridge_set) {
-				syslog(LOG_NOTICE, "Fridge temperature changed from %.1f to %.1f degrees from the panel", current_unit->fridge_set, temp_temp);
-				current_unit->fridge_set = temp_temp;
+			    if (temp_temp != current_unit->fridge_set_hi) {
+				syslog(LOG_NOTICE, "Fridge temp high changed from %.1f to %.1f from the panel", current_unit->fridge_set_hi, temp_temp);
+				current_unit->fridge_set_hi = temp_temp;
 				current_unit->mqtt_flag |= MQTT_FLAG_DATA;
 			    }
 			    go_menu(MENU_MODE_FRIDGE);
@@ -623,8 +674,8 @@
 			    go_menu(MENU_MODE_FRIDGE);
 			if (key == KEY_ENTER) {
 			    if (current_unit->mode == UNITMODE_BEER) {
-				temp_temp = current_unit->beer_set;
-				go_menu(MENU_BEER_TEMP);
+				temp_temp = current_unit->beer_set_lo;
+				go_menu(MENU_BEER_TEMP_LO);
 			    } else {
 			    	change_mode(UNITMODE_BEER);
 			    	go_menu(MENU_MODE_BEER);
@@ -632,26 +683,52 @@
 			}
 			break;
 
-	case MENU_BEER_TEMP:
+	case MENU_BEER_TEMP_LO:
+			if (key == KEY_ESCAPE) {
+			    temp_temp = current_unit->beer_set_hi;
+			    go_menu(MENU_BEER_TEMP_HI);
+			}
+			if (key == KEY_DOWN) {
+			    if (temp_temp > current_unit->temp_set_min)
+				temp_temp -= 0.1;
+			    go_menu(MENU_BEER_TEMP_LO);
+			}
+			if (key == KEY_UP) {
+			    if (temp_temp < current_unit->temp_set_max)
+				temp_temp += 0.1;
+			    go_menu(MENU_BEER_TEMP_LO);
+			}
+			if (key == KEY_CONFIRM) {
+			    if (temp_temp != current_unit->beer_set_lo ) {
+				syslog(LOG_NOTICE, "Beer temp low changed from %.1f to %.1f from the panel", current_unit->beer_set_lo, temp_temp);
+				current_unit->beer_set_lo = temp_temp;
+				current_unit->mqtt_flag |= MQTT_FLAG_DATA;
+			    }
+			    temp_temp = current_unit->beer_set_hi;
+			    go_menu(MENU_BEER_TEMP_HI);
+			}
+			break;
+
+	case MENU_BEER_TEMP_HI:
 			if (key == KEY_ESCAPE)
 			    go_menu(MENU_MODE_BEER);
 			if (key == KEY_DOWN) {
 			    if (temp_temp > current_unit->temp_set_min)
 				temp_temp -= 0.1;
-			    go_menu(MENU_BEER_TEMP);
+			    go_menu(MENU_BEER_TEMP_HI);
 			}
 			if (key == KEY_UP) {
 			    if (temp_temp < current_unit->temp_set_max)
 				temp_temp += 0.1;
-			    go_menu(MENU_BEER_TEMP);
+			    go_menu(MENU_BEER_TEMP_HI);
 			}
 			if (key == KEY_CONFIRM) {
-			    if (temp_temp != current_unit->beer_set) {
-				syslog(LOG_NOTICE, "Beer temperature changed from %.1f to %.1f degrees from the panel", current_unit->beer_set, temp_temp);
-				current_unit->beer_set = temp_temp;
+			    if (temp_temp != current_unit->beer_set_hi ) {
+				syslog(LOG_NOTICE, "Beer temp high changed from %.1f to %.1f from the panel", current_unit->beer_set_hi, temp_temp);
+				current_unit->beer_set_hi = temp_temp;
 				current_unit->mqtt_flag |= MQTT_FLAG_DATA;
 			    }
-			    go_menu(MENU_MODE_BEER);			    
+			    go_menu(MENU_MODE_BEER);
 			}
 			break;
 
@@ -1037,9 +1114,9 @@
 	    	syslog(LOG_NOTICE, "Starting unit `%s' in profile state %s.", unit->alias, PROFSTATE[unit->prof_state]);
 	    }
 	} else if (unit->mode == UNITMODE_BEER) {
-	    syslog(LOG_NOTICE, "Starting unit `%s' beer cooler at %.1f degrees", unit->alias, unit->beer_set);
+	    syslog(LOG_NOTICE, "Starting unit `%s' beer cooler at %.1f - %.1f degrees", unit->alias, unit->beer_set_lo, unit->beer_set_hi);
 	} else if (unit->mode == UNITMODE_FRIDGE) {
-	    syslog(LOG_NOTICE, "Starting unit `%s' as refridgerator at %.1f degrees", unit->alias, unit->fridge_set);
+	    syslog(LOG_NOTICE, "Starting unit `%s' as refridgerator at %.1f - %.1f degrees", unit->alias, unit->fridge_set_lo, unit->fridge_set_hi);
 	} else if (unit->mode == UNITMODE_NONE) {
 	    syslog(LOG_NOTICE, "Starting unit `%s' in inactive state", unit->alias);
 	} else {
@@ -1588,13 +1665,13 @@
 		     */
 		    unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_NONE;
 		    if (unit->mode == UNITMODE_FRIDGE) {
-			unit->PID_cool->SetP = unit->fridge_set;
-			unit->PID_heat->SetP = unit->fridge_set;
+			unit->PID_cool->SetP = unit->fridge_set_hi;
+			unit->PID_heat->SetP = unit->fridge_set_lo;
 			unit->PID_cool->Input = unit->PID_heat->Input = unit->air_temperature / 1000.0;
 			unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_BOO;
 		    } else if (unit->mode == UNITMODE_BEER) {
-			unit->PID_cool->SetP = unit->beer_set;
-			unit->PID_heat->SetP = unit->beer_set;
+			unit->PID_cool->SetP = unit->beer_set_hi;
+			unit->PID_heat->SetP = unit->beer_set_lo;
 			unit->PID_cool->Input = unit->PID_heat->Input = unit->beer_temperature / 1000.0;
 			unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_AUTO;
 		    } else if (unit->mode == UNITMODE_PROFILE) {
@@ -1810,11 +1887,13 @@
 			LCDstatC = '\3';
 		}
 		LCDspH = LCDspL = 0.0;
-		if (unit->mode == UNITMODE_BEER)
-		    LCDspH = LCDspL = unit->beer_set;
-		else if (unit->mode == UNITMODE_FRIDGE)
-		    LCDspH = LCDspL = unit->fridge_set;
-		else if (unit->mode == UNITMODE_PROFILE) {
+		if (unit->mode == UNITMODE_BEER) {
+		    LCDspH = unit->beer_set_hi;
+		    LCDspL = unit->beer_set_lo;
+		} else if (unit->mode == UNITMODE_FRIDGE) {
+		    LCDspH = unit->fridge_set_hi;
+		    LCDspL = unit->fridge_set_lo;
+		} else if (unit->mode == UNITMODE_PROFILE) {
 		    if (unit->prof_state != PROFILE_OFF) {
 			LCDspL = unit->prof_target_lo;
 			LCDspH = unit->prof_target_hi;

mercurial