-
Notifications
You must be signed in to change notification settings - Fork 0
/
arduino_baglanti.py
162 lines (119 loc) · 5.36 KB
/
arduino_baglanti.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# -*- coding: utf-8 -*-
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import *
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
import serial.tools.list_ports
from modules import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtGui import QIcon, QPixmap
from PyQt5 import QtGui, QtCore
import serial.tools.list_ports
from serial import Serial
from devre_semasi import *
class Arduino(object):
def setupUi3(self, Arduino1):
Arduino1.setObjectName("MainWindow")
Arduino1.resize(390, 229)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("../icons/arduino.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
Arduino1.setWindowIcon(icon)
self.centralwidget = QtWidgets.QWidget(Arduino1)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout.setObjectName("gridLayout")
self.kaydet_butonu = QtWidgets.QPushButton(self.centralwidget)
self.kaydet_butonu.setObjectName("kaydet_butonu")
self.gridLayout.addWidget(self.kaydet_butonu, 3, 1, 1, 1)
self.cikis_butonu = QtWidgets.QPushButton(self.centralwidget)
self.cikis_butonu.setObjectName("cikis_butonu")
self.gridLayout.addWidget(self.cikis_butonu, 4,1,1,1)
self.port_listesi = QtWidgets.QComboBox(self.centralwidget)
self.port_listesi.setObjectName("port_listesi")
self.gridLayout.addWidget(self.port_listesi, 0, 1, 1, 1)
self.isletim_sistemi_label = QtWidgets.QLabel(self.centralwidget)
self.isletim_sistemi_label.setObjectName("isletim_sistemi_label")
self.gridLayout.addWidget(self.isletim_sistemi_label, 0, 0, 1, 1)
self.uyari_labeli = QtWidgets.QLabel ( self.centralwidget )
self.uyari_labeli.setObjectName ( "uyari_labeli" )
self.gridLayout.addWidget ( self.uyari_labeli, 2, 0, 1, 1 )
self.devreyi_gorme_butonu = QtWidgets.QPushButton(self.centralwidget)
self.devreyi_gorme_butonu.setObjectName("devreyi_gorme_butonu")
self.gridLayout.addWidget(self.devreyi_gorme_butonu, 3, 0, 1, 1)
Arduino1.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(Arduino1)
self.menubar.setGeometry(QtCore.QRect(0, 0, 390, 22))
self.menubar.setObjectName("menubar")
Arduino1.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(Arduino1)
self.statusbar.setObjectName("statusbar")
Arduino1.setStatusBar(self.statusbar)
self.retranslateUi(Arduino1)
self.devreyi_gorme_butonu.clicked.connect(self.devre_semasi_goster)
self.kaydet_butonu.clicked.connect(self.kaydet_gonder)
self.cikis_butonu.clicked.connect(Arduino1.hide)
QtCore.QMetaObject.connectSlotsByName(Arduino1)
self.portlari_getir()
# self.uyari_labeli.setVisible(False)
def kaydet_gonder(self):
secim = self.port_listesi.currentText ()
if len ( ports ) == 0:
print ( "usb portunuzda bağlantı yok" )
msg = QMessageBox ()
msg.setIcon ( QMessageBox.Warning )
msg.setText ( "Hata" )
msg.setWindowTitle ( "Hata" )
msg.setDetailedText ( "Olası Hata: USB bağlantısı yok." )
msg.setStandardButtons( QMessageBox.Ok)
msg.exec()
else:
print ( secim + " seçildi." )
print(type(secim))
arduinoyu_bagla(secim)
msg = QMessageBox()
msg.setIcon(QMessageBox.Information)
msg.setWindowTitle(" ")
msg.setText("Bağlantı Başarılı.")
msg.setStandardButtons(QMessageBox.Ok)
msg.exec()
Arduino1.hide()
def portlari_getir(self):
a = (serial.tools.list_ports.comports ())
b = 0
for i in a:
print(i)
port_isimler = ( str ( a [b] ).split ( " -" ) [0] )
self.port_listesi.addItem ( str ( port_isimler ) )
b += 1
if len(a) == 0:
self.port_listesi.setEnabled(False)
self.uyari_labeli.setVisible ( True )
else:
self.uyari_labeli.setVisible ( False )
def devre_semasi_goster(self):
ui7.setupUi7 ( devre_semasi )
devre_semasi.show ()
def retranslateUi(self, Arduino1):
_translate = QtCore.QCoreApplication.translate
Arduino1.setWindowTitle(_translate("MainWindow", "Arduino Bağlantı Ekranı"))
self.kaydet_butonu.setText(_translate("MainWindow", "Kaydet"))
self.isletim_sistemi_label.setText(_translate("MainWindow", "Portunuzu seçiniz: "))
self.cikis_butonu.setText(_translate("MainWindow", "Çıkış"))
self.devreyi_gorme_butonu.setText(_translate("MainWindow", "Devreyi görmek için tıklayınız."))
self.uyari_labeli.setText(_translate("MainWindow", "Portunuzda bağlantı yok!"))
myFont=QtGui.QFont()
myFont.setBold(True)
self.uyari_labeli.setFont(myFont)
self.uyari_labeli.setStyleSheet('color: red')
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Arduino1 = QtWidgets.QMainWindow()
ui3 = Arduino()
ui3.setupUi3(Arduino1 )
Arduino1.show()
sys.exit(app.exec_())
ui7 = Ui_MainWindow ()
ui7.setupUi7 ( devre_semasi )
devre_semasi.show ()