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
| #!/usr/bin/python3
# coding: utf-8
from tkinter import *
import serial
commandePhoto = [0x18, 0x39, 0x0d, 0x0a]
commandeVideo = [0b00011000, 0x3a, 0x0d, 0x0a]
commandeFocusNear = [0b00101000, 0x47, 0x0d, 0x0a]
commandeFocusFar = [0b00101000, 0x45, 0x0d, 0x0a]
ser = serial.Serial('/dev/ttyUSB0')
def takePhoto():
for i in range (4):
ser.write(commandePhoto[i])
def takeVideo():
for i in range (4):
ser.write(commandeVideo[i])
def focusNear():
for i in range (4):
ser.write(commandeFocusNear[i])
def focusFar():
for i in range (4):
ser.write(commandeFocusFar[i])
Mafenetre = Tk()
Mafenetre.title('Télécommande LANC')
Mafenetre.geometry('350x100+400+400')
boutonPhoto = Button(Mafenetre, text ='Photo', command = takePhoto)
boutonPhoto.pack(side = LEFT, padx = 5, pady = 5)
boutonVideo = Button(Mafenetre, text ='Video', command = takeVideo)
boutonVideo.pack(side = LEFT, padx = 5, pady = 5)
boutonFocusNear = Button(Mafenetre, text ='Focus near', command = focusNear)
boutonFocusNear.pack(side = LEFT, padx = 5, pady = 5)
boutonFocusFar = Button(Mafenetre, text ='Focus far', command = focusFar)
boutonFocusFar.pack(side = LEFT, padx = 5, pady = 5)
Texte = StringVar()
LabelResultat = Label(Mafenetre, textvariable = Texte, fg ='red', bg ='white')
LabelResultat.pack(side = LEFT, padx = 5, pady = 5)
Mafenetre.mainloop() |
Partager