From 2c3f70a61e7aee9e4b9021548781e19b24695a60 Mon Sep 17 00:00:00 2001 From: jens Date: Wed, 25 Nov 2020 14:46:05 +0100 Subject: [PATCH] - added temperature sensor --- brewpi.py | 4 +- brewpi.ui | 476 +++++++++++++++++++++++++++++++++++++++++++++++++- brewpi_gui.py | 2 + brewpi_win.py | 160 ++++++++++++++++- 4 files changed, 635 insertions(+), 7 deletions(-) diff --git a/brewpi.py b/brewpi.py index 81c87db..0783182 100644 --- a/brewpi.py +++ b/brewpi.py @@ -37,7 +37,7 @@ class TempSensorTask(ATask): while True: temp.set(round(self.sensor.temperature(), 1)) if temp.is_changed(): - await self.send(temp.get()) + await self.send({'Temp': temp.get()}) await asyncio.sleep(self.interval) @@ -191,7 +191,7 @@ if __name__ == '__main__': # {"Heater": {"Activate": 1, "Power": 1000}} # Plant pot = Pot(pot_params) - # pot.connect_theta_changed(sensor.set_fake_temp) + pot.connect_theta_changed(sensor.set_fake_temp) taskmgr.add(PotTask(pot, 0.1, dispatcher.msgio_get("Pot"))) # Heater diff --git a/brewpi.ui b/brewpi.ui index 6e03d9e..f1318fd 100644 --- a/brewpi.ui +++ b/brewpi.ui @@ -489,7 +489,7 @@ 0 10 350 - 353 + 471 @@ -1430,6 +1430,476 @@ + + + + + 0 + 120 + + + + + + + + + 0 + 0 + 0 + + + + + + + 138 + 226 + 52 + + + + + + + 198 + 255 + 143 + + + + + + + 168 + 240 + 97 + + + + + + + 69 + 113 + 26 + + + + + + + 92 + 151 + 34 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 138 + 226 + 52 + + + + + + + 0 + 0 + 0 + + + + + + + 196 + 240 + 153 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 138 + 226 + 52 + + + + + + + 198 + 255 + 143 + + + + + + + 168 + 240 + 97 + + + + + + + 69 + 113 + 26 + + + + + + + 92 + 151 + 34 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 138 + 226 + 52 + + + + + + + 0 + 0 + 0 + + + + + + + 196 + 240 + 153 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 69 + 113 + 26 + + + + + + + 138 + 226 + 52 + + + + + + + 198 + 255 + 143 + + + + + + + 168 + 240 + 97 + + + + + + + 69 + 113 + 26 + + + + + + + 92 + 151 + 34 + + + + + + + 69 + 113 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 69 + 113 + 26 + + + + + + + 138 + 226 + 52 + + + + + + + 138 + 226 + 52 + + + + + + + 0 + 0 + 0 + + + + + + + 138 + 226 + 52 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + QFrame::Box + + + QFrame::Raised + + + false + + + 5 + + + QLCDNumber::Filled + + + 2037.000000000000000 + + + @@ -1458,8 +1928,8 @@ - 390 - 90 + 410 + 70 63 250 diff --git a/brewpi_gui.py b/brewpi_gui.py index 9e109e4..748b822 100644 --- a/brewpi_gui.py +++ b/brewpi_gui.py @@ -46,6 +46,8 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow): async def on_sensor_changed(self, msg): print("on_sensor_changed {}".format(msg)) + if "Temp" in msg: + self.lcdNumber_3.display(str(msg['Temp'])) async def on_heater_changed(self, msg): print("on_heater_changed {}".format(msg)) diff --git a/brewpi_win.py b/brewpi_win.py index 23e004b..401ceb9 100644 --- a/brewpi_win.py +++ b/brewpi_win.py @@ -175,7 +175,7 @@ class Ui_MainWindow(object): self.centralwidget.setObjectName("centralwidget") self.horizontalTabWidget = QtWidgets.QTabWidget(self.centralwidget) self.horizontalTabWidget.setEnabled(True) - self.horizontalTabWidget.setGeometry(QtCore.QRect(0, 10, 350, 353)) + self.horizontalTabWidget.setGeometry(QtCore.QRect(0, 10, 350, 471)) self.horizontalTabWidget.setObjectName("horizontalTabWidget") self.horizontalTabWidgetPage1 = QtWidgets.QWidget() self.horizontalTabWidgetPage1.setObjectName("horizontalTabWidgetPage1") @@ -491,6 +491,162 @@ class Ui_MainWindow(object): self.lcdNumber_2.setProperty("value", 2037.0) self.lcdNumber_2.setObjectName("lcdNumber_2") self.verticalLayout.addWidget(self.lcdNumber_2) + self.lcdNumber_3 = QtWidgets.QLCDNumber(self.horizontalTabWidgetPage1) + self.lcdNumber_3.setMinimumSize(QtCore.QSize(0, 120)) + palette = QtGui.QPalette() + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush) + brush = QtGui.QBrush(QtGui.QColor(138, 226, 52)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush) + brush = QtGui.QBrush(QtGui.QColor(198, 255, 143)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Light, brush) + brush = QtGui.QBrush(QtGui.QColor(168, 240, 97)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Midlight, brush) + brush = QtGui.QBrush(QtGui.QColor(69, 113, 26)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Dark, brush) + brush = QtGui.QBrush(QtGui.QColor(92, 151, 34)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Mid, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.BrightText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(138, 226, 52)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Shadow, brush) + brush = QtGui.QBrush(QtGui.QColor(196, 240, 153)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.AlternateBase, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipBase, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 128)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.PlaceholderText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush) + brush = QtGui.QBrush(QtGui.QColor(138, 226, 52)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush) + brush = QtGui.QBrush(QtGui.QColor(198, 255, 143)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Light, brush) + brush = QtGui.QBrush(QtGui.QColor(168, 240, 97)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Midlight, brush) + brush = QtGui.QBrush(QtGui.QColor(69, 113, 26)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Dark, brush) + brush = QtGui.QBrush(QtGui.QColor(92, 151, 34)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Mid, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.BrightText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(138, 226, 52)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Shadow, brush) + brush = QtGui.QBrush(QtGui.QColor(196, 240, 153)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.AlternateBase, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipBase, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 128)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.PlaceholderText, brush) + brush = QtGui.QBrush(QtGui.QColor(69, 113, 26)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) + brush = QtGui.QBrush(QtGui.QColor(138, 226, 52)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush) + brush = QtGui.QBrush(QtGui.QColor(198, 255, 143)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Light, brush) + brush = QtGui.QBrush(QtGui.QColor(168, 240, 97)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Midlight, brush) + brush = QtGui.QBrush(QtGui.QColor(69, 113, 26)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Dark, brush) + brush = QtGui.QBrush(QtGui.QColor(92, 151, 34)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Mid, brush) + brush = QtGui.QBrush(QtGui.QColor(69, 113, 26)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.BrightText, brush) + brush = QtGui.QBrush(QtGui.QColor(69, 113, 26)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush) + brush = QtGui.QBrush(QtGui.QColor(138, 226, 52)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(138, 226, 52)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Shadow, brush) + brush = QtGui.QBrush(QtGui.QColor(138, 226, 52)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.AlternateBase, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipBase, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 128)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.PlaceholderText, brush) + self.lcdNumber_3.setPalette(palette) + self.lcdNumber_3.setFrameShape(QtWidgets.QFrame.Box) + self.lcdNumber_3.setFrameShadow(QtWidgets.QFrame.Raised) + self.lcdNumber_3.setSmallDecimalPoint(False) + self.lcdNumber_3.setDigitCount(5) + self.lcdNumber_3.setSegmentStyle(QtWidgets.QLCDNumber.Filled) + self.lcdNumber_3.setProperty("value", 2037.0) + self.lcdNumber_3.setObjectName("lcdNumber_3") + self.verticalLayout.addWidget(self.lcdNumber_3) self.horizontalLayout.addLayout(self.verticalLayout) self.horizontalTabWidget.addTab(self.horizontalTabWidgetPage1, "") self.tab = QtWidgets.QWidget() @@ -503,7 +659,7 @@ class Ui_MainWindow(object): self.Thermo.setGeometry(QtCore.QRect(890, 50, 56, 201)) self.Thermo.setObjectName("Thermo") self.Slider = QwtSlider(self.centralwidget) - self.Slider.setGeometry(QtCore.QRect(390, 90, 63, 250)) + self.Slider.setGeometry(QtCore.QRect(410, 70, 63, 250)) self.Slider.setObjectName("Slider") MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow)