@@ -189,17 +189,19 @@ def __init__(self,path):
189
189
def run (self ):
190
190
while True :
191
191
touch = InputDevice (self .Path )
192
- # print(touch)
193
192
circle1Visible = False
194
193
circle2Visible = False
195
194
circle3Visible = False
195
+ circle3flage = False
196
196
circle4Visible = False
197
+ circle4flage = False
197
198
circle5Visible = False
199
+ circle5flage = False
198
200
for event in touch .read_loop ():
199
201
if event .type == ecodes .EV_ABS :
200
202
touchevents = repr (event )
201
203
val_list = touchevents .replace ('(' ,'' ).replace (')' ,'' ).replace (' ' ,'' ).split (',' )
202
- # print(val_list)
204
+ print (val_list )
203
205
if val_list [3 ] == '53' :
204
206
xvalue = int (val_list [4 ])
205
207
self .TouchSignal .emit (xvalue ,'axisx1' )
@@ -213,21 +215,10 @@ def run(self):
213
215
if val_list [3 ] == '47' :
214
216
if val_list [4 ] == '1' :
215
217
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
231
222
if circle2Visible == True :
232
223
if val_list [3 ] == '53' :
233
224
xvalue = int (val_list [4 ])
@@ -239,10 +230,13 @@ def run(self):
239
230
zvalue = int (val_list [4 ])
240
231
self .TouchSignal .emit (zvalue ,'axisz2' )
241
232
242
-
243
233
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
246
240
if circle3Visible == True :
247
241
if val_list [3 ] == '53' :
248
242
xvalue = int (val_list [4 ])
@@ -255,8 +249,12 @@ def run(self):
255
249
self .TouchSignal .emit (zvalue ,'axisz3' )
256
250
257
251
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
260
258
if circle4Visible == True :
261
259
if val_list [3 ] == '53' :
262
260
xvalue = int (val_list [4 ])
@@ -267,10 +265,14 @@ def run(self):
267
265
if val_list [3 ] == '48' :
268
266
zvalue = int (val_list [4 ])
269
267
self .TouchSignal .emit (zvalue ,'axisz4' )
270
-
268
+
271
269
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
274
276
if circle5Visible == True :
275
277
if val_list [3 ] == '53' :
276
278
xvalue = int (val_list [4 ])
@@ -281,10 +283,9 @@ def run(self):
281
283
if val_list [3 ] == '48' :
282
284
zvalue = int (val_list [4 ])
283
285
self .TouchSignal .emit (zvalue ,'axisz5' )
284
-
286
+
285
287
if event .type == ecodes .EV_SYN :
286
288
break
287
-
288
289
289
290
290
291
@@ -317,81 +318,66 @@ def Lcdlightset(self,val):
317
318
#Camera
318
319
@Slot ()
319
320
def Cameraon (self ):
320
- # print("camera on")
321
321
os .system ('sudo sed -i "s/start_x=0/start_x=1/g" /boot/config.txt' )
322
322
@Slot ()
323
323
def Cameraoff (self ):
324
- # print("camera off")
325
324
os .system ('sudo sed -i "s/start_x=1/start_x=0/g" /boot/config.txt' )
326
325
327
326
#SSH
328
327
@Slot ()
329
328
def SSHon (self ):
330
- # print("ssh on")
331
329
os .system ('sudo ln -s /lib/systemd/system/ssh.service /etc/systemd/system/multi-user.target.wants/ssh.service' )
332
330
@Slot ()
333
331
def SSHoff (self ):
334
- # print("ssh off")
335
332
os .system ('sudo rm /etc/systemd/system/multi-user.target.wants/ssh.service' )
336
333
337
334
#VNC
338
335
@Slot ()
339
336
def VNCon (self ):
340
- # print("vnc on")
341
337
os .system ('sudo ln -s /usr/lib/systemd/system/vncserver-x11-serviced.service /etc/systemd/system/multi-user.target.wants/vncserver-x11-serviced.service' )
342
338
@Slot ()
343
339
def VNCoff (self ):
344
- # print("vnc off")
345
340
os .system ('sudo rm /etc/systemd/system/multi-user.target.wants/vncserver-x11-serviced.service' )
346
341
347
342
348
343
349
344
#SPI
350
345
@Slot ()
351
346
def SPIon (self ):
352
- # print("SPI on")
353
347
os .system ('sudo sed -i "s/dtparam=spi=off/dtparam=spi=on/g" /boot/config.txt' )
354
348
@Slot ()
355
349
def SPIoff (self ):
356
- # print("SPI off")
357
350
os .system ('sudo sed -i "s/dtparam=spi=on/dtparam=spi=off/g" /boot/config.txt' )
358
351
359
352
#I2C
360
353
@Slot ()
361
354
def I2Con (self ):
362
- # print("i2c on")
363
355
os .system ('sudo sed -i "s/dtparam=i2c_arm=off/dtparam=i2c_arm=on/g" /boot/config.txt' )
364
356
@Slot ()
365
357
def I2Coff (self ):
366
- # print("i2c off")
367
358
os .system ('sudo sed -i "s/dtparam=i2c_arm=on/dtparam=i2c_arm=off/g" /boot/config.txt' )
368
359
369
360
#Serial
370
361
@Slot ()
371
362
def Serialon (self ):
372
- # print("Serial on")
373
363
os .system ('sudo sed -i "s/enable_uart=0/enable_uart=1/g" /boot/config.txt' )
374
364
@Slot ()
375
365
def Serialoff (self ):
376
- # print("Serial off")
377
366
os .system ('sudo sed -i "s/enable_uart=1/enable_uart=0/g" /boot/config.txt' )
378
367
379
368
#Shutdown
380
369
@Slot ()
381
370
def Shutdown (self ):
382
- # print("Shutdown")
383
371
os .system ('sudo shutdown now' )
384
372
385
373
#Reboot
386
374
@Slot ()
387
375
def Rebooton (self ):
388
- # print("Rebooton")
389
376
os .system ('sudo reboot' )
390
377
391
378
#Logout
392
379
@Slot ()
393
380
def Logout (self ):
394
- # print("Logout")
395
381
sys .exit ()
396
382
397
383
@@ -404,27 +390,24 @@ def Logout(self):
404
390
engine = QQmlApplicationEngine ()
405
391
url = QUrl ("NewbuttonUI.qml" )
406
392
# url = QUrl("Ui.ui.qml")
393
+ context = engine .rootContext ()
407
394
408
395
appFilePath = os .getcwd ()
409
396
os .chdir (deviceFilePath )
410
397
number = len (os .listdir (os .getcwd ()))
411
398
for num in range (0 ,number ):
412
399
namePath = "/sys/class/input/event%d/device/name" % (num )
413
- print (namePath )
414
400
if os .path .isfile (namePath ):
415
401
f = open (namePath ,'r' )
416
402
devname = f .read ().split ('\n ' )[0 ]
417
403
if devname == 'seeed-tp' :
418
404
tpfilePath = intputdevPath + "event%d" % (num )
419
- print ("aaaa: %s" % tpfilePath )
420
405
f .close ()
421
406
if devname == 'gpio_keys' :
422
407
LedsKeyPath = intputdevPath + "event%d" % (num )
423
- print ("bbbb: %s" % LedsKeyPath )
424
408
f .close ()
425
409
if devname == 'ST LIS3LV02DL Accelerometer' :
426
410
AcceleratorPath = intputdevPath + "event%d" % (num )
427
- print ("cccc: %s" % AcceleratorPath )
428
411
f .close ()
429
412
os .chdir (appFilePath )
430
413
@@ -437,33 +420,30 @@ def Logout(self):
437
420
438
421
if tpfilePath :
439
422
touchpanel = TouchPanel (tpfilePath )
423
+ context .setContextProperty ("_TouchPanel" , touchpanel )
424
+ touchpanel .start ()
440
425
if LedsKeyPath :
441
426
ledkey = LedsKey (LedsKeyPath )
427
+ context .setContextProperty ("_LedsKey" , ledkey )
428
+ ledkey .start ()
442
429
if AcceleratorPath :
443
430
axis = Accelerator (AcceleratorPath )
431
+ context .setContextProperty ("_Accelerator" , axis )
432
+ axis .start ()
433
+
444
434
445
435
# context = view.rootContext()
446
- context = engine .rootContext ()
447
436
context .setContextProperty ("_CpuUsage" , cpu )
448
437
context .setContextProperty ("_Cputemperature" , cputem )
449
438
context .setContextProperty ("_RamUsage" , arm )
450
439
context .setContextProperty ("_StorageUsage" , Storage )
451
- context .setContextProperty ("_Accelerator" , axis )
452
440
context .setContextProperty ("_Systeminfo" , sysinfo )
453
- context .setContextProperty ("_LedsKey" , ledkey )
454
- context .setContextProperty ("_TouchPanel" , touchpanel )
455
-
456
441
context .setContextProperty ("_Settting" , seting )
457
442
458
-
459
-
460
443
cpu .start ()
461
444
cputem .start ()
462
445
arm .start ()
463
446
Storage .start ()
464
- axis .start ()
465
- ledkey .start ()
466
- touchpanel .start ()
467
447
sysinfo .start ()
468
448
469
449
# view.setSource(url)
0 commit comments