Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

\uD83D\uDD17 Reference materials

This is an example of a simple GUI interface with a rasberry pi, displaying data in real time. This should give you and idea of the general architecture that is required to have this project completed

Code Block
import time
import Adafruit_DHT
from PyQt4 import QtCore, QtGui

try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    def _fromUtf8(s):
        return s

try:
    _encoding = QtGui.QApplication.UnicodeUTF8
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig)


class Ui_Room1(object):

    def AffichT(self):  
        sensor=11
        pin=4
        humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
        if temperature is not None:
            print('Temp={0:0.1f}*  Humidity={1:0.1f}%'.format(temperature, humidity))
            return str(temperature)
        else:
            print('Failed to get reading. Try again!')
            sys.exit(1)

    def AffichH(self):            
        sensor=11
        pin=4
        humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
        if humidity is not None:
            return str(humidity)
        else:
            print('Failed to get reading. Try again!')
            sys.exit(1)

    def setupUi(self, Room1):

        Room1.setObjectName(_fromUtf8("Room1"))
        Room1.resize(674, 422)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(Room1.sizePolicy().hasHeightForWidth())
        Room1.setSizePolicy(sizePolicy)
        Room1.setMouseTracking(False)
        Room1.setStyleSheet(_fromUtf8("image: url(:/gradient1/Images/gradient1.png);\n"
"\n"
""))
        self.centralwidget = QtGui.QWidget(Room1)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.centralwidget.sizePolicy().hasHeightForWidth())
       self.centralwidget.setSizePolicy(sizePolicy)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.graphicsView = QtGui.QGraphicsView(self.centralwidget)
        self.graphicsView.setGeometry(QtCore.QRect(610, 30, 41, 41))
        self.graphicsView.setStyleSheet(_fromUtf8("background-color: transparent;\n"
"background-image: url(:/gradient1/Images/logout.png);\n"
"background-repeat: no;"))
        self.graphicsView.setFrameShape(QtGui.QFrame.NoFrame)
        self.graphicsView.setObjectName(_fromUtf8("graphicsView"))
        self.label = QtGui.QLabel(self.centralwidget)
       self.label.setGeometry(QtCore.QRect(270, 50, 131, 31))
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
        self.label.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setPointSize(18)
        font.setBold(True)
        font.setWeight(75)
        self.label.setFont(font)
        self.label.setStyleSheet(_fromUtf8("image : none;\n"
"color: #fff;\n"
"background-color: transparent;"))
        self.label.setObjectName(_fromUtf8("label"))
        self.label_2 = QtGui.QLabel(self.centralwidget)
        self.label_2.setGeometry(QtCore.QRect(140, 170, 101, 61))
        self.label_2.setStyleSheet(_fromUtf8("image: none;\n"
"color: #fff;\n"
"background-color: #347;"))
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.label_3 = QtGui.QLabel(self.centralwidget)
        self.label_3.setGeometry(QtCore.QRect(140, 260, 101, 61))
        self.label_3.setStyleSheet(_fromUtf8("image: none;\n"
"color: #fff;\n"
"background-color: #347;"))
        self.label_3.setObjectName(_fromUtf8("label_3"))
        self.label_4 = QtGui.QLabel(self.centralwidget)
        self.label_4.setGeometry(QtCore.QRect(300, 170, 101, 61))
        self.label_4.setStyleSheet(_fromUtf8("image: none;\n"
"color: #fff;\n"
"background-color: #347;"))
        temp = self.AffichT()
        self.label_4.setText(_fromUtf8(temp+"°"))
        self.label_4.setObjectName(_fromUtf8("label_4"))
        self.label_5 = QtGui.QLabel(self.centralwidget)
        self.label_5.setGeometry(QtCore.QRect(300, 260, 101, 61))
        self.label_5.setStyleSheet(_fromUtf8("image: none;\n"
"color: #fff;\n"
"background-color: #347;"))
        hum = self.AffichH()
        self.label_5.setText(_fromUtf8(hum)+"%")
        self.label_5.setObjectName(_fromUtf8("label_5"))
        Room1.setCentralWidget(self.centralwidget)
        self.retranslateUi(Room1)
        QtCore.QMetaObject.connectSlotsByName(Room1)


    def retranslateUi(self, Room1):
        Room1.setWindowTitle(_translate("Room1", "Parents Room", None))
        self.label.setText(_translate("Room1", "Welcome !", None))
        self.label_2.setText(_translate("Room1", "Température:", None))
        self.label_3.setText(_translate("Room1", "Humidité:", None))


if __name__ == "__main__":
    import sys
    app = QtGui.QApplication(sys.argv)
    Room1 = QtGui.QMainWindow()
    ui = Ui_Room1()
    ui.setupUi(Room1)
    Room1.show()
    sys.exit(app.exec_())`

❓Questions

  • What will the ground station look like? Are we also displaying video data or will that be on a separate interface?

  • Do we want to dockerize this?

...