Skip to content

Commit a87a680

Browse files
committed
modified rouchpanel function
1 parent fd3936e commit a87a680

File tree

1 file changed

+36
-56
lines changed

1 file changed

+36
-56
lines changed

QML/qml_5/main.py

+36-56
Original file line numberDiff line numberDiff line change
@@ -189,17 +189,19 @@ def __init__(self,path):
189189
def run(self):
190190
while True:
191191
touch = InputDevice(self.Path)
192-
# print(touch)
193192
circle1Visible = False
194193
circle2Visible = False
195194
circle3Visible = False
195+
circle3flage = False
196196
circle4Visible = False
197+
circle4flage = False
197198
circle5Visible = False
199+
circle5flage = False
198200
for event in touch.read_loop():
199201
if event.type == ecodes.EV_ABS:
200202
touchevents = repr(event)
201203
val_list = touchevents.replace('(','').replace(')','').replace(' ','').split(',')
202-
# print(val_list)
204+
print(val_list)
203205
if val_list[3] == '53':
204206
xvalue = int(val_list[4])
205207
self.TouchSignal.emit(xvalue,'axisx1')
@@ -213,21 +215,10 @@ def run(self):
213215
if val_list[3] == '47':
214216
if val_list[4] == '1':
215217
circle1Visible = True
216-
if circle1Visible == True:
217-
if val_list[3] == '53':
218-
xvalue = int(val_list[4])
219-
self.TouchSignal.emit(xvalue,'axisx1')
220-
if val_list[3] == '54':
221-
yvalue = int(val_list[4])
222-
self.TouchSignal.emit(yvalue,'axisy1')
223-
if val_list[3] == '48':
224-
zvalue = int(val_list[4])
225-
self.TouchSignal.emit(zvalue,'axisz1')
226-
227-
228-
if val_list[3] == '47':
229-
if val_list[4] == '2':
230-
circle2Visible = True
218+
if circle1Visible == True:
219+
if val_list[3] == '47':
220+
if val_list[4] == '0':
221+
circle2Visible = True
231222
if circle2Visible == True:
232223
if val_list[3] == '53':
233224
xvalue = int(val_list[4])
@@ -239,10 +230,13 @@ def run(self):
239230
zvalue = int(val_list[4])
240231
self.TouchSignal.emit(zvalue,'axisz2')
241232

242-
243233
if val_list[3] == '47':
244-
if val_list[4] == '3':
245-
circle3Visible = True
234+
if val_list[4] == '2':
235+
circle3flage = True
236+
if circle3flage == True:
237+
if val_list[3] == '47':
238+
if val_list[4] == '0':
239+
circle3Visible = True
246240
if circle3Visible == True:
247241
if val_list[3] == '53':
248242
xvalue = int(val_list[4])
@@ -255,8 +249,12 @@ def run(self):
255249
self.TouchSignal.emit(zvalue,'axisz3')
256250

257251
if val_list[3] == '47':
258-
if val_list[4] == '4':
259-
circle4Visible = True
252+
if val_list[4] == '3':
253+
circle4flage = True
254+
if circle4flage == True:
255+
if val_list[3] == '47':
256+
if val_list[4] == '0':
257+
circle4Visible = True
260258
if circle4Visible == True:
261259
if val_list[3] == '53':
262260
xvalue = int(val_list[4])
@@ -267,10 +265,14 @@ def run(self):
267265
if val_list[3] == '48':
268266
zvalue = int(val_list[4])
269267
self.TouchSignal.emit(zvalue,'axisz4')
270-
268+
271269
if val_list[3] == '47':
272-
if val_list[4] == '0':
273-
circle5Visible = True
270+
if val_list[4] == '4':
271+
circle5flage = True
272+
if circle5flage == True:
273+
if val_list[3] == '47':
274+
if val_list[4] == '0':
275+
circle5Visible = True
274276
if circle5Visible == True:
275277
if val_list[3] == '53':
276278
xvalue = int(val_list[4])
@@ -281,10 +283,9 @@ def run(self):
281283
if val_list[3] == '48':
282284
zvalue = int(val_list[4])
283285
self.TouchSignal.emit(zvalue,'axisz5')
284-
286+
285287
if event.type == ecodes.EV_SYN:
286288
break
287-
288289

289290

290291

@@ -317,81 +318,66 @@ def Lcdlightset(self,val):
317318
#Camera
318319
@Slot()
319320
def Cameraon(self):
320-
# print("camera on")
321321
os.system('sudo sed -i "s/start_x=0/start_x=1/g" /boot/config.txt')
322322
@Slot()
323323
def Cameraoff(self):
324-
# print("camera off")
325324
os.system('sudo sed -i "s/start_x=1/start_x=0/g" /boot/config.txt')
326325

327326
#SSH
328327
@Slot()
329328
def SSHon(self):
330-
# print("ssh on")
331329
os.system('sudo ln -s /lib/systemd/system/ssh.service /etc/systemd/system/multi-user.target.wants/ssh.service')
332330
@Slot()
333331
def SSHoff(self):
334-
# print("ssh off")
335332
os.system('sudo rm /etc/systemd/system/multi-user.target.wants/ssh.service')
336333

337334
#VNC
338335
@Slot()
339336
def VNCon(self):
340-
# print("vnc on")
341337
os.system('sudo ln -s /usr/lib/systemd/system/vncserver-x11-serviced.service /etc/systemd/system/multi-user.target.wants/vncserver-x11-serviced.service')
342338
@Slot()
343339
def VNCoff(self):
344-
# print("vnc off")
345340
os.system('sudo rm /etc/systemd/system/multi-user.target.wants/vncserver-x11-serviced.service')
346341

347342

348343

349344
#SPI
350345
@Slot()
351346
def SPIon(self):
352-
# print("SPI on")
353347
os.system('sudo sed -i "s/dtparam=spi=off/dtparam=spi=on/g" /boot/config.txt')
354348
@Slot()
355349
def SPIoff(self):
356-
# print("SPI off")
357350
os.system('sudo sed -i "s/dtparam=spi=on/dtparam=spi=off/g" /boot/config.txt')
358351

359352
#I2C
360353
@Slot()
361354
def I2Con(self):
362-
# print("i2c on")
363355
os.system('sudo sed -i "s/dtparam=i2c_arm=off/dtparam=i2c_arm=on/g" /boot/config.txt')
364356
@Slot()
365357
def I2Coff(self):
366-
# print("i2c off")
367358
os.system('sudo sed -i "s/dtparam=i2c_arm=on/dtparam=i2c_arm=off/g" /boot/config.txt')
368359

369360
#Serial
370361
@Slot()
371362
def Serialon(self):
372-
# print("Serial on")
373363
os.system('sudo sed -i "s/enable_uart=0/enable_uart=1/g" /boot/config.txt')
374364
@Slot()
375365
def Serialoff(self):
376-
# print("Serial off")
377366
os.system('sudo sed -i "s/enable_uart=1/enable_uart=0/g" /boot/config.txt')
378367

379368
#Shutdown
380369
@Slot()
381370
def Shutdown(self):
382-
# print("Shutdown")
383371
os.system('sudo shutdown now')
384372

385373
#Reboot
386374
@Slot()
387375
def Rebooton(self):
388-
# print("Rebooton")
389376
os.system('sudo reboot')
390377

391378
#Logout
392379
@Slot()
393380
def Logout(self):
394-
# print("Logout")
395381
sys.exit()
396382

397383

@@ -404,27 +390,24 @@ def Logout(self):
404390
engine = QQmlApplicationEngine()
405391
url = QUrl("NewbuttonUI.qml")
406392
# url = QUrl("Ui.ui.qml")
393+
context = engine.rootContext()
407394

408395
appFilePath = os.getcwd()
409396
os.chdir(deviceFilePath)
410397
number = len(os.listdir(os.getcwd()))
411398
for num in range(0,number):
412399
namePath ="/sys/class/input/event%d/device/name"%(num)
413-
print(namePath)
414400
if os.path.isfile(namePath):
415401
f = open(namePath,'r')
416402
devname = f.read().split('\n')[0]
417403
if devname == 'seeed-tp':
418404
tpfilePath = intputdevPath + "event%d"%(num)
419-
print("aaaa: %s" % tpfilePath)
420405
f.close()
421406
if devname == 'gpio_keys':
422407
LedsKeyPath = intputdevPath + "event%d"%(num)
423-
print("bbbb: %s" % LedsKeyPath)
424408
f.close()
425409
if devname == 'ST LIS3LV02DL Accelerometer':
426410
AcceleratorPath = intputdevPath + "event%d"%(num)
427-
print("cccc: %s" % AcceleratorPath)
428411
f.close()
429412
os.chdir(appFilePath)
430413

@@ -437,33 +420,30 @@ def Logout(self):
437420

438421
if tpfilePath:
439422
touchpanel = TouchPanel(tpfilePath)
423+
context.setContextProperty("_TouchPanel", touchpanel)
424+
touchpanel.start()
440425
if LedsKeyPath:
441426
ledkey = LedsKey(LedsKeyPath)
427+
context.setContextProperty("_LedsKey", ledkey)
428+
ledkey.start()
442429
if AcceleratorPath:
443430
axis = Accelerator(AcceleratorPath)
431+
context.setContextProperty("_Accelerator", axis)
432+
axis.start()
433+
444434

445435
# context = view.rootContext()
446-
context = engine.rootContext()
447436
context.setContextProperty("_CpuUsage", cpu)
448437
context.setContextProperty("_Cputemperature", cputem)
449438
context.setContextProperty("_RamUsage", arm)
450439
context.setContextProperty("_StorageUsage", Storage)
451-
context.setContextProperty("_Accelerator", axis)
452440
context.setContextProperty("_Systeminfo", sysinfo)
453-
context.setContextProperty("_LedsKey", ledkey)
454-
context.setContextProperty("_TouchPanel", touchpanel)
455-
456441
context.setContextProperty("_Settting", seting)
457442

458-
459-
460443
cpu.start()
461444
cputem.start()
462445
arm.start()
463446
Storage.start()
464-
axis.start()
465-
ledkey.start()
466-
touchpanel.start()
467447
sysinfo.start()
468448

469449
# view.setSource(url)

0 commit comments

Comments
 (0)