Updated code and Tutorial.pdf
This commit is contained in:
a838557765 2020-03-03 17:39:01 +08:00
parent ee8fca1e23
commit f14021b98a
12 changed files with 489 additions and 448 deletions

View File

@ -1,30 +1,16 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'F:/GUO/test/qss/Client_Ui.ui'
# Form implementation generated from reading ui file 'C:\Users\Freenove\Desktop\树莓派四轮车项目\四轮车python3+pyqt5\Client_Ui.ui'
#
# Created by: PyQt4 UI code generator 4.11.4
# Created by: PyQt5 UI code generator 5.11.3
#
# WARNING! All changes made in this file will be lost!
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)
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Client(object):
def setupUi(self, Client):
Client.setObjectName(_fromUtf8("Client"))
Client.setObjectName("Client")
Client.resize(760, 610)
palette = QtGui.QPalette()
brush = QtGui.QBrush(QtGui.QColor(72, 72, 72))
@ -56,10 +42,10 @@ class Ui_Client(object):
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush)
Client.setPalette(palette)
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setPointSize(14)
font.setFamily("3ds")
font.setPointSize(10)
Client.setFont(font)
Client.setStyleSheet(_fromUtf8("QWidget{\n"
Client.setStyleSheet("QWidget{\n"
"background:#484848;\n"
"}\n"
"QAbstractButton{\n"
@ -160,330 +146,322 @@ class Ui_Client(object):
"border-radius:6px;\n"
"background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5,stop:0.6 #565656,stop:0.8 #565656);\n"
"}\n"
""))
self.Btn_ForWard = QtGui.QPushButton(Client)
self.Btn_ForWard.setGeometry(QtCore.QRect(120, 450, 90, 30))
"")
self.Btn_ForWard = QtWidgets.QPushButton(Client)
self.Btn_ForWard.setGeometry(QtCore.QRect(120, 460, 90, 30))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.Btn_ForWard.setFont(font)
self.Btn_ForWard.setStyleSheet(_fromUtf8(""))
self.Btn_ForWard.setObjectName(_fromUtf8("Btn_ForWard"))
self.name = QtGui.QLabel(Client)
self.Btn_ForWard.setStyleSheet("")
self.Btn_ForWard.setObjectName("Btn_ForWard")
self.name = QtWidgets.QLabel(Client)
self.name.setGeometry(QtCore.QRect(0, 1, 660, 40))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(28)
font.setBold(True)
font.setWeight(75)
font.setBold(False)
font.setWeight(50)
self.name.setFont(font)
self.name.setStyleSheet(_fromUtf8(""))
self.name.setObjectName(_fromUtf8("name"))
self.Btn_Turn_Left = QtGui.QPushButton(Client)
self.Btn_Turn_Left.setGeometry(QtCore.QRect(10, 500, 90, 30))
self.name.setStyleSheet("")
self.name.setObjectName("name")
self.Btn_Turn_Left = QtWidgets.QPushButton(Client)
self.Btn_Turn_Left.setGeometry(QtCore.QRect(10, 510, 90, 30))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.Btn_Turn_Left.setFont(font)
self.Btn_Turn_Left.setStyleSheet(_fromUtf8(""))
self.Btn_Turn_Left.setObjectName(_fromUtf8("Btn_Turn_Left"))
self.Btn_BackWard = QtGui.QPushButton(Client)
self.Btn_BackWard.setGeometry(QtCore.QRect(120, 550, 90, 30))
self.Btn_Turn_Left.setStyleSheet("")
self.Btn_Turn_Left.setObjectName("Btn_Turn_Left")
self.Btn_BackWard = QtWidgets.QPushButton(Client)
self.Btn_BackWard.setGeometry(QtCore.QRect(120, 560, 90, 30))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.Btn_BackWard.setFont(font)
self.Btn_BackWard.setStyleSheet(_fromUtf8(""))
self.Btn_BackWard.setObjectName(_fromUtf8("Btn_BackWard"))
self.Btn_Tracking_Faces = QtGui.QPushButton(Client)
self.Btn_Tracking_Faces.setGeometry(QtCore.QRect(240, 450, 90, 30))
self.Btn_BackWard.setStyleSheet("")
self.Btn_BackWard.setObjectName("Btn_BackWard")
self.Btn_Turn_Right = QtWidgets.QPushButton(Client)
self.Btn_Turn_Right.setGeometry(QtCore.QRect(230, 510, 90, 30))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setPointSize(10)
self.Btn_Tracking_Faces.setFont(font)
self.Btn_Tracking_Faces.setStyleSheet(_fromUtf8(""))
self.Btn_Tracking_Faces.setObjectName(_fromUtf8("Btn_Tracking_Faces"))
self.Btn_Turn_Right = QtGui.QPushButton(Client)
self.Btn_Turn_Right.setGeometry(QtCore.QRect(240, 500, 90, 30))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.Btn_Turn_Right.setFont(font)
self.Btn_Turn_Right.setStyleSheet(_fromUtf8(""))
self.Btn_Turn_Right.setObjectName(_fromUtf8("Btn_Turn_Right"))
self.Btn_Video = QtGui.QPushButton(Client)
self.Btn_Video.setGeometry(QtCore.QRect(240, 380, 90, 30))
self.Btn_Turn_Right.setStyleSheet("")
self.Btn_Turn_Right.setObjectName("Btn_Turn_Right")
self.Btn_Video = QtWidgets.QPushButton(Client)
self.Btn_Video.setGeometry(QtCore.QRect(230, 380, 90, 30))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.Btn_Video.setFont(font)
self.Btn_Video.setStyleSheet(_fromUtf8(""))
self.Btn_Video.setObjectName(_fromUtf8("Btn_Video"))
self.label_Video = QtGui.QLabel(Client)
self.Btn_Video.setStyleSheet("")
self.Btn_Video.setObjectName("Btn_Video")
self.label_Video = QtWidgets.QLabel(Client)
self.label_Video.setGeometry(QtCore.QRect(1, 42, 400, 300))
self.label_Video.setText(_fromUtf8(""))
self.label_Video.setObjectName(_fromUtf8("label_Video"))
self.Btn_Down = QtGui.QPushButton(Client)
self.Btn_Down.setGeometry(QtCore.QRect(510, 480, 75, 30))
self.label_Video.setText("")
self.label_Video.setObjectName("label_Video")
self.Btn_Down = QtWidgets.QPushButton(Client)
self.Btn_Down.setGeometry(QtCore.QRect(510, 490, 75, 30))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.Btn_Down.setFont(font)
self.Btn_Down.setStyleSheet(_fromUtf8(""))
self.Btn_Down.setObjectName(_fromUtf8("Btn_Down"))
self.Btn_Left = QtGui.QPushButton(Client)
self.Btn_Left.setGeometry(QtCore.QRect(440, 450, 75, 30))
self.Btn_Down.setStyleSheet("")
self.Btn_Down.setObjectName("Btn_Down")
self.Btn_Left = QtWidgets.QPushButton(Client)
self.Btn_Left.setGeometry(QtCore.QRect(440, 460, 75, 30))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.Btn_Left.setFont(font)
self.Btn_Left.setStyleSheet(_fromUtf8(""))
self.Btn_Left.setObjectName(_fromUtf8("Btn_Left"))
self.Btn_Home = QtGui.QPushButton(Client)
self.Btn_Home.setGeometry(QtCore.QRect(510, 450, 75, 30))
self.Btn_Left.setStyleSheet("")
self.Btn_Left.setObjectName("Btn_Left")
self.Btn_Home = QtWidgets.QPushButton(Client)
self.Btn_Home.setGeometry(QtCore.QRect(510, 460, 75, 30))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.Btn_Home.setFont(font)
self.Btn_Home.setStyleSheet(_fromUtf8(""))
self.Btn_Home.setObjectName(_fromUtf8("Btn_Home"))
self.Btn_Up = QtGui.QPushButton(Client)
self.Btn_Up.setGeometry(QtCore.QRect(510, 420, 75, 30))
self.Btn_Home.setStyleSheet("")
self.Btn_Home.setObjectName("Btn_Home")
self.Btn_Up = QtWidgets.QPushButton(Client)
self.Btn_Up.setGeometry(QtCore.QRect(510, 430, 75, 30))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.Btn_Up.setFont(font)
self.Btn_Up.setStyleSheet(_fromUtf8(""))
self.Btn_Up.setObjectName(_fromUtf8("Btn_Up"))
self.Btn_Right = QtGui.QPushButton(Client)
self.Btn_Right.setGeometry(QtCore.QRect(580, 450, 75, 30))
self.Btn_Up.setStyleSheet("")
self.Btn_Up.setObjectName("Btn_Up")
self.Btn_Right = QtWidgets.QPushButton(Client)
self.Btn_Right.setGeometry(QtCore.QRect(580, 460, 75, 30))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.Btn_Right.setFont(font)
self.Btn_Right.setStyleSheet(_fromUtf8(""))
self.Btn_Right.setObjectName(_fromUtf8("Btn_Right"))
self.Window_Close = QtGui.QPushButton(Client)
self.Btn_Right.setStyleSheet("")
self.Btn_Right.setObjectName("Btn_Right")
self.Window_Close = QtWidgets.QPushButton(Client)
self.Window_Close.setGeometry(QtCore.QRect(710, 1, 50, 40))
self.Window_Close.setObjectName(_fromUtf8("Window_Close"))
self.IP = QtGui.QLineEdit(Client)
self.Window_Close.setObjectName("Window_Close")
self.IP = QtWidgets.QLineEdit(Client)
self.IP.setGeometry(QtCore.QRect(10, 380, 101, 30))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.IP.setFont(font)
self.IP.setStyleSheet(_fromUtf8(""))
self.IP.setObjectName(_fromUtf8("IP"))
self.Btn_Connect = QtGui.QPushButton(Client)
self.IP.setStyleSheet("")
self.IP.setObjectName("IP")
self.Btn_Connect = QtWidgets.QPushButton(Client)
self.Btn_Connect.setGeometry(QtCore.QRect(120, 380, 90, 30))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.Btn_Connect.setFont(font)
self.Btn_Connect.setObjectName(_fromUtf8("Btn_Connect"))
self.checkBox_Led1 = QtGui.QCheckBox(Client)
self.Btn_Connect.setObjectName("Btn_Connect")
self.checkBox_Led1 = QtWidgets.QCheckBox(Client)
self.checkBox_Led1.setGeometry(QtCore.QRect(420, 120, 91, 31))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.checkBox_Led1.setFont(font)
self.checkBox_Led1.setObjectName(_fromUtf8("checkBox_Led1"))
self.label_Servo2 = QtGui.QLabel(Client)
self.label_Servo2.setGeometry(QtCore.QRect(710, 460, 41, 31))
self.checkBox_Led1.setObjectName("checkBox_Led1")
self.label_Servo2 = QtWidgets.QLabel(Client)
self.label_Servo2.setGeometry(QtCore.QRect(710, 470, 41, 31))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(14)
self.label_Servo2.setFont(font)
self.label_Servo2.setObjectName(_fromUtf8("label_Servo2"))
self.checkBox_Led2 = QtGui.QCheckBox(Client)
self.label_Servo2.setObjectName("label_Servo2")
self.checkBox_Led2 = QtWidgets.QCheckBox(Client)
self.checkBox_Led2.setGeometry(QtCore.QRect(420, 170, 91, 31))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.checkBox_Led2.setFont(font)
self.checkBox_Led2.setObjectName(_fromUtf8("checkBox_Led2"))
self.checkBox_Led3 = QtGui.QCheckBox(Client)
self.checkBox_Led2.setObjectName("checkBox_Led2")
self.checkBox_Led3 = QtWidgets.QCheckBox(Client)
self.checkBox_Led3.setGeometry(QtCore.QRect(420, 220, 91, 31))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.checkBox_Led3.setFont(font)
self.checkBox_Led3.setObjectName(_fromUtf8("checkBox_Led3"))
self.checkBox_Led4 = QtGui.QCheckBox(Client)
self.checkBox_Led3.setObjectName("checkBox_Led3")
self.checkBox_Led4 = QtWidgets.QCheckBox(Client)
self.checkBox_Led4.setGeometry(QtCore.QRect(420, 270, 91, 31))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.checkBox_Led4.setFont(font)
self.checkBox_Led4.setObjectName(_fromUtf8("checkBox_Led4"))
self.checkBox_Led5 = QtGui.QCheckBox(Client)
self.checkBox_Led4.setObjectName("checkBox_Led4")
self.checkBox_Led5 = QtWidgets.QCheckBox(Client)
self.checkBox_Led5.setGeometry(QtCore.QRect(530, 120, 91, 31))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.checkBox_Led5.setFont(font)
self.checkBox_Led5.setObjectName(_fromUtf8("checkBox_Led5"))
self.checkBox_Led6 = QtGui.QCheckBox(Client)
self.checkBox_Led5.setObjectName("checkBox_Led5")
self.checkBox_Led6 = QtWidgets.QCheckBox(Client)
self.checkBox_Led6.setGeometry(QtCore.QRect(530, 170, 91, 31))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.checkBox_Led6.setFont(font)
self.checkBox_Led6.setObjectName(_fromUtf8("checkBox_Led6"))
self.checkBox_Led7 = QtGui.QCheckBox(Client)
self.checkBox_Led6.setObjectName("checkBox_Led6")
self.checkBox_Led7 = QtWidgets.QCheckBox(Client)
self.checkBox_Led7.setGeometry(QtCore.QRect(530, 220, 91, 31))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.checkBox_Led7.setFont(font)
self.checkBox_Led7.setObjectName(_fromUtf8("checkBox_Led7"))
self.checkBox_Led8 = QtGui.QCheckBox(Client)
self.checkBox_Led7.setObjectName("checkBox_Led7")
self.checkBox_Led8 = QtWidgets.QCheckBox(Client)
self.checkBox_Led8.setGeometry(QtCore.QRect(530, 270, 91, 31))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.checkBox_Led8.setFont(font)
self.checkBox_Led8.setObjectName(_fromUtf8("checkBox_Led8"))
self.HSlider_Servo1 = QtGui.QSlider(Client)
self.HSlider_Servo1.setGeometry(QtCore.QRect(470, 530, 160, 22))
self.HSlider_Servo1.setStyleSheet(_fromUtf8(""))
self.HSlider_Servo1.setOrientation(QtCore.Qt.Horizontal)
self.HSlider_Servo1.setObjectName(_fromUtf8("HSlider_Servo1"))
self.VSlider_Servo2 = QtGui.QSlider(Client)
self.VSlider_Servo2.setGeometry(QtCore.QRect(680, 400, 22, 160))
self.VSlider_Servo2.setStyleSheet(_fromUtf8(""))
self.VSlider_Servo2.setOrientation(QtCore.Qt.Vertical)
self.VSlider_Servo2.setObjectName(_fromUtf8("VSlider_Servo2"))
self.label_Servo1 = QtGui.QLabel(Client)
self.label_Servo1.setGeometry(QtCore.QRect(530, 560, 41, 31))
self.checkBox_Led8.setObjectName("checkBox_Led8")
self.HSlider_Servo1 = QtWidgets.QSlider(Client)
self.HSlider_Servo1.setGeometry(QtCore.QRect(470, 540, 160, 22))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.HSlider_Servo1.setFont(font)
self.HSlider_Servo1.setStyleSheet("")
self.HSlider_Servo1.setOrientation(QtCore.Qt.Horizontal)
self.HSlider_Servo1.setObjectName("HSlider_Servo1")
self.VSlider_Servo2 = QtWidgets.QSlider(Client)
self.VSlider_Servo2.setGeometry(QtCore.QRect(680, 410, 22, 160))
self.VSlider_Servo2.setStyleSheet("")
self.VSlider_Servo2.setOrientation(QtCore.Qt.Vertical)
self.VSlider_Servo2.setObjectName("VSlider_Servo2")
self.label_Servo1 = QtWidgets.QLabel(Client)
self.label_Servo1.setGeometry(QtCore.QRect(530, 570, 41, 31))
font = QtGui.QFont()
font.setFamily("3ds")
font.setPointSize(14)
self.label_Servo1.setFont(font)
self.label_Servo1.setObjectName(_fromUtf8("label_Servo1"))
self.checkBox_Led_Mode2 = QtGui.QCheckBox(Client)
self.checkBox_Led_Mode2.setGeometry(QtCore.QRect(640, 170, 101, 31))
self.label_Servo1.setObjectName("label_Servo1")
self.checkBox_Led_Mode2 = QtWidgets.QCheckBox(Client)
self.checkBox_Led_Mode2.setGeometry(QtCore.QRect(640, 170, 91, 31))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.checkBox_Led_Mode2.setFont(font)
self.checkBox_Led_Mode2.setObjectName(_fromUtf8("checkBox_Led_Mode2"))
self.checkBox_Led_Mode3 = QtGui.QCheckBox(Client)
self.checkBox_Led_Mode3.setGeometry(QtCore.QRect(640, 220, 101, 31))
self.checkBox_Led_Mode2.setObjectName("checkBox_Led_Mode2")
self.checkBox_Led_Mode3 = QtWidgets.QCheckBox(Client)
self.checkBox_Led_Mode3.setGeometry(QtCore.QRect(640, 220, 91, 31))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.checkBox_Led_Mode3.setFont(font)
self.checkBox_Led_Mode3.setObjectName(_fromUtf8("checkBox_Led_Mode3"))
self.checkBox_Led_Mode4 = QtGui.QCheckBox(Client)
self.checkBox_Led_Mode4.setGeometry(QtCore.QRect(640, 270, 101, 31))
self.checkBox_Led_Mode3.setObjectName("checkBox_Led_Mode3")
self.checkBox_Led_Mode4 = QtWidgets.QCheckBox(Client)
self.checkBox_Led_Mode4.setGeometry(QtCore.QRect(640, 270, 91, 31))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.checkBox_Led_Mode4.setFont(font)
self.checkBox_Led_Mode4.setObjectName(_fromUtf8("checkBox_Led_Mode4"))
self.checkBox_Led_Mode1 = QtGui.QCheckBox(Client)
self.checkBox_Led_Mode1.setGeometry(QtCore.QRect(640, 120, 101, 31))
self.checkBox_Led_Mode4.setObjectName("checkBox_Led_Mode4")
self.checkBox_Led_Mode1 = QtWidgets.QCheckBox(Client)
self.checkBox_Led_Mode1.setGeometry(QtCore.QRect(640, 120, 91, 31))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.checkBox_Led_Mode1.setFont(font)
self.checkBox_Led_Mode1.setObjectName(_fromUtf8("checkBox_Led_Mode1"))
self.Color_R = QtGui.QLineEdit(Client)
self.checkBox_Led_Mode1.setObjectName("checkBox_Led_Mode1")
self.Color_R = QtWidgets.QLineEdit(Client)
self.Color_R.setGeometry(QtCore.QRect(560, 90, 30, 20))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.Color_R.setFont(font)
self.Color_R.setObjectName(_fromUtf8("Color_R"))
self.Color_G = QtGui.QLineEdit(Client)
self.Color_R.setObjectName("Color_R")
self.Color_G = QtWidgets.QLineEdit(Client)
self.Color_G.setGeometry(QtCore.QRect(630, 90, 30, 20))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.Color_G.setFont(font)
self.Color_G.setObjectName(_fromUtf8("Color_G"))
self.Color_B = QtGui.QLineEdit(Client)
self.Color_G.setObjectName("Color_G")
self.Color_B = QtWidgets.QLineEdit(Client)
self.Color_B.setGeometry(QtCore.QRect(700, 90, 30, 20))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.Color_B.setFont(font)
self.Color_B.setObjectName(_fromUtf8("Color_B"))
self.HSlider_FineServo2 = QtGui.QSlider(Client)
self.HSlider_FineServo2.setGeometry(QtCore.QRect(480, 370, 160, 22))
self.Color_B.setObjectName("Color_B")
self.HSlider_FineServo2 = QtWidgets.QSlider(Client)
self.HSlider_FineServo2.setGeometry(QtCore.QRect(480, 380, 160, 22))
self.HSlider_FineServo2.setOrientation(QtCore.Qt.Horizontal)
self.HSlider_FineServo2.setObjectName(_fromUtf8("HSlider_FineServo2"))
self.HSlider_FineServo1 = QtGui.QSlider(Client)
self.HSlider_FineServo1.setGeometry(QtCore.QRect(480, 320, 160, 22))
self.HSlider_FineServo2.setObjectName("HSlider_FineServo2")
self.HSlider_FineServo1 = QtWidgets.QSlider(Client)
self.HSlider_FineServo1.setGeometry(QtCore.QRect(480, 330, 160, 22))
self.HSlider_FineServo1.setOrientation(QtCore.Qt.Horizontal)
self.HSlider_FineServo1.setObjectName(_fromUtf8("HSlider_FineServo1"))
self.label_FineServo1 = QtGui.QLabel(Client)
self.label_FineServo1.setGeometry(QtCore.QRect(650, 320, 41, 31))
self.HSlider_FineServo1.setObjectName("HSlider_FineServo1")
self.label_FineServo1 = QtWidgets.QLabel(Client)
self.label_FineServo1.setGeometry(QtCore.QRect(650, 330, 41, 31))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(14)
self.label_FineServo1.setFont(font)
self.label_FineServo1.setObjectName(_fromUtf8("label_FineServo1"))
self.label_FineServo2 = QtGui.QLabel(Client)
self.label_FineServo2.setGeometry(QtCore.QRect(650, 360, 41, 31))
self.label_FineServo1.setObjectName("label_FineServo1")
self.label_FineServo2 = QtWidgets.QLabel(Client)
self.label_FineServo2.setGeometry(QtCore.QRect(650, 370, 41, 31))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(14)
self.label_FineServo2.setFont(font)
self.label_FineServo2.setObjectName(_fromUtf8("label_FineServo2"))
self.Window_Min = QtGui.QPushButton(Client)
self.label_FineServo2.setObjectName("label_FineServo2")
self.Window_Min = QtWidgets.QPushButton(Client)
self.Window_Min.setGeometry(QtCore.QRect(660, 1, 50, 40))
self.Window_Min.setObjectName(_fromUtf8("Window_Min"))
self.R = QtGui.QLabel(Client)
self.Window_Min.setObjectName("Window_Min")
self.R = QtWidgets.QLabel(Client)
self.R.setGeometry(QtCore.QRect(530, 90, 16, 20))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.R.setFont(font)
self.R.setObjectName(_fromUtf8("R"))
self.G = QtGui.QLabel(Client)
self.R.setObjectName("R")
self.G = QtWidgets.QLabel(Client)
self.G.setGeometry(QtCore.QRect(600, 90, 16, 20))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.G.setFont(font)
self.G.setObjectName(_fromUtf8("G"))
self.B = QtGui.QLabel(Client)
self.G.setObjectName("G")
self.B = QtWidgets.QLabel(Client)
self.B.setGeometry(QtCore.QRect(670, 90, 16, 20))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.B.setFont(font)
self.B.setObjectName(_fromUtf8("B"))
self.Led_Module = QtGui.QLabel(Client)
self.B.setObjectName("B")
self.Led_Module = QtWidgets.QLabel(Client)
self.Led_Module.setGeometry(QtCore.QRect(410, 90, 111, 25))
self.Led_Module.setObjectName(_fromUtf8("Led_Module"))
self.Servo1 = QtGui.QLabel(Client)
self.Servo1.setGeometry(QtCore.QRect(420, 320, 54, 20))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.Servo1.setFont(font)
self.Servo1.setObjectName(_fromUtf8("Servo1"))
self.Servo2 = QtGui.QLabel(Client)
self.Servo2.setGeometry(QtCore.QRect(420, 370, 54, 20))
self.Led_Module.setFont(font)
self.Led_Module.setObjectName("Led_Module")
self.Servo1 = QtWidgets.QLabel(Client)
self.Servo1.setGeometry(QtCore.QRect(420, 330, 54, 20))
self.Servo1.setObjectName("Servo1")
self.Servo2 = QtWidgets.QLabel(Client)
self.Servo2.setGeometry(QtCore.QRect(420, 380, 54, 20))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.Servo2.setFont(font)
self.Servo2.setObjectName(_fromUtf8("Servo2"))
self.progress_Power = QtGui.QProgressBar(Client)
self.progress_Power.setGeometry(QtCore.QRect(20, 550, 70, 30))
self.Servo2.setObjectName("Servo2")
self.progress_Power = QtWidgets.QProgressBar(Client)
self.progress_Power.setGeometry(QtCore.QRect(20, 560, 70, 30))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.progress_Power.setFont(font)
self.progress_Power.setStyleSheet(_fromUtf8("QProgressBar {\n"
self.progress_Power.setStyleSheet("QProgressBar {\n"
"border: 2px solid grey;\n"
"border-radius: 5px;\n"
"background-color: #FFFFFF;\n"
@ -498,103 +476,119 @@ class Ui_Client(object):
"text-align: center; \n"
"color: rgb(152,251,152);\n"
"}\n"
""))
"")
self.progress_Power.setProperty("value", 0)
self.progress_Power.setObjectName(_fromUtf8("progress_Power"))
self.Btn_Buzzer = QtGui.QPushButton(Client)
self.Btn_Buzzer.setGeometry(QtCore.QRect(120, 500, 90, 30))
self.progress_Power.setObjectName("progress_Power")
self.Btn_Buzzer = QtWidgets.QPushButton(Client)
self.Btn_Buzzer.setGeometry(QtCore.QRect(120, 510, 90, 30))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.Btn_Buzzer.setFont(font)
self.Btn_Buzzer.setObjectName(_fromUtf8("Btn_Buzzer"))
self.Ultrasonic = QtGui.QPushButton(Client)
self.Ultrasonic.setGeometry(QtCore.QRect(401, 41, 180, 30))
self.Ultrasonic.setObjectName(_fromUtf8("Ultrasonic"))
self.Light = QtGui.QPushButton(Client)
self.Light.setGeometry(QtCore.QRect(581, 41, 179, 30))
self.Light.setObjectName(_fromUtf8("Light"))
self.Btn_Mode1 = QtGui.QRadioButton(Client)
self.Btn_Mode1.setGeometry(QtCore.QRect(340, 400, 90, 30))
self.Btn_Buzzer.setObjectName("Btn_Buzzer")
self.Btn_Mode1 = QtWidgets.QRadioButton(Client)
self.Btn_Mode1.setGeometry(QtCore.QRect(335, 410, 90, 30))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.Btn_Mode1.setFont(font)
self.Btn_Mode1.setObjectName(_fromUtf8("Btn_Mode1"))
self.Btn_Mode2 = QtGui.QRadioButton(Client)
self.Btn_Mode2.setGeometry(QtCore.QRect(340, 450, 90, 30))
self.Btn_Mode1.setObjectName("Btn_Mode1")
self.Btn_Mode2 = QtWidgets.QRadioButton(Client)
self.Btn_Mode2.setGeometry(QtCore.QRect(335, 460, 90, 30))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.Btn_Mode2.setFont(font)
self.Btn_Mode2.setObjectName(_fromUtf8("Btn_Mode2"))
self.Btn_Mode3 = QtGui.QRadioButton(Client)
self.Btn_Mode3.setGeometry(QtCore.QRect(340, 500, 90, 30))
self.Btn_Mode2.setObjectName("Btn_Mode2")
self.Btn_Mode3 = QtWidgets.QRadioButton(Client)
self.Btn_Mode3.setGeometry(QtCore.QRect(335, 510, 90, 30))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.Btn_Mode3.setFont(font)
self.Btn_Mode3.setObjectName(_fromUtf8("Btn_Mode3"))
self.Btn_Mode4 = QtGui.QRadioButton(Client)
self.Btn_Mode4.setGeometry(QtCore.QRect(340, 550, 90, 30))
self.Btn_Mode3.setObjectName("Btn_Mode3")
self.Btn_Mode4 = QtWidgets.QRadioButton(Client)
self.Btn_Mode4.setGeometry(QtCore.QRect(335, 560, 90, 30))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(10)
self.Btn_Mode4.setFont(font)
self.Btn_Mode4.setObjectName(_fromUtf8("Btn_Mode4"))
self.Btn_Mode4.setObjectName("Btn_Mode4")
self.Btn_Tracking_Faces = QtWidgets.QPushButton(Client)
self.Btn_Tracking_Faces.setGeometry(QtCore.QRect(230, 460, 90, 30))
font = QtGui.QFont()
font.setFamily("3ds")
font.setPointSize(10)
self.Btn_Tracking_Faces.setFont(font)
self.Btn_Tracking_Faces.setStyleSheet("")
self.Btn_Tracking_Faces.setObjectName("Btn_Tracking_Faces")
self.Ultrasonic = QtWidgets.QPushButton(Client)
self.Ultrasonic.setGeometry(QtCore.QRect(400, 41, 180, 30))
font = QtGui.QFont()
font.setFamily("3ds")
font.setPointSize(10)
self.Ultrasonic.setFont(font)
self.Ultrasonic.setObjectName("Ultrasonic")
self.Light = QtWidgets.QPushButton(Client)
self.Light.setGeometry(QtCore.QRect(580, 41, 180, 30))
font = QtGui.QFont()
font.setFamily("3ds")
font.setPointSize(10)
self.Light.setFont(font)
self.Light.setObjectName("Light")
self.retranslateUi(Client)
QtCore.QMetaObject.connectSlotsByName(Client)
def retranslateUi(self, Client):
Client.setWindowTitle(_translate("Client", "freenove", None))
self.Btn_ForWard.setText(_translate("Client", "ForWard", None))
self.name.setText(_translate("Client", "Freenove", None))
self.Btn_Turn_Left.setText(_translate("Client", "Turn Left", None))
self.Btn_BackWard.setText(_translate("Client", "BackWard", None))
self.Btn_Turn_Right.setText(_translate("Client", "Turn Right", None))
self.Btn_Video.setText(_translate("Client", "Open Video", None))
self.Btn_Tracking_Faces.setText(_translate("Client", "Tracing-On", None))
self.Btn_Down.setText(_translate("Client", "Down", None))
self.Btn_Left.setText(_translate("Client", "Left", None))
self.Btn_Home.setText(_translate("Client", "Home", None))
self.Btn_Up.setText(_translate("Client", "Up", None))
self.Btn_Right.setText(_translate("Client", "Right", None))
self.Window_Close.setText(_translate("Client", "×", None))
self.IP.setText(_translate("Client", "IP address", None))
self.Btn_Connect.setText(_translate("Client", "Connect", None))
self.checkBox_Led1.setText(_translate("Client", "Led1", None))
self.label_Servo2.setText(_translate("Client", "0", None))
self.checkBox_Led2.setText(_translate("Client", "Led2", None))
self.checkBox_Led3.setText(_translate("Client", "Led3", None))
self.checkBox_Led4.setText(_translate("Client", "Led4", None))
self.checkBox_Led5.setText(_translate("Client", "Led5", None))
self.checkBox_Led6.setText(_translate("Client", "Led6", None))
self.checkBox_Led7.setText(_translate("Client", "Led7", None))
self.checkBox_Led8.setText(_translate("Client", "Led8", None))
self.label_Servo1.setText(_translate("Client", "90", None))
self.checkBox_Led_Mode2.setText(_translate("Client", "Led_Mode2", None))
self.checkBox_Led_Mode3.setText(_translate("Client", "Led_Mode3", None))
self.checkBox_Led_Mode4.setText(_translate("Client", "Led_Mode4", None))
self.checkBox_Led_Mode1.setText(_translate("Client", "Led_Mode1", None))
self.Color_R.setText(_translate("Client", "255", None))
self.Color_G.setText(_translate("Client", "0", None))
self.Color_B.setText(_translate("Client", "0", None))
self.label_FineServo1.setText(_translate("Client", "0", None))
self.label_FineServo2.setText(_translate("Client", "0", None))
self.Window_Min.setText(_translate("Client", "-", None))
self.R.setText(_translate("Client", "R", None))
self.G.setText(_translate("Client", "G", None))
self.B.setText(_translate("Client", "B", None))
self.Led_Module.setText(_translate("Client", "Led Module", None))
self.Servo1.setText(_translate("Client", "Servo 1", None))
self.Servo2.setText(_translate("Client", "Servo 2", None))
self.Btn_Buzzer.setText(_translate("Client", "Buzzer", None))
self.Ultrasonic.setText(_translate("Client", "Ultrasonic", None))
self.Light.setText(_translate("Client", "Light", None))
self.Btn_Mode1.setText(_translate("Client", "M-Free", None))
self.Btn_Mode2.setText(_translate("Client", "M-Light", None))
self.Btn_Mode3.setText(_translate("Client", "M-Sonic", None))
self.Btn_Mode4.setText(_translate("Client", "M-Line", None))
_translate = QtCore.QCoreApplication.translate
Client.setWindowTitle(_translate("Client", "freenove"))
self.Btn_ForWard.setText(_translate("Client", "ForWard"))
self.name.setText(_translate("Client", "Freenove"))
self.Btn_Turn_Left.setText(_translate("Client", "Turn Left"))
self.Btn_BackWard.setText(_translate("Client", "BackWard"))
self.Btn_Turn_Right.setText(_translate("Client", "Turn Right"))
self.Btn_Video.setText(_translate("Client", "Open Video"))
self.Btn_Down.setText(_translate("Client", "Down"))
self.Btn_Left.setText(_translate("Client", "Left"))
self.Btn_Home.setText(_translate("Client", "Home"))
self.Btn_Up.setText(_translate("Client", "Up"))
self.Btn_Right.setText(_translate("Client", "Right"))
self.Window_Close.setText(_translate("Client", "×"))
self.IP.setText(_translate("Client", "IP Address"))
self.Btn_Connect.setText(_translate("Client", "Connect"))
self.checkBox_Led1.setText(_translate("Client", "Led1"))
self.label_Servo2.setText(_translate("Client", "0"))
self.checkBox_Led2.setText(_translate("Client", "Led2"))
self.checkBox_Led3.setText(_translate("Client", "Led3"))
self.checkBox_Led4.setText(_translate("Client", "Led4"))
self.checkBox_Led5.setText(_translate("Client", "Led5"))
self.checkBox_Led6.setText(_translate("Client", "Led6"))
self.checkBox_Led7.setText(_translate("Client", "Led7"))
self.checkBox_Led8.setText(_translate("Client", "Led8"))
self.label_Servo1.setText(_translate("Client", "90"))
self.checkBox_Led_Mode2.setText(_translate("Client", "Led_Mode2"))
self.checkBox_Led_Mode3.setText(_translate("Client", "Led_Mode3"))
self.checkBox_Led_Mode4.setText(_translate("Client", "Led_Mode4"))
self.checkBox_Led_Mode1.setText(_translate("Client", "Led_Mode1"))
self.Color_R.setText(_translate("Client", "255"))
self.Color_G.setText(_translate("Client", "0"))
self.Color_B.setText(_translate("Client", "0"))
self.label_FineServo1.setText(_translate("Client", "0"))
self.label_FineServo2.setText(_translate("Client", "0"))
self.Window_Min.setText(_translate("Client", "-"))
self.R.setText(_translate("Client", "R"))
self.G.setText(_translate("Client", "G"))
self.B.setText(_translate("Client", "B"))
self.Led_Module.setText(_translate("Client", "Led Module"))
self.Servo1.setText(_translate("Client", "Servo 1"))
self.Servo2.setText(_translate("Client", "Servo 2"))
self.Btn_Buzzer.setText(_translate("Client", "Buzzer"))
self.Btn_Mode1.setText(_translate("Client", "M-Free"))
self.Btn_Mode2.setText(_translate("Client", "M-Light"))
self.Btn_Mode3.setText(_translate("Client", "M-Sonic"))
self.Btn_Mode4.setText(_translate("Client", "M-Line"))
self.Btn_Tracking_Faces.setText(_translate("Client", "Tracing-On"))
self.Ultrasonic.setText(_translate("Client", "Ultrasonic"))
self.Light.setText(_translate("Client", "Light"))

View File

@ -15,12 +15,10 @@ from Command import COMMAND as cmd
from Thread import *
from Client_Ui import Ui_Client
from Video import *
from PyQt4.QtCore import *
from PyQt4 import QtGui, QtCore
from PyQt4.QtGui import *
from PyQt4.QtCore import pyqtSignature
from PyQt4.QtGui import (QApplication, QMainWindow, QGraphicsScene)
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
class mywindow(QMainWindow,Ui_Client):
def __init__(self):
global timer
@ -147,8 +145,8 @@ class mywindow(QMainWindow,Ui_Client):
self.Window_Min.clicked.connect(self.windowMinimumed)
self.Window_Close.clicked.connect(self.close)
timer = QTimer(self)
self.connect(timer, SIGNAL("timeout()"), self.time)
self.timer = QTimer(self)
self.timer.timeout.connect(self.time)
def mousePressEvent(self, event):
if event.button()==Qt.LeftButton:
self.m_drag=True
@ -323,10 +321,10 @@ class mywindow(QMainWindow,Ui_Client):
def on_btn_video(self):
if self.Btn_Video.text()=='Open Video':
timer.start(34)
self.timer.start(34)
self.Btn_Video.setText('Close Video')
elif self.Btn_Video.text()=='Close Video':
timer.stop()
self.timer.stop()
self.Btn_Video.setText('Open Video')
def on_btn_Up(self):
self.servo2=self.servo2+10
@ -490,20 +488,19 @@ class mywindow(QMainWindow,Ui_Client):
def on_btn_Mode(self,Mode):
if Mode.text() == "M-Free":
if Mode.isChecked() == True:
timer.start(34)
self.timer.start(34)
self.TCP.sendData(cmd.CMD_MODE+self.intervalChar+'one'+self.endChar)
if Mode.text() == "M-Light":
if Mode.isChecked() == True:
timer.stop()
self.timer.stop()
self.TCP.sendData(cmd.CMD_MODE+self.intervalChar+'two'+self.endChar)
if Mode.text() == "M-Sonic":
if Mode.isChecked() == True:
timer.stop()
self.timer.stop()
self.TCP.sendData(cmd.CMD_MODE+self.intervalChar+'three'+self.endChar)
if Mode.text() == "M-Line":
if Mode.isChecked() == True:
timer.stop()
self.timer.stop()
self.TCP.sendData(cmd.CMD_MODE+self.intervalChar+'four'+self.endChar)
@ -515,12 +512,12 @@ class mywindow(QMainWindow,Ui_Client):
self.streaming=Thread(target=self.TCP.streaming,args=(self.h,))
self.streaming.start()
except:
print 'video error'
print ('video error')
try:
self.recv=Thread(target=self.recvmassage)
self.recv.start()
except:
print 'recv error'
print ('recv error')
self.Btn_Connect.setText( "Disconnect")
print ('Server address:'+str(self.h)+'\n')
elif self.Btn_Connect.text()=="Disconnect":
@ -535,7 +532,7 @@ class mywindow(QMainWindow,Ui_Client):
def close(self):
timer.stop()
self.timer.stop()
try:
stop_thread(self.recv)
stop_thread(self.streaming)
@ -623,11 +620,15 @@ class mywindow(QMainWindow,Ui_Client):
self.VSlider_Servo2.setValue(self.servo2)
def time(self):
self.TCP.video_Flag=False
if self.is_valid_jpg('video.jpg'):
self.label_Video.setPixmap(QtGui.QPixmap(QtCore.QString.fromUtf8('video.jpg')))
if self.Btn_Tracking_Faces.text()=="Tracing-Off":
self.find_Face(self.TCP.face_x,self.TCP.face_y)
try:
if self.is_valid_jpg('video.jpg'):
self.label_Video.setPixmap(QPixmap('video.jpg'))
if self.Btn_Tracking_Faces.text()=="Tracing-Off":
self.find_Face(self.TCP.face_x,self.TCP.face_y)
except Exception as e:
print(e)
self.TCP.video_Flag=True
if __name__ == '__main__':
app = QApplication(sys.argv)

View File

@ -42,18 +42,18 @@ class VideoStreaming:
return bValid
def face_detect(self,img):
if sys.platform.startswith('win'):
if sys.platform.startswith('win') or sys.platform.startswith('darwin'):
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
faces = self.face_cascade.detectMultiScale(gray,1.3,5)
if len(faces)>0 :
for (x,y,w,h) in faces:
self.face_x=float(x+w/2.0)
self.face_y=float(y+h/2.0)
img = cv2.circle(img, (x+w/2,y+h/2), (w+h)/4, (0, 255, 0), 2)
img= cv2.circle(img, (int(self.face_x),int(self.face_y)), int((w+h)/4), (0, 255, 0), 2)
else:
self.face_x=0
self.face_y=0
cv2.imwrite('video.jpg', img)
cv2.imwrite('video.jpg',img)
def streaming(self,ip):
stream_bytes = b' '
@ -66,24 +66,25 @@ class VideoStreaming:
while True:
try:
stream_bytes= self.connection.read(4)
leng=struct.unpack('L', stream_bytes[:4])
leng=struct.unpack('<L', stream_bytes[:4])
jpg=self.connection.read(leng[0])
if self.IsValidImage4Bytes(jpg):
image = cv2.imdecode(np.frombuffer(jpg, dtype=np.uint8), cv2.IMREAD_COLOR)
if self.video_Flag:
self.face_detect(image)
self.video_Flag=False
except:
except Exception as e:
print (e)
break
def sendData(self,s):
if self.connect_Flag:
self.client_socket1.send(s)
self.client_socket1.send(s.encode('utf-8'))
def recvData(self):
data=""
try:
data=self.client_socket1.recv(1024)
data=self.client_socket1.recv(1024).decode('utf-8')
except:
pass
return data
@ -92,9 +93,9 @@ class VideoStreaming:
try:
self.client_socket1.connect((ip, 5000))
self.connect_Flag=True
print "Connecttion Successful !"
except Exception, e:
print "Connect to server Faild!: Server IP is right? Server is opend?"
print ("Connecttion Successful !")
except Exception as e:
print ("Connect to server Faild!: Server IP is right? Server is opend?")
self.connect_Flag=False
if __name__ == '__main__':

View File

@ -4,24 +4,16 @@ class Adc:
def __init__(self):
# Get I2C bus
self.bus = smbus.SMBus(1)
# I2C address of the device
self.ADDRESS = 0x48
# PCF8591 Command
self.PCF8591_CMD =0x40 #Command
# ADS7830 Command Set
self.ADS7830_CMD_SD_SINGLE = 0x84 # Single-Ended Inputs
self.ADS7830_CMD_SNGL_CHANNEL_0 = 0x00 # +IN = CH0, -IN = GND
self.ADS7830_CMD_SNGL_CHANNEL_1 = 0x40 # +IN = CH1, -IN = GND
self.ADS7830_CMD_SNGL_CHANNEL_2 = 0x10 # +IN = CH2, -IN = GND
self.ADS7830_CMD_SNGL_CHANNEL_3 = 0x50 # +IN = CH3, -IN = GND
self.ADS7830_CMD_SNGL_CHANNEL_4 = 0x20 # +IN = CH4, -IN = GND
self.ADS7830_CMD_SNGL_CHANNEL_5 = 0x60 # +IN = CH5, -IN = GND
self.ADS7830_CMD_SNGL_CHANNEL_6 = 0x30 # +IN = CH6, -IN = GND
self.ADS7830_CMD_SNGL_CHANNEL_7 = 0x70 # +IN = CH7, -IN = GND
self.ADS7830_CMD_PD_POWER_DOWN = 0x00 # Power Down Between A/D Converter Conversions
self.ADS7830_CMD_PD_REF_OFF = 0x04 # Internal Reference OFF and A/D Converter ON
self.ADS7830_CMD_PD_REF_ON = 0x08 # Internal Reference ON and A/D Converter OFF
self.ADS7830_CMD_PD_REF_ON_AD_ON = 0x0C # Internal Reference ON and A/D Converter ON
# ADS7830 Command
self.ADS7830_CMD = 0x84 # Single-Ended Inputs
for i in range(3):
aa=self.bus.read_byte_data(self.ADDRESS,0xf4)
if aa < 150:
@ -49,30 +41,14 @@ class Adc:
return voltage
def recvADS7830(self,channel):
"""Select the Command data from the given provided value above"""
if channel == 0:
COMMAND_SET = (self.ADS7830_CMD_SD_SINGLE | self.ADS7830_CMD_SNGL_CHANNEL_0)
elif channel == 1:
COMMAND_SET = (self.ADS7830_CMD_SD_SINGLE | self.ADS7830_CMD_SNGL_CHANNEL_1)
elif channel == 2:
COMMAND_SET = (self.ADS7830_CMD_SD_SINGLE | self.ADS7830_CMD_SNGL_CHANNEL_2)
elif channel == 3:
COMMAND_SET = (self.ADS7830_CMD_SD_SINGLE | self.ADS7830_CMD_SNGL_CHANNEL_3)
elif channel == 4:
COMMAND_SET = (self.ADS7830_CMD_SD_SINGLE | self.ADS7830_CMD_SNGL_CHANNEL_4)
elif channel == 5:
COMMAND_SET = (self.ADS7830_CMD_SD_SINGLE | self.ADS7830_CMD_SNGL_CHANNEL_5)
elif channel == 6:
COMMAND_SET = (self.ADS7830_CMD_SD_SINGLE | self.ADS7830_CMD_SNGL_CHANNEL_6)
elif channel == 7:
COMMAND_SET = (self.ADS7830_CMD_SD_SINGLE | self.ADS7830_CMD_SNGL_CHANNEL_7)
self.bus.write_byte(self.ADDRESS, COMMAND_SET)
COMMAND_SET = self.ADS7830_CMD | ((((channel<<2)|(channel>>1))&0x07)<<4)
self.bus.write_byte(self.ADDRESS,COMMAND_SET)
while(1):
value1 = self.bus.read_byte(self.ADDRESS)
value2 = self.bus.read_byte(self.ADDRESS)
if value1==value2:
break;
voltage = value1 / 256.0 * 3.3 #calculate the voltage value
voltage = value1 / 255.0 * 3.3 #calculate the voltage value
voltage = round(voltage,2)
return voltage

View File

@ -125,12 +125,12 @@ if __name__ == '__main__':
print ('Program is starting ... ')
try:
while True:
print "Chaser animation"
print ("Chaser animation")
led.colorWipe(led.strip, Color(255,0, 0)) # Red wipe
led.colorWipe(led.strip, Color(0, 255, 0)) # Green wipe
led.colorWipe(led.strip, Color(0, 0, 255)) # Blue wipe
led.theaterChaseRainbow(led.strip)
print "Rainbow animation"
print ("Rainbow animation")
led.rainbow(led.strip)
led.rainbowCycle(led.strip)
led.colorWipe(led.strip, Color(0,0,0),10)

View File

@ -5,15 +5,15 @@ import struct
import time
import picamera
import sys,getopt
from threading import Thread
from server_ui import Ui_server_ui
from PyQt4.QtCore import *
from Thread import *
from PyQt4 import QtGui, QtCore
from PyQt4.QtGui import *
from PyQt4.QtCore import pyqtSignature
from PyQt4.QtGui import (QApplication, QMainWindow, QGraphicsScene)
from threading import Thread
from server import Server
from server_ui import Ui_server_ui
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
class mywindow(QMainWindow,Ui_server_ui):
@ -50,7 +50,7 @@ class mywindow(QMainWindow,Ui_server_ui):
self.opts,self.args = getopt.getopt(sys.argv[1:],"tn")
for o,a in self.opts:
if o in ('-t'):
print "Open TCP"
print ("Open TCP")
self.TCP_Server.StartTcpServer()
self.ReadData=Thread(target=self.TCP_Server.readdata)
self.SendVideo=Thread(target=self.TCP_Server.sendvideo)
@ -77,7 +77,7 @@ class mywindow(QMainWindow,Ui_server_ui):
self.TCP_Server.StopTcpServer()
except:
pass
print "Close TCP"
print ("Close TCP")
QCoreApplication.instance().quit()
os._exit(0)
def on_pushButton(self):
@ -85,7 +85,7 @@ class mywindow(QMainWindow,Ui_server_ui):
self.label.setText("Server On")
self.Button_Server.setText("Off")
self.TCP_Server.tcp_Flag = True
print "Open TCP"
print ("Open TCP")
self.TCP_Server.StartTcpServer()
self.SendVideo=Thread(target=self.TCP_Server.sendvideo)
self.ReadData=Thread(target=self.TCP_Server.readdata)
@ -106,7 +106,7 @@ class mywindow(QMainWindow,Ui_server_ui):
pass
self.TCP_Server.StopTcpServer()
print "Close TCP"
print ("Close TCP")
if __name__ == '__main__':
app = QApplication(sys.argv)
@ -119,4 +119,4 @@ if __name__ == '__main__':
while(1):
pass
except KeyboardInterrupt:
myshow.close()
myshow.close()

View File

@ -39,8 +39,10 @@ class Server:
self.intervalChar='#'
def get_interface_ip(self):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(s.fileno(), 0x8915, struct.pack('256s',
"wlan0"[:15]))[20:24])
return socket.inet_ntoa(fcntl.ioctl(s.fileno(),
0x8915,
struct.pack('256s',b'wlan0'[:15])
)[20:24])
def StartTcpServer(self):
HOST=str(self.get_interface_ip())
self.server_socket1 = socket.socket()
@ -58,8 +60,8 @@ class Server:
try:
self.connection.close()
self.connection1.close()
except Exception , e:
print '\n'+"No client connection"
except Exception as e:
print ('\n'+"No client connection")
def Reset(self):
self.StopTcpServer()
@ -68,23 +70,24 @@ class Server:
self.ReadData=Thread(target=self.readdata)
self.SendVideo.start()
self.ReadData.start()
def send(self,data):
self.connection1.send(data.encode('utf-8'))
def sendvideo(self):
try:
self.connection,self.client_address = self.server_socket.accept()
self.connection=self.connection.makefile('rb')
self.connection=self.connection.makefile('wb')
except:
pass
self.server_socket.close()
try:
with picamera.PiCamera() as camera:
camera.resolution = (400,300) # pi camera resolution
camera.framerate = 30 # 15 frames/sec
camera.framerate = 15 # 15 frames/sec
time.sleep(2) # give 2 secs for camera to initilize
start = time.time()
stream = io.BytesIO()
# send jpeg format video stream
print "Start transmit ... "
print ("Start transmit ... ")
for foo in camera.capture_continuous(stream, 'jpeg', use_video_port = True):
try:
self.connection.flush()
@ -98,8 +101,9 @@ class Server:
self.connection.write(b)
stream.seek(0)
stream.truncate()
except :
print "End transmit ... "
except Exception as e:
print(e)
print ("End transmit ... " )
break
except:
#print "Camera unintall"
@ -127,14 +131,14 @@ class Server:
def readdata(self):
try:
self.connection1,self.client_address1 = self.server_socket1.accept()
print "Client connection successful !"
print ("Client connection successful !")
except:
print "Client connect failed"
print ("Client connect failed")
restCmd=""
self.server_socket1.close()
while True:
try:
AllData=restCmd+self.connection1.recv(1024)
AllData=restCmd+self.connection1.recv(1024).decode('utf-8')
except:
if self.tcp_Flag:
self.Reset()
@ -249,7 +253,7 @@ class Server:
elif cmd.CMD_POWER in data:
ADC_Power=self.adc.recvADC(2)*3
try:
self.connection1.send(cmd.CMD_POWER+'#'+str(ADC_Power)+'\n')
self.send(cmd.CMD_POWER+'#'+str(ADC_Power)+'\n')
except:
pass
self.StopTcpServer()
@ -258,7 +262,7 @@ class Server:
ADC_Ultrasonic=self.ultrasonic.get_distance()
if ADC_Ultrasonic==self.ultrasonic.get_distance():
try:
self.connection1.send(cmd.CMD_SONIC+"#"+str(ADC_Ultrasonic)+'\n')
self.send(cmd.CMD_SONIC+"#"+str(ADC_Ultrasonic)+'\n')
except:
self.sonic=False
self.ultrasonicTimer = threading.Timer(0.13,self.sendUltrasonic)
@ -268,7 +272,7 @@ class Server:
ADC_Light1=self.adc.recvADC(0)
ADC_Light2=self.adc.recvADC(1)
try:
self.connection1.send(cmd.CMD_LIGHT+'#'+str(ADC_Light1)+'#'+str(ADC_Light2)+'\n')
self.send(cmd.CMD_LIGHT+'#'+str(ADC_Light1)+'#'+str(ADC_Light2)+'\n')
except:
self.Light=False
self.lightTimer = threading.Timer(0.17,self.sendLight)
@ -292,4 +296,4 @@ class Server:
else:
self.buzzer.run('0')
if __name__=='__main__':
passS
pass

View File

@ -1,32 +1,21 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'C:/Users/Freenove/Desktop/test/qss/server_ui.ui'
# Form implementation generated from reading ui file 'C:\Users\Freenove\Desktop\树莓派四轮车项目\四轮车python3+pyqt5代码\server_ui.ui'
#
# Created by: PyQt4 UI code generator 4.11.4
# Created by: PyQt5 UI code generator 5.11.3
#
# WARNING! All changes made in this file will be lost!
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)
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_server_ui(object):
def setupUi(self, server_ui):
server_ui.setObjectName(_fromUtf8("server_ui"))
server_ui.setObjectName("server_ui")
server_ui.resize(400, 300)
server_ui.setStyleSheet(_fromUtf8("QWidget{\n"
font = QtGui.QFont()
font.setFamily("3ds")
server_ui.setFont(font)
server_ui.setStyleSheet("QWidget{\n"
"background:#484848;\n"
"}\n"
"QAbstractButton{\n"
@ -82,46 +71,53 @@ class Ui_server_ui(object):
"}\n"
"QLineEdit{\n"
"lineedit-password-character:9679;\n"
"}"))
self.label = QtGui.QLabel(server_ui)
"}")
self.label = QtWidgets.QLabel(server_ui)
self.label.setGeometry(QtCore.QRect(100, 150, 200, 42))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(26)
self.label.setFont(font)
self.label.setObjectName(_fromUtf8("label"))
self.Button_Server = QtGui.QPushButton(server_ui)
self.label.setObjectName("label")
self.Button_Server = QtWidgets.QPushButton(server_ui)
self.Button_Server.setGeometry(QtCore.QRect(150, 220, 100, 40))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(12)
self.Button_Server.setFont(font)
self.Button_Server.setObjectName(_fromUtf8("Button_Server"))
self.label_2 = QtGui.QLabel(server_ui)
self.Button_Server.setObjectName("Button_Server")
self.label_2 = QtWidgets.QLabel(server_ui)
self.label_2.setGeometry(QtCore.QRect(0, 0, 301, 41))
font = QtGui.QFont()
font.setFamily(_fromUtf8("3ds"))
font.setFamily("3ds")
font.setPointSize(28)
font.setBold(True)
font.setWeight(75)
self.label_2.setFont(font)
self.label_2.setStyleSheet(_fromUtf8(""))
self.label_2.setObjectName(_fromUtf8("label_2"))
self.pushButton_Close = QtGui.QPushButton(server_ui)
self.label_2.setStyleSheet("")
self.label_2.setObjectName("label_2")
self.pushButton_Close = QtWidgets.QPushButton(server_ui)
self.pushButton_Close.setGeometry(QtCore.QRect(350, 0, 50, 40))
self.pushButton_Close.setObjectName(_fromUtf8("pushButton_Close"))
self.pushButton_Min = QtGui.QPushButton(server_ui)
font = QtGui.QFont()
font.setFamily("3ds")
self.pushButton_Close.setFont(font)
self.pushButton_Close.setObjectName("pushButton_Close")
self.pushButton_Min = QtWidgets.QPushButton(server_ui)
self.pushButton_Min.setGeometry(QtCore.QRect(300, 0, 50, 40))
self.pushButton_Min.setObjectName(_fromUtf8("pushButton_Min"))
font = QtGui.QFont()
font.setFamily("3ds")
self.pushButton_Min.setFont(font)
self.pushButton_Min.setObjectName("pushButton_Min")
self.retranslateUi(server_ui)
QtCore.QMetaObject.connectSlotsByName(server_ui)
def retranslateUi(self, server_ui):
server_ui.setWindowTitle(_translate("server_ui", "Form", None))
self.label.setText(_translate("server_ui", "Server Off", None))
self.Button_Server.setText(_translate("server_ui", "Off", None))
self.label_2.setText(_translate("server_ui", "Freenove", None))
self.pushButton_Close.setText(_translate("server_ui", "×", None))
self.pushButton_Min.setText(_translate("server_ui", "-", None))
_translate = QtCore.QCoreApplication.translate
server_ui.setWindowTitle(_translate("server_ui", "Form"))
self.label.setText(_translate("server_ui", "Server Off"))
self.Button_Server.setText(_translate("server_ui", "Off"))
self.label_2.setText(_translate("server_ui", "freenove"))
self.pushButton_Close.setText(_translate("server_ui", "×"))
self.pushButton_Min.setText(_translate("server_ui", "-"))

View File

@ -11,13 +11,13 @@ def test_Led():
led.ledIndex(0x20,0,0,255) #blue
led.ledIndex(0x40,128,0,128) #purple
led.ledIndex(0x80,255,255,255) #white'''
print "The LED has been lit, the color is red orange yellow green cyan-blue blue white"
print ("The LED has been lit, the color is red orange yellow green cyan-blue blue white")
time.sleep(3) #wait 3s
led.colorWipe(led.strip, Color(0,0,0)) #turn off the light
print "\nEnd of program"
print ("\nEnd of program")
except KeyboardInterrupt:
led.colorWipe(led.strip, Color(0,0,0)) #turn off the light
print "\nEnd of program"
print ("\nEnd of program")
@ -26,22 +26,22 @@ PWM=Motor()
def test_Motor():
try:
PWM.setMotorModel(1000,1000,1000,1000) #Forward
print "The car is moving forward"
print ("The car is moving forward")
time.sleep(1)
PWM.setMotorModel(-1000,-1000,-1000,-1000) #Back
print "The car is going backwards"
print ("The car is going backwards")
time.sleep(1)
PWM.setMotorModel(-1500,-1500,2000,2000) #Left
print "The car is turning left"
print ("The car is turning left")
time.sleep(1)
PWM.setMotorModel(2000,2000,-1500,-1500) #Right
print "The car is turning right"
print ("The car is turning right")
time.sleep(1)
PWM.setMotorModel(0,0,0,0) #Stop
print "\nEnd of program"
print ("\nEnd of program")
except KeyboardInterrupt:
PWM.setMotorModel(0,0,0,0)
print "\nEnd of program"
print ("\nEnd of program")
from Ultrasonic import *
@ -53,7 +53,7 @@ def test_Ultrasonic():
print ("Obstacle distance is "+str(data)+"CM")
time.sleep(1)
except KeyboardInterrupt:
print "\nEnd of program"
print ("\nEnd of program")
from Line_Tracking import *
@ -61,13 +61,13 @@ def test_Infrared():
try:
while True:
if GPIO.input(IR01)!=True and GPIO.input(IR02)==True and GPIO.input(IR03)!=True:
print 'Middle'
print ('Middle')
elif GPIO.input(IR01)!=True and GPIO.input(IR02)!=True and GPIO.input(IR03)==True:
print 'Right'
print ('Right')
elif GPIO.input(IR01)==True and GPIO.input(IR02)!=True and GPIO.input(IR03)!=True:
print 'Left'
print ('Left')
except KeyboardInterrupt:
print "\nEnd of program"
print ("\nEnd of program")
from servo import *
@ -90,7 +90,7 @@ def test_Servo():
except KeyboardInterrupt:
pwm.setServoPwm('0',90)
pwm.setServoPwm('1',90)
print "\nEnd of program"
print ("\nEnd of program")
from ADC import *
@ -105,9 +105,9 @@ def test_Adc():
Power=adc.recvADC(2)
print ("The battery voltage is "+str(Power*3)+"V")
time.sleep(1)
print '\n'
print ('\n')
except KeyboardInterrupt:
print "\nEnd of program"
print ("\nEnd of program")
from Buzzer import *
buzzer=Buzzer()
@ -115,21 +115,21 @@ def test_Buzzer():
try:
buzzer.run('1')
time.sleep(1)
print "1S"
print ("1S")
time.sleep(1)
print "2S"
print ("2S")
time.sleep(1)
print "3S"
print ("3S")
buzzer.run('0')
print "\nEnd of program"
print ("\nEnd of program")
except KeyboardInterrupt:
buzzer.run('0')
print "\nEnd of program"
print ("\nEnd of program")
import cv2
def test_Camera():
try:
print "\nOpen camera"
print ("\nOpen camera")
capturing_Flag = True
cap = cv2.VideoCapture(0)
while(capturing_Flag):
@ -138,7 +138,7 @@ def test_Camera():
cv2.waitKey(5)
cv2.destroyAllWindows()
except KeyboardInterrupt:
print "\nClose camera"
print ("\nClose camera")
capturing_Flag = False
# Main program logic follows:
@ -147,7 +147,7 @@ if __name__ == '__main__':
print ('Program is starting ... ')
import sys
if len(sys.argv)<2:
print "Parameter error: Please assign the device"
print ("Parameter error: Please assign the device")
exit()
if sys.argv[1] == 'Led':
test_Led()

31
Code/setup_macos.py Normal file
View File

@ -0,0 +1,31 @@
import os
import sys
import time
flag=0x00
for x in range(1,4):
if os.system("python3 -m pip install --upgrade pip") == 0:
flag=flag | 0x01
break
for x in range(1,4):
if os.system("pip3 install PyQt5") == 0:
flag=flag | 0x02
break
for x in range(1,4):
if os.system("pip3 install Pillow") == 0:
flag=flag | 0x04
break
for x in range(1,4):
if os.system("pip3 install opencv-python-headless") == 0:
flag=flag | 0x08
break
for x in range(1,4):
if os.system("pip3 install numpy") == 0:
flag=flag | 0x10
break
if flag==0x1f:
os.system("pip3 list")
print("\nAll libraries installed successfully")
else:
print ("\nSome libraries have not been installed yet. Please run 'python3 setup_macos.py' again")

38
Code/setup_windows.py Normal file
View File

@ -0,0 +1,38 @@
import os
import sys
import time
flag=0x00
for x in range(1,4):
if os.system("python3 -m pip install --upgrade pip") == 0:
flag=flag | 0x01
break
for x in range(1,4):
if os.system("pip3 install PyQt5") == 0:
flag=flag | 0x02
break
for x in range(1,4):
if os.system("pip3 install pyqt5-tools") == 0:
flag=flag | 0x04
break
for x in range(1,4):
if os.system("pip3 install Pillow") == 0:
flag=flag | 0x08
break
for x in range(1,4):
if os.system("pip3 install opencv-python") == 0:
flag=flag | 0x10
break
for x in range(1,4):
if os.system("pip3 install numpy") == 0:
flag=flag | 0x20
break
if flag==0x3f:
os.system("pip3 list && pause")
print("\nAll libraries installed successfully")
else:
print ("\nSome libraries have not been installed yet. Please run 'sudo python3 setup_windows.py' again")

Binary file not shown.