228 lcdPuts(lcdHandle, "New mode BEER"); |
226 lcdPuts(lcdHandle, "New mode BEER"); |
229 #endif |
227 #endif |
230 slcdPuts(slcdHandle, "New mode BEER"); |
228 slcdPuts(slcdHandle, "New mode BEER"); |
231 break; |
229 break; |
232 |
230 |
233 case MENU_BEER_TEMP: |
231 case MENU_BEER_TEMP_LO: |
234 #ifdef HAVE_WIRINGPI_H |
232 #ifdef HAVE_WIRINGPI_H |
235 lcdPuts(lcdHandle, "Set beer temp"); |
233 lcdPuts(lcdHandle, "Set beer low"); |
236 lcdPosition(lcdHandle, 0, 1); |
234 lcdPosition(lcdHandle, 0, 1); |
237 #endif |
235 #endif |
238 slcdPuts(slcdHandle, "Set beer temp"); |
236 slcdPuts(slcdHandle, "Set beer low"); |
239 slcdPosition(slcdHandle, 0, 1); |
237 slcdPosition(slcdHandle, 0, 1); |
240 |
|
241 snprintf(buf, Config.lcd_cols, "Set %.1f", temp_temp); |
238 snprintf(buf, Config.lcd_cols, "Set %.1f", temp_temp); |
242 #ifdef HAVE_WIRINGPI_H |
239 #ifdef HAVE_WIRINGPI_H |
243 lcdPuts(lcdHandle, buf); |
240 lcdPuts(lcdHandle, buf); |
244 #endif |
241 #endif |
245 slcdPuts(slcdHandle, buf); |
242 slcdPuts(slcdHandle, buf); |
246 break; |
243 break; |
247 |
244 |
|
245 case MENU_BEER_TEMP_HI: |
|
246 #ifdef HAVE_WIRINGPI_H |
|
247 lcdPuts(lcdHandle, "Set beer high"); |
|
248 lcdPosition(lcdHandle, 0, 1); |
|
249 #endif |
|
250 slcdPuts(slcdHandle, "Set beer high"); |
|
251 slcdPosition(slcdHandle, 0, 1); |
|
252 snprintf(buf, Config.lcd_cols, "Set %.1f", temp_temp); |
|
253 #ifdef HAVE_WIRINGPI_H |
|
254 lcdPuts(lcdHandle, buf); |
|
255 #endif |
|
256 slcdPuts(slcdHandle, buf); |
|
257 break; |
|
258 |
248 case MENU_MODE_FRIDGE: show_mode(); |
259 case MENU_MODE_FRIDGE: show_mode(); |
249 #ifdef HAVE_WIRINGPI_H |
260 #ifdef HAVE_WIRINGPI_H |
250 lcdPuts(lcdHandle, "New mode FRIDGE"); |
261 lcdPuts(lcdHandle, "New mode FRIDGE"); |
251 #endif |
262 #endif |
252 slcdPuts(slcdHandle, "New mode FRIDGE"); |
263 slcdPuts(slcdHandle, "New mode FRIDGE"); |
253 break; |
264 break; |
254 |
265 |
255 case MENU_FRIDGE_TEMP: |
266 case MENU_FRIDGE_TEMP_LO: |
256 #ifdef HAVE_WIRINGPI_H |
267 #ifdef HAVE_WIRINGPI_H |
257 lcdPuts(lcdHandle, "Set fridge temp"); |
268 lcdPuts(lcdHandle, "Set fridge low"); |
258 lcdPosition(lcdHandle, 0, 1); |
269 lcdPosition(lcdHandle, 0, 1); |
259 #endif |
270 #endif |
260 slcdPuts(slcdHandle, "Set fridge temp"); |
271 slcdPuts(slcdHandle, "Set fridge low"); |
|
272 slcdPosition(slcdHandle, 0, 1); |
|
273 snprintf(buf, Config.lcd_cols, "Set %.1f", temp_temp); |
|
274 #ifdef HAVE_WIRINGPI_H |
|
275 lcdPuts(lcdHandle, buf); |
|
276 #endif |
|
277 slcdPuts(slcdHandle, buf); |
|
278 break; |
|
279 |
|
280 case MENU_FRIDGE_TEMP_HI: |
|
281 #ifdef HAVE_WIRINGPI_H |
|
282 lcdPuts(lcdHandle, "Set fridge high"); |
|
283 lcdPosition(lcdHandle, 0, 1); |
|
284 #endif |
|
285 slcdPuts(slcdHandle, "Set fridge high"); |
261 slcdPosition(slcdHandle, 0, 1); |
286 slcdPosition(slcdHandle, 0, 1); |
262 snprintf(buf, Config.lcd_cols, "Set %.1f", temp_temp); |
287 snprintf(buf, Config.lcd_cols, "Set %.1f", temp_temp); |
263 #ifdef HAVE_WIRINGPI_H |
288 #ifdef HAVE_WIRINGPI_H |
264 lcdPuts(lcdHandle, buf); |
289 lcdPuts(lcdHandle, buf); |
265 #endif |
290 #endif |
576 go_menu(MENU_MODE_BEER); |
601 go_menu(MENU_MODE_BEER); |
577 if (key == KEY_UP) |
602 if (key == KEY_UP) |
578 go_menu(MENU_MODE_NONE); |
603 go_menu(MENU_MODE_NONE); |
579 if (key == KEY_ENTER) { |
604 if (key == KEY_ENTER) { |
580 if (current_unit->mode == UNITMODE_FRIDGE) { |
605 if (current_unit->mode == UNITMODE_FRIDGE) { |
581 temp_temp = current_unit->fridge_set; |
606 temp_temp = current_unit->fridge_set_lo; |
582 go_menu(MENU_FRIDGE_TEMP); |
607 go_menu(MENU_FRIDGE_TEMP_LO); |
583 } else { |
608 } else { |
584 change_mode(UNITMODE_FRIDGE); |
609 change_mode(UNITMODE_FRIDGE); |
585 go_menu(MENU_MODE_FRIDGE); |
610 go_menu(MENU_MODE_FRIDGE); |
586 } |
611 } |
587 } |
612 } |
588 break; |
613 break; |
589 |
614 |
590 case MENU_FRIDGE_TEMP: |
615 case MENU_FRIDGE_TEMP_LO: |
|
616 if (key == KEY_ESCAPE) { |
|
617 temp_temp = current_unit->fridge_set_hi; |
|
618 go_menu(MENU_FRIDGE_TEMP_HI); |
|
619 } |
|
620 if (key == KEY_DOWN) { |
|
621 if (temp_temp > current_unit->temp_set_min) |
|
622 temp_temp -= 0.1; |
|
623 go_menu(MENU_FRIDGE_TEMP_LO); |
|
624 } |
|
625 if (key == KEY_UP) { |
|
626 if (temp_temp < current_unit->temp_set_max) |
|
627 temp_temp += 0.1; |
|
628 go_menu(MENU_FRIDGE_TEMP_LO); |
|
629 } |
|
630 if (key == KEY_CONFIRM) { |
|
631 if (temp_temp != current_unit->fridge_set_lo) { |
|
632 syslog(LOG_NOTICE, "Fridge temp low changed from %.1f to %.1f from the panel", current_unit->fridge_set_lo, temp_temp); |
|
633 current_unit->fridge_set_lo = temp_temp; |
|
634 current_unit->mqtt_flag |= MQTT_FLAG_DATA; |
|
635 } |
|
636 temp_temp = current_unit->fridge_set_hi; |
|
637 go_menu(MENU_FRIDGE_TEMP_HI); |
|
638 } |
|
639 break; |
|
640 |
|
641 case MENU_FRIDGE_TEMP_HI: |
591 if (key == KEY_ESCAPE) |
642 if (key == KEY_ESCAPE) |
592 go_menu(MENU_MODE_FRIDGE); |
643 go_menu(MENU_MODE_FRIDGE); |
593 if (key == KEY_DOWN) { |
644 if (key == KEY_DOWN) { |
594 if (temp_temp > current_unit->temp_set_min) |
645 if (temp_temp > current_unit->temp_set_min) |
595 temp_temp -= 0.1; |
646 temp_temp -= 0.1; |
596 go_menu(MENU_FRIDGE_TEMP); |
647 go_menu(MENU_FRIDGE_TEMP_HI); |
597 } |
648 } |
598 if (key == KEY_UP) { |
649 if (key == KEY_UP) { |
599 if (temp_temp < current_unit->temp_set_max) |
650 if (temp_temp < current_unit->temp_set_max) |
600 temp_temp += 0.1; |
651 temp_temp += 0.1; |
601 go_menu(MENU_FRIDGE_TEMP); |
652 go_menu(MENU_FRIDGE_TEMP_HI); |
602 } |
653 } |
603 if (key == KEY_CONFIRM) { |
654 if (key == KEY_CONFIRM) { |
604 if (temp_temp != current_unit->fridge_set) { |
655 if (temp_temp != current_unit->fridge_set_hi) { |
605 syslog(LOG_NOTICE, "Fridge temperature changed from %.1f to %.1f degrees from the panel", current_unit->fridge_set, temp_temp); |
656 syslog(LOG_NOTICE, "Fridge temp high changed from %.1f to %.1f from the panel", current_unit->fridge_set_hi, temp_temp); |
606 current_unit->fridge_set = temp_temp; |
657 current_unit->fridge_set_hi = temp_temp; |
607 current_unit->mqtt_flag |= MQTT_FLAG_DATA; |
658 current_unit->mqtt_flag |= MQTT_FLAG_DATA; |
608 } |
659 } |
609 go_menu(MENU_MODE_FRIDGE); |
660 go_menu(MENU_MODE_FRIDGE); |
610 } |
661 } |
611 break; |
662 break; |
621 } |
672 } |
622 if (key == KEY_UP) |
673 if (key == KEY_UP) |
623 go_menu(MENU_MODE_FRIDGE); |
674 go_menu(MENU_MODE_FRIDGE); |
624 if (key == KEY_ENTER) { |
675 if (key == KEY_ENTER) { |
625 if (current_unit->mode == UNITMODE_BEER) { |
676 if (current_unit->mode == UNITMODE_BEER) { |
626 temp_temp = current_unit->beer_set; |
677 temp_temp = current_unit->beer_set_lo; |
627 go_menu(MENU_BEER_TEMP); |
678 go_menu(MENU_BEER_TEMP_LO); |
628 } else { |
679 } else { |
629 change_mode(UNITMODE_BEER); |
680 change_mode(UNITMODE_BEER); |
630 go_menu(MENU_MODE_BEER); |
681 go_menu(MENU_MODE_BEER); |
631 } |
682 } |
632 } |
683 } |
633 break; |
684 break; |
634 |
685 |
635 case MENU_BEER_TEMP: |
686 case MENU_BEER_TEMP_LO: |
|
687 if (key == KEY_ESCAPE) { |
|
688 temp_temp = current_unit->beer_set_hi; |
|
689 go_menu(MENU_BEER_TEMP_HI); |
|
690 } |
|
691 if (key == KEY_DOWN) { |
|
692 if (temp_temp > current_unit->temp_set_min) |
|
693 temp_temp -= 0.1; |
|
694 go_menu(MENU_BEER_TEMP_LO); |
|
695 } |
|
696 if (key == KEY_UP) { |
|
697 if (temp_temp < current_unit->temp_set_max) |
|
698 temp_temp += 0.1; |
|
699 go_menu(MENU_BEER_TEMP_LO); |
|
700 } |
|
701 if (key == KEY_CONFIRM) { |
|
702 if (temp_temp != current_unit->beer_set_lo ) { |
|
703 syslog(LOG_NOTICE, "Beer temp low changed from %.1f to %.1f from the panel", current_unit->beer_set_lo, temp_temp); |
|
704 current_unit->beer_set_lo = temp_temp; |
|
705 current_unit->mqtt_flag |= MQTT_FLAG_DATA; |
|
706 } |
|
707 temp_temp = current_unit->beer_set_hi; |
|
708 go_menu(MENU_BEER_TEMP_HI); |
|
709 } |
|
710 break; |
|
711 |
|
712 case MENU_BEER_TEMP_HI: |
636 if (key == KEY_ESCAPE) |
713 if (key == KEY_ESCAPE) |
637 go_menu(MENU_MODE_BEER); |
714 go_menu(MENU_MODE_BEER); |
638 if (key == KEY_DOWN) { |
715 if (key == KEY_DOWN) { |
639 if (temp_temp > current_unit->temp_set_min) |
716 if (temp_temp > current_unit->temp_set_min) |
640 temp_temp -= 0.1; |
717 temp_temp -= 0.1; |
641 go_menu(MENU_BEER_TEMP); |
718 go_menu(MENU_BEER_TEMP_HI); |
642 } |
719 } |
643 if (key == KEY_UP) { |
720 if (key == KEY_UP) { |
644 if (temp_temp < current_unit->temp_set_max) |
721 if (temp_temp < current_unit->temp_set_max) |
645 temp_temp += 0.1; |
722 temp_temp += 0.1; |
646 go_menu(MENU_BEER_TEMP); |
723 go_menu(MENU_BEER_TEMP_HI); |
647 } |
724 } |
648 if (key == KEY_CONFIRM) { |
725 if (key == KEY_CONFIRM) { |
649 if (temp_temp != current_unit->beer_set) { |
726 if (temp_temp != current_unit->beer_set_hi ) { |
650 syslog(LOG_NOTICE, "Beer temperature changed from %.1f to %.1f degrees from the panel", current_unit->beer_set, temp_temp); |
727 syslog(LOG_NOTICE, "Beer temp high changed from %.1f to %.1f from the panel", current_unit->beer_set_hi, temp_temp); |
651 current_unit->beer_set = temp_temp; |
728 current_unit->beer_set_hi = temp_temp; |
652 current_unit->mqtt_flag |= MQTT_FLAG_DATA; |
729 current_unit->mqtt_flag |= MQTT_FLAG_DATA; |
653 } |
730 } |
654 go_menu(MENU_MODE_BEER); |
731 go_menu(MENU_MODE_BEER); |
655 } |
732 } |
656 break; |
733 break; |
657 |
734 |
658 case MENU_MODE_PROFILE: |
735 case MENU_MODE_PROFILE: |
659 if (key == KEY_ESCAPE) |
736 if (key == KEY_ESCAPE) |
1035 syslog(LOG_NOTICE, "Starting unit `%s' in profile mode, no profile defined.", unit->alias); |
1112 syslog(LOG_NOTICE, "Starting unit `%s' in profile mode, no profile defined.", unit->alias); |
1036 else { |
1113 else { |
1037 syslog(LOG_NOTICE, "Starting unit `%s' in profile state %s.", unit->alias, PROFSTATE[unit->prof_state]); |
1114 syslog(LOG_NOTICE, "Starting unit `%s' in profile state %s.", unit->alias, PROFSTATE[unit->prof_state]); |
1038 } |
1115 } |
1039 } else if (unit->mode == UNITMODE_BEER) { |
1116 } else if (unit->mode == UNITMODE_BEER) { |
1040 syslog(LOG_NOTICE, "Starting unit `%s' beer cooler at %.1f degrees", unit->alias, unit->beer_set); |
1117 syslog(LOG_NOTICE, "Starting unit `%s' beer cooler at %.1f - %.1f degrees", unit->alias, unit->beer_set_lo, unit->beer_set_hi); |
1041 } else if (unit->mode == UNITMODE_FRIDGE) { |
1118 } else if (unit->mode == UNITMODE_FRIDGE) { |
1042 syslog(LOG_NOTICE, "Starting unit `%s' as refridgerator at %.1f degrees", unit->alias, unit->fridge_set); |
1119 syslog(LOG_NOTICE, "Starting unit `%s' as refridgerator at %.1f - %.1f degrees", unit->alias, unit->fridge_set_lo, unit->fridge_set_hi); |
1043 } else if (unit->mode == UNITMODE_NONE) { |
1120 } else if (unit->mode == UNITMODE_NONE) { |
1044 syslog(LOG_NOTICE, "Starting unit `%s' in inactive state", unit->alias); |
1121 syslog(LOG_NOTICE, "Starting unit `%s' in inactive state", unit->alias); |
1045 } else { |
1122 } else { |
1046 syslog(LOG_NOTICE, "Starting unit `%s' in off state", unit->alias); |
1123 syslog(LOG_NOTICE, "Starting unit `%s' in off state", unit->alias); |
1047 } |
1124 } |
1586 /* |
1663 /* |
1587 * Set both PID's to their input values. |
1664 * Set both PID's to their input values. |
1588 */ |
1665 */ |
1589 unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_NONE; |
1666 unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_NONE; |
1590 if (unit->mode == UNITMODE_FRIDGE) { |
1667 if (unit->mode == UNITMODE_FRIDGE) { |
1591 unit->PID_cool->SetP = unit->fridge_set; |
1668 unit->PID_cool->SetP = unit->fridge_set_hi; |
1592 unit->PID_heat->SetP = unit->fridge_set; |
1669 unit->PID_heat->SetP = unit->fridge_set_lo; |
1593 unit->PID_cool->Input = unit->PID_heat->Input = unit->air_temperature / 1000.0; |
1670 unit->PID_cool->Input = unit->PID_heat->Input = unit->air_temperature / 1000.0; |
1594 unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_BOO; |
1671 unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_BOO; |
1595 } else if (unit->mode == UNITMODE_BEER) { |
1672 } else if (unit->mode == UNITMODE_BEER) { |
1596 unit->PID_cool->SetP = unit->beer_set; |
1673 unit->PID_cool->SetP = unit->beer_set_hi; |
1597 unit->PID_heat->SetP = unit->beer_set; |
1674 unit->PID_heat->SetP = unit->beer_set_lo; |
1598 unit->PID_cool->Input = unit->PID_heat->Input = unit->beer_temperature / 1000.0; |
1675 unit->PID_cool->Input = unit->PID_heat->Input = unit->beer_temperature / 1000.0; |
1599 unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_AUTO; |
1676 unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_AUTO; |
1600 } else if (unit->mode == UNITMODE_PROFILE) { |
1677 } else if (unit->mode == UNITMODE_PROFILE) { |
1601 double usetemp; |
1678 double usetemp; |
1602 unit->PID_cool->SetP = unit->prof_target_hi; |
1679 unit->PID_cool->SetP = unit->prof_target_hi; |