Example #1
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.ui = Ui_Dialog_accelerometer()
        self.ui.setupUi(self)

        try:
            self.linkbot = linkbot.CLinkbot('locl')
        except:
            QtGui.QMessageBox.warning(
                self, "Error",
                "Could not connect to Linkbot. Please make sure the Linkbot is "
                "plugged into the computer with a working Micro-USB cable.")
            raise

        for slider in (
                self.ui.verticalSlider_1,
                self.ui.verticalSlider_2,
                self.ui.verticalSlider_3,
        ):
            slider.setMaximum(360)

        # Connect button
        self.ui.pushButton.clicked.connect(self.close)

        self.linkbot.enableAccelerometerEvents(self.accelerometerEvent_)
        self.accelerometerSignal.connect(self.accelerometerEvent)
Example #2
0
class AccelerometerDialog(QtGui.QDialog):
    accelerometerSignal = QtCore.pyqtSignal(float, float, float, int)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.ui = Ui_Dialog_accelerometer()
        self.ui.setupUi(self)

        try:
            self.linkbot = linkbot.CLinkbot('locl')
        except:
            QtGui.QMessageBox.warning(
                self, "Error",
                "Could not connect to Linkbot. Please make sure the Linkbot is "
                "plugged into the computer with a working Micro-USB cable.")
            raise

        for slider in (
                self.ui.verticalSlider_1,
                self.ui.verticalSlider_2,
                self.ui.verticalSlider_3,
        ):
            slider.setMaximum(360)

        # Connect button
        self.ui.pushButton.clicked.connect(self.close)

        self.linkbot.enableAccelerometerEvents(self.accelerometerEvent_)
        self.accelerometerSignal.connect(self.accelerometerEvent)

    def __del__(self):
        self.linkbot.disableAccelerometerEvents()

    def accelerometerEvent_(self, x, y, z, timestamp):
        self.accelerometerSignal.emit(x, y, z, timestamp)

    def accelerometerEvent(self, x, y, z, timestamp):
        accels = [x, y, z]
        sliders = [
            self.ui.verticalSlider_1,
            self.ui.verticalSlider_2,
            self.ui.verticalSlider_3,
        ]
        labels = [
            self.ui.label_1,
            self.ui.label_2,
            self.ui.label_3,
        ]
        for a, s, l in zip(accels, sliders, labels):
            s.setValue(a * 100)
            l.setText('{0:.2f}'.format(a))

    def close(self):
        self.done(0)
class AccelerometerDialog(QtGui.QDialog):
    accelerometerSignal = QtCore.pyqtSignal(float, float, float, int)
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.ui = Ui_Dialog_accelerometer()
        self.ui.setupUi(self)

        try:
            self.linkbot = linkbot.CLinkbot('locl')
        except:
            QtGui.QMessageBox.warning(self, "Error",
                "Could not connect to Linkbot. Please make sure the Linkbot is "
                "plugged into the computer with a working Micro-USB cable." )
            raise 

        for slider in ( self.ui.verticalSlider_1,
                        self.ui.verticalSlider_2,
                        self.ui.verticalSlider_3, ):
            slider.setMaximum(360)

        # Connect button
        self.ui.pushButton.clicked.connect(self.close)

        self.linkbot.enableAccelerometerEvents(self.accelerometerEvent_)
        self.accelerometerSignal.connect(self.accelerometerEvent)

    def __del__(self):
        self.linkbot.disableAccelerometerEvents()

    def accelerometerEvent_(self, x, y, z, timestamp):
        self.accelerometerSignal.emit(x, y, z, timestamp)

    def accelerometerEvent(self, x, y, z, timestamp):
        accels = [x,y,z]
        sliders = [ self.ui.verticalSlider_1,
                    self.ui.verticalSlider_2,
                    self.ui.verticalSlider_3, ]
        labels = [ self.ui.label_1, 
                   self.ui.label_2, 
                   self.ui.label_3, ]
        for a, s, l in zip(accels, sliders, labels):
            s.setValue(a*100)
            l.setText('{0:.2f}'.format(a))

    def close(self):
        self.done(0)
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.ui = Ui_Dialog_accelerometer()
        self.ui.setupUi(self)

        try:
            self.linkbot = linkbot.CLinkbot('locl')
        except:
            QtGui.QMessageBox.warning(self, "Error",
                "Could not connect to Linkbot. Please make sure the Linkbot is "
                "plugged into the computer with a working Micro-USB cable." )
            raise 

        for slider in ( self.ui.verticalSlider_1,
                        self.ui.verticalSlider_2,
                        self.ui.verticalSlider_3, ):
            slider.setMaximum(360)

        # Connect button
        self.ui.pushButton.clicked.connect(self.close)

        self.linkbot.enableAccelerometerEvents(self.accelerometerEvent_)
        self.accelerometerSignal.connect(self.accelerometerEvent)