thermferm/thermferm.c

changeset 693
3518c07737d8
parent 678
cc49115e769e
child 714
24749c296a50
equal deleted inserted replaced
692:6d97eb820cc1 693:3518c07737d8
1031 1031
1032 // unit->mqtt_flag &= ~MQTT_FLAG_DATA; 1032 // unit->mqtt_flag &= ~MQTT_FLAG_DATA;
1033 unit->alarm_flag = 0; 1033 unit->alarm_flag = 0;
1034 1034
1035 if (unit->air_address) { 1035 if (unit->air_address) {
1036 rc = device_in(unit->air_address, &temp); 1036 unit->air_state = rc = device_in(unit->air_address, &temp);
1037 if (rc == DEVPRESENT_YES) { 1037 if (rc == DEVPRESENT_YES) {
1038 if (unit->air_temperature != temp) { 1038 if (unit->air_temperature != temp) {
1039 unit->mqtt_flag |= MQTT_FLAG_DATA; 1039 unit->mqtt_flag |= MQTT_FLAG_DATA;
1040 } 1040 }
1041 unit->air_temperature = temp; 1041 unit->air_temperature = temp;
1042 unit->air_state = 0; 1042 }
1043 } else if (rc == DEVPRESENT_ERROR) { 1043 } else {
1044 unit->air_state = 1; 1044 unit->air_state = DEVPRESENT_NO;
1045 } else {
1046 unit->air_state = 2;
1047 }
1048 } 1045 }
1049 1046
1050 if (unit->beer_address) { 1047 if (unit->beer_address) {
1051 rc = device_in(unit->beer_address, &temp); 1048 rc = device_in(unit->beer_address, &temp);
1052 if ((rc == DEVPRESENT_NO) && unit->beer_address2) { 1049 if ((rc == DEVPRESENT_NO) && unit->beer_address2) {
1053 /* Read alternative sensor */ 1050 /* Read alternative sensor */
1054 rc = device_in(unit->beer_address2, &temp); 1051 rc = device_in(unit->beer_address2, &temp);
1055 } 1052 }
1053 unit->beer_state = rc;
1056 if (rc == DEVPRESENT_YES) { 1054 if (rc == DEVPRESENT_YES) {
1057 if (unit->beer_temperature != temp) { 1055 if (unit->beer_temperature != temp) {
1058 unit->mqtt_flag |= MQTT_FLAG_DATA; 1056 unit->mqtt_flag |= MQTT_FLAG_DATA;
1059 } 1057 }
1060 unit->beer_temperature = temp; 1058 unit->beer_temperature = temp;
1061 unit->beer_state = 0; 1059 }
1062 } else if (rc == DEVPRESENT_ERROR) { 1060 } else {
1063 unit->beer_state = 1; 1061 unit->beer_state = DEVPRESENT_NO;
1064 } else {
1065 unit->beer_state = 2;
1066 }
1067 } 1062 }
1068 1063
1069 if (unit->chiller_address) { 1064 if (unit->chiller_address) {
1070 rc = device_in(unit->chiller_address, &temp); 1065 unit->chiller_state = rc = device_in(unit->chiller_address, &temp);
1071 if (rc == DEVPRESENT_YES) { 1066 if (rc == DEVPRESENT_YES) {
1072 if (unit->chiller_temperature != temp) { 1067 if (unit->chiller_temperature != temp) {
1073 unit->mqtt_flag |= MQTT_FLAG_DATA; 1068 unit->mqtt_flag |= MQTT_FLAG_DATA;
1074 } 1069 }
1075 unit->chiller_temperature = temp; 1070 unit->chiller_temperature = temp;
1076 unit->chiller_state = 0; 1071 }
1077 } else if (rc == DEVPRESENT_ERROR) { 1072 } else {
1078 unit->chiller_state = 1; 1073 unit->chiller_state = DEVPRESENT_NO;
1079 } else {
1080 unit->chiller_state = 2;
1081 }
1082 } 1074 }
1083 1075
1084 /* 1076 /*
1085 * Unit door state, default is closed. 1077 * Unit door state, default is closed.
1086 */ 1078 */
1731 1723
1732 pthread_mutex_lock(&mutexes[LOCK_LCD]); 1724 pthread_mutex_lock(&mutexes[LOCK_LCD]);
1733 lcd_buf_write(row, "Room temp N/A "); 1725 lcd_buf_write(row, "Room temp N/A ");
1734 pthread_mutex_unlock(&mutexes[LOCK_LCD]); 1726 pthread_mutex_unlock(&mutexes[LOCK_LCD]);
1735 int updateHT = 0; 1727 int updateHT = 0;
1736 if (Config.temp_address) { 1728 if (Config.temp_uuid) {
1737 rc = device_in(Config.temp_address, &temp); 1729 Config.temp_state = rc = device_in(Config.temp_uuid, &temp);
1738 if (rc == DEVPRESENT_YES) { 1730 if (rc == DEVPRESENT_YES) {
1739 if (Config.temp_value != temp) 1731 if (Config.temp_value != temp)
1740 updateHT = 1; 1732 updateHT = 1;
1741 Config.temp_value = temp; 1733 Config.temp_value = temp;
1742 Config.temp_state = 0;
1743 pthread_mutex_lock(&mutexes[LOCK_LCD]); 1734 pthread_mutex_lock(&mutexes[LOCK_LCD]);
1744 lcd_buf_write(row, "Room temp %.1f%c ", Config.temp_value / 1000.0, 0x01); 1735 lcd_buf_write(row, "Room temp %.1f%c ", Config.temp_value / 1000.0, 0x01);
1745 pthread_mutex_unlock(&mutexes[LOCK_LCD]); 1736 pthread_mutex_unlock(&mutexes[LOCK_LCD]);
1746 } else if (rc == DEVPRESENT_ERROR) {
1747 Config.temp_state = 1;
1748 } else {
1749 Config.temp_state = 2;
1750 } 1737 }
1751 mDelay(10); 1738 mDelay(10);
1752 } 1739 }
1753 row++; 1740 row++;
1754 1741
1755 pthread_mutex_lock(&mutexes[LOCK_LCD]); 1742 pthread_mutex_lock(&mutexes[LOCK_LCD]);
1756 lcd_buf_write(row, " Humidity N/A "); 1743 lcd_buf_write(row, " Humidity N/A ");
1757 pthread_mutex_unlock(&mutexes[LOCK_LCD]); 1744 pthread_mutex_unlock(&mutexes[LOCK_LCD]);
1758 if (Config.hum_address) { 1745 if (Config.hum_uuid) {
1759 rc = device_in(Config.hum_address, &temp); 1746 Config.hum_state = rc = device_in(Config.hum_uuid, &temp);
1760 if (rc == DEVPRESENT_YES) { 1747 if (rc == DEVPRESENT_YES) {
1761 if (Config.hum_value != temp) 1748 if (Config.hum_value != temp)
1762 updateHT = 1; 1749 updateHT = 1;
1763 Config.hum_value = temp; 1750 Config.hum_value = temp;
1764 Config.hum_state = 0;
1765 pthread_mutex_lock(&mutexes[LOCK_LCD]); 1751 pthread_mutex_lock(&mutexes[LOCK_LCD]);
1766 lcd_buf_write(row, " Humidity %.1f%% ", Config.hum_value / 1000.0); 1752 lcd_buf_write(row, " Humidity %.1f%% ", Config.hum_value / 1000.0);
1767 pthread_mutex_unlock(&mutexes[LOCK_LCD]); 1753 pthread_mutex_unlock(&mutexes[LOCK_LCD]);
1768 } else if (rc == DEVPRESENT_ERROR) {
1769 Config.hum_state = 1;
1770 } else {
1771 Config.hum_state = 2;
1772 } 1754 }
1773 mDelay(10); 1755 mDelay(10);
1774 } 1756 }
1775 row++; 1757 row++;
1776 1758

mercurial