# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'GUI.ui'
#
# Created by: PyQt5 UI code generator 5.11.3
#
# WARNING! All changes made in this file will be lost!

from Serial import *
from SetPort import *
from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_MainWindow(object):
    def setupUi(self, MainWindow, serial_thread):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(660, 580)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName("gridLayout")
        self.dcmotor_directions = QtWidgets.QGroupBox(self.centralwidget)
        self.dcmotor_directions.setObjectName("dcmotor_directions")
        self.dcmotor_forward = QtWidgets.QRadioButton(self.dcmotor_directions)
        self.dcmotor_forward.setGeometry(QtCore.QRect(10, 20, 82, 17))
        self.dcmotor_forward.setChecked(True)
        self.dcmotor_forward.setObjectName("dcmotor_forward")
        self.dcmotor_reverse = QtWidgets.QRadioButton(self.dcmotor_directions)
        self.dcmotor_reverse.setGeometry(QtCore.QRect(10, 40, 82, 17))
        self.dcmotor_reverse.setObjectName("dcmotor_reverse")
        self.gridLayout.addWidget(self.dcmotor_directions, 2, 2, 1, 1)
        self.stepper_directions = QtWidgets.QGroupBox(self.centralwidget)
        self.stepper_directions.setMinimumSize(QtCore.QSize(100, 75))
        self.stepper_directions.setObjectName("stepper_directions")
        self.stepper_forward = QtWidgets.QRadioButton(self.stepper_directions)
        self.stepper_forward.setGeometry(QtCore.QRect(10, 20, 82, 17))
        self.stepper_forward.setChecked(True)
        self.stepper_forward.setObjectName("stepper_forward")
        self.stepper_reverse = QtWidgets.QRadioButton(self.stepper_directions)
        self.stepper_reverse.setGeometry(QtCore.QRect(10, 40, 82, 17))
        self.stepper_reverse.setObjectName("stepper_reverse")
        self.gridLayout.addWidget(self.stepper_directions, 2, 0, 1, 1)
        self.stepper_position_button = QtWidgets.QPushButton(self.centralwidget)
        self.stepper_position_button.setObjectName("stepper_position_button")
        self.gridLayout.addWidget(self.stepper_position_button, 7, 0, 1, 1)
        self.rcservo_degrees_spin = QtWidgets.QSpinBox(self.centralwidget)
        self.rcservo_degrees_spin.setMaximum(180)
        self.rcservo_degrees_spin.setObjectName("rcservo_degrees_spin")
        self.gridLayout.addWidget(self.rcservo_degrees_spin, 5, 1, 1, 1)
        self.dcmotor_speed_button = QtWidgets.QPushButton(self.centralwidget)
        self.dcmotor_speed_button.setObjectName("dcmotor_speed_button")
        self.gridLayout.addWidget(self.dcmotor_speed_button, 12, 2, 1, 1)
        self.dcmotor_controls_label = QtWidgets.QLabel(self.centralwidget)
        self.dcmotor_controls_label.setObjectName("dcmotor_controls_label")
        self.gridLayout.addWidget(self.dcmotor_controls_label, 1, 2, 1, 1)
        self.rcservo_position_button = QtWidgets.QPushButton(self.centralwidget)
        self.rcservo_position_button.setObjectName("rcservo_position_button")
        self.gridLayout.addWidget(self.rcservo_position_button, 7, 1, 1, 1)
        self.rcservo_controls_label = QtWidgets.QLabel(self.centralwidget)
        self.rcservo_controls_label.setObjectName("rcservo_controls_label")
        self.gridLayout.addWidget(self.rcservo_controls_label, 1, 1, 1, 1)
        self.stepper_controls_label = QtWidgets.QLabel(self.centralwidget)
        self.stepper_controls_label.setObjectName("stepper_controls_label")
        self.gridLayout.addWidget(self.stepper_controls_label, 1, 0, 1, 1)
        self.dcmotor_position_button = QtWidgets.QPushButton(self.centralwidget)
        self.dcmotor_position_button.setObjectName("dcmotor_position_button")
        self.gridLayout.addWidget(self.dcmotor_position_button, 7, 2, 1, 1)
        self.rcservo_lcd_label = QtWidgets.QLabel(self.centralwidget)
        self.rcservo_lcd_label.setObjectName("rcservo_lcd_label")
        self.gridLayout.addWidget(self.rcservo_lcd_label, 13, 1, 1, 1, QtCore.Qt.AlignBottom)
        self.stepper_degrees_label = QtWidgets.QLabel(self.centralwidget)
        self.stepper_degrees_label.setObjectName("stepper_degrees_label")
        self.gridLayout.addWidget(self.stepper_degrees_label, 6, 0, 1, 1, QtCore.Qt.AlignTop)
        self.dcmotor_degrees_spin = QtWidgets.QSpinBox(self.centralwidget)
        self.dcmotor_degrees_spin.setMaximum(9999)
        self.dcmotor_degrees_spin.setObjectName("dcmotor_degrees_spin")
        self.gridLayout.addWidget(self.dcmotor_degrees_spin, 5, 2, 1, 1)
        self.stepper_lcd_label = QtWidgets.QLabel(self.centralwidget)
        self.stepper_lcd_label.setObjectName("stepper_lcd_label")
        self.gridLayout.addWidget(self.stepper_lcd_label, 13, 0, 1, 1, QtCore.Qt.AlignBottom)
        self.spinBox = QtWidgets.QSpinBox(self.centralwidget)
        self.spinBox.setMaximum(360)
        self.spinBox.setObjectName("spinBox")
        self.gridLayout.addWidget(self.spinBox, 8, 2, 1, 1)
        self.dcmotor_degrees_label = QtWidgets.QLabel(self.centralwidget)
        self.dcmotor_degrees_label.setObjectName("dcmotor_degrees_label")
        self.gridLayout.addWidget(self.dcmotor_degrees_label, 6, 2, 1, 1, QtCore.Qt.AlignTop)
        self.stepper_degrees_spin = QtWidgets.QSpinBox(self.centralwidget)
        self.stepper_degrees_spin.setMaximum(9999)
        self.stepper_degrees_spin.setObjectName("stepper_degrees_spin")
        self.gridLayout.addWidget(self.stepper_degrees_spin, 5, 0, 1, 1)
        self.user_control_enable = QtWidgets.QCheckBox(self.centralwidget)
        self.user_control_enable.setChecked(False)
        self.user_control_enable.setObjectName("user_control_enable")
        self.gridLayout.addWidget(self.user_control_enable, 0, 0, 1, 1)
        self.dcmotor_speed_label = QtWidgets.QLabel(self.centralwidget)
        self.dcmotor_speed_label.setObjectName("dcmotor_speed_label")
        self.gridLayout.addWidget(self.dcmotor_speed_label, 9, 2, 1, 1, QtCore.Qt.AlignTop)
        self.dcmotor_lcd_label = QtWidgets.QLabel(self.centralwidget)
        self.dcmotor_lcd_label.setObjectName("dcmotor_lcd_label")
        self.gridLayout.addWidget(self.dcmotor_lcd_label, 13, 2, 1, 1, QtCore.Qt.AlignBottom)
        self.rcservo_angle_label = QtWidgets.QLabel(self.centralwidget)
        self.rcservo_angle_label.setObjectName("rcservo_angle_label")
        self.gridLayout.addWidget(self.rcservo_angle_label, 6, 1, 1, 1, QtCore.Qt.AlignTop)
        self.accelerometer_reading = QtWidgets.QLabel(self.centralwidget)
        font = QtGui.QFont()
        font.setPointSize(14)
        font.setBold(True)
        font.setWeight(75)
        self.accelerometer_reading.setFont(font)
        self.accelerometer_reading.setObjectName("accelerometer_reading")
        self.gridLayout.addWidget(self.accelerometer_reading, 16, 0, 1, 1, QtCore.Qt.AlignHCenter)
        self.potentiometer_reading = QtWidgets.QLabel(self.centralwidget)
        font = QtGui.QFont()
        font.setPointSize(14)
        font.setBold(True)
        font.setWeight(75)
        self.potentiometer_reading.setFont(font)
        self.potentiometer_reading.setObjectName("potentiometer_reading")
        self.gridLayout.addWidget(self.potentiometer_reading, 16, 1, 1, 1, QtCore.Qt.AlignHCenter)
        self.ultrasonic_reading = QtWidgets.QLabel(self.centralwidget)
        font = QtGui.QFont()
        font.setPointSize(14)
        font.setBold(True)
        font.setWeight(75)
        self.ultrasonic_reading.setFont(font)
        self.ultrasonic_reading.setObjectName("ultrasonic_reading")
        self.gridLayout.addWidget(self.ultrasonic_reading, 16, 2, 1, 1, QtCore.Qt.AlignHCenter)
        self.label_4 = QtWidgets.QLabel(self.centralwidget)
        self.label_4.setObjectName("label_4")
        self.gridLayout.addWidget(self.label_4, 15, 0, 1, 1, QtCore.Qt.AlignBottom)
        self.label_5 = QtWidgets.QLabel(self.centralwidget)
        self.label_5.setObjectName("label_5")
        self.gridLayout.addWidget(self.label_5, 15, 1, 1, 1, QtCore.Qt.AlignBottom)
        self.label_6 = QtWidgets.QLabel(self.centralwidget)
        self.label_6.setObjectName("label_6")
        self.gridLayout.addWidget(self.label_6, 15, 2, 1, 1, QtCore.Qt.AlignBottom)
        self.stepper_position = QtWidgets.QLabel(self.centralwidget)
        font = QtGui.QFont()
        font.setPointSize(14)
        font.setBold(True)
        font.setWeight(75)
        self.stepper_position.setFont(font)
        self.stepper_position.setObjectName("stepper_position")
        self.gridLayout.addWidget(self.stepper_position, 14, 0, 1, 1, QtCore.Qt.AlignHCenter)
        self.rcservo_position = QtWidgets.QLabel(self.centralwidget)
        font = QtGui.QFont()
        font.setPointSize(14)
        font.setBold(True)
        font.setWeight(75)
        self.rcservo_position.setFont(font)
        self.rcservo_position.setObjectName("rcservo_position")
        self.gridLayout.addWidget(self.rcservo_position, 14, 1, 1, 1, QtCore.Qt.AlignHCenter)
        self.dcmotor_position = QtWidgets.QLabel(self.centralwidget)
        font = QtGui.QFont()
        font.setPointSize(14)
        font.setBold(True)
        font.setWeight(75)
        self.dcmotor_position.setFont(font)
        self.dcmotor_position.setObjectName("dcmotor_position")
        self.gridLayout.addWidget(self.dcmotor_position, 14, 2, 1, 1, QtCore.Qt.AlignHCenter)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setEnabled(True)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 660, 21))
        self.menubar.setObjectName("menubar")
        self.menuConnect = QtWidgets.QMenu(self.menubar)
        self.menuConnect.setObjectName("menuConnect")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.actionConfigure_Serial_Port = QtWidgets.QAction(MainWindow)
        self.actionConfigure_Serial_Port.setObjectName("actionConfigure_Serial_Port")
        self.menuConnect.addAction(self.actionConfigure_Serial_Port)
        self.menubar.addAction(self.menuConnect.menuAction())

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

        serial_thread.set_output({
            "rcservo_position": self.rcservo_position,
            "stepper_position": self.stepper_position,
            "dcmotor_position": self.dcmotor_position,
            "accelerometer": self.accelerometer_reading,
            "potentiometer": self.potentiometer_reading,
            "ultrasonic":self.ultrasonic_reading
            })
        self.actionConfigure_Serial_Port.triggered.connect(build_show_serial_config(serial_thread))

        self.user_control_enable.stateChanged.connect(serial_thread.build_controls_changed(self.user_control_enable))

        self.stepper_position_button.clicked.connect(serial_thread.build_stepper_command(self.stepper_forward, self.stepper_reverse, self.stepper_degrees_spin))
        self.rcservo_position_button.clicked.connect(serial_thread.build_rcservo_command(self.rcservo_degrees_spin))
        self.dcmotor_position_button.clicked.connect(serial_thread.build_dcmotor_position_command(self.dcmotor_forward, self.dcmotor_reverse, self.dcmotor_degrees_spin))
        self.dcmotor_speed_button.clicked.connect(serial_thread.build_dcmotor_speed_command(self.dcmotor_forward, self.dcmotor_reverse, self.spinBox))

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "Motor Lab Controls"))
        self.dcmotor_directions.setTitle(_translate("MainWindow", "Direction"))
        self.dcmotor_forward.setText(_translate("MainWindow", "Forward"))
        self.dcmotor_reverse.setText(_translate("MainWindow", "Reverse"))
        self.stepper_directions.setTitle(_translate("MainWindow", "Direction"))
        self.stepper_forward.setText(_translate("MainWindow", "Forward"))
        self.stepper_reverse.setText(_translate("MainWindow", "Rerverse"))
        self.stepper_position_button.setText(_translate("MainWindow", "Set Stepper Position"))
        self.dcmotor_speed_button.setText(_translate("MainWindow", "Set DC Motor Speed"))
        self.dcmotor_controls_label.setText(_translate("MainWindow", "DC Motor Controls"))
        self.rcservo_position_button.setText(_translate("MainWindow", "Set Servo Position"))
        self.rcservo_controls_label.setText(_translate("MainWindow", "RC Servo Controls"))
        self.stepper_controls_label.setText(_translate("MainWindow", "Stepper Motor Controls"))
        self.dcmotor_position_button.setText(_translate("MainWindow", "Set DC Motor Position"))
        self.rcservo_lcd_label.setText(_translate("MainWindow", "RC Servo Angle"))
        self.stepper_degrees_label.setText(_translate("MainWindow", "Degrees Rotation"))
        self.stepper_lcd_label.setText(_translate("MainWindow", "Stepper Position"))
        self.dcmotor_degrees_label.setText(_translate("MainWindow", "Degrees Rotation"))
        self.user_control_enable.setText(_translate("MainWindow", "Enable User Input (disables Sensor Control)"))
        self.dcmotor_speed_label.setText(_translate("MainWindow", "Speed"))
        self.dcmotor_lcd_label.setText(_translate("MainWindow", "DC Motor Position"))
        self.rcservo_angle_label.setText(_translate("MainWindow", "Angle"))
        self.accelerometer_reading.setText(_translate("MainWindow", "X: 0.00 Y: 0.00 Z: 0.00"))
        self.potentiometer_reading.setText(_translate("MainWindow", "0V"))
        self.ultrasonic_reading.setText(_translate("MainWindow", "0.00cm"))
        self.label_4.setText(_translate("MainWindow", "Accelerometer Reading"))
        self.label_5.setText(_translate("MainWindow", "Potentiometer Reading"))
        self.label_6.setText(_translate("MainWindow", "Ultrasonic Reading"))
        self.stepper_position.setText(_translate("MainWindow", "0 degrees"))
        self.rcservo_position.setText(_translate("MainWindow", "0 degrees"))
        self.dcmotor_position.setText(_translate("MainWindow", "0 degrees"))
        self.menuConnect.setTitle(_translate("MainWindow", "Connect"))
        self.actionConfigure_Serial_Port.setText(_translate("MainWindow", "Configure Serial Port"))

