Interface gráfica reformulada, novos recursos e ícones acrescentados

parent bb8c8523
Ícones feitos por <a href="https://www.flaticon.com/br/autores/becris" title="Becris">Becris</a> from <a href="https://www.flaticon.com/br/" title="Flaticon"> www.flaticon.com</a>
Ícones feitos por <a href="https://www.flaticon.com/br/autores/kiranshastry" title="Kiranshastry">Kiranshastry</a> from <a href="https://www.flaticon.com/br/" title="Flaticon"> www.flaticon.com</a>
Ícones feitos por <a href="https://www.flaticon.com/br/autores/becris" title="Becris">Becris</a> from <a href="https://www.flaticon.com/br/" title="Flaticon"> www.flaticon.com</a>
Ícones feitos por <a href="https://www.flaticon.com/br/autores/bqlqn" title="bqlqn">bqlqn</a> from <a href="https://www.flaticon.com/br/" title="Flaticon"> www.flaticon.com</a>
Ícones feitos por <a href="https://www.flaticon.com/br/autores/freepik" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/br/" title="Flaticon"> www.flaticon.com</a>
\ No newline at end of file
......@@ -2,7 +2,10 @@ from tkinter import *
from tkinter.scrolledtext import ScrolledText
from PIL import Image, ImageTk
import time
import serial
import serial.tools.list_ports
import datetime
import tkinter.font as font
global i
global n_items_basal
......@@ -15,18 +18,19 @@ global height_items_tbs
global n_items_pbs
global height_items_pbs
#Define janela de tela cheia
root = Tk()
root.state('zoomed')
root.title('Neuroestimulador - Gerenciador de protocolos v1.0')
root.title('Neuroestimulador - Gerenciador de protocolos')
root.resizable(False, False)
canvas_big = Canvas(root, bg='black')
canvas_big = Canvas(root, bg='LightCyan4')
canvas_big.place(relx=0, rely=0, relwidth=1, relheight=1)
#--------------------------------------------------Tela 1 (lateral esquerda)-------------------------------------------------------
canvas1 = Canvas(canvas_big, bg='LightSteelBlue1')
canvas1.place(relx=0.025, rely=0.0125, relwidth=0.3, relheight=0.7)
canvas1.place(relx=0.025, rely=0.275, relwidth=0.3, relheight=0.7)
#Seleção de protocolo:
......@@ -40,14 +44,14 @@ protocol_list1.insert(2,"Basal bipolar")
protocol_list1.insert(3,"TBS unipolar")
protocol_list1.insert(4,"TBS bipolar")
protocol_list1.insert(5,"PBS")
protocol_list1.place(relx=0.1, rely=0.075, relwidth=0.5, relheight=0.15)
protocol_list1.place(relx=0.1, rely=0.075, relwidth=0.5, relheight=0.165)
button_prot_1 = Button(canvas1, text="Selecionar", command = lambda:select_protocol(canvas1, protocol_list1.get(ACTIVE)))
button_prot_1.place(relx=0.6, rely=0.075, relwidth=0.3, relheight=0.15)
button_prot_1.place(relx=0.6, rely=0.075, relwidth=0.3, relheight=0.165)
#--------------------------------------------------Tela 2 (meio)-------------------------------------------------------
canvas2 = Canvas(canvas_big, bg='LightSteelBlue1')
canvas2.place(relx=0.35, rely=0.0125, relwidth=0.3, relheight=0.7)
canvas2.place(relx=0.35, rely=0.275, relwidth=0.3, relheight=0.7)
#Seleção de protocolo:
......@@ -61,15 +65,15 @@ protocol_list2.insert(2,"Basal bipolar")
protocol_list2.insert(3,"TBS unipolar")
protocol_list2.insert(4,"TBS bipolar")
protocol_list2.insert(5,"PBS")
protocol_list2.place(relx=0.1, rely=0.075, relwidth=0.5, relheight=0.15)
protocol_list2.place(relx=0.1, rely=0.075, relwidth=0.5, relheight=0.165)
button_prot_2 = Button(canvas2, text="Selecionar", command = lambda:select_protocol(canvas2, protocol_list2.get(ACTIVE)))
button_prot_2.place(relx=0.6, rely=0.075, relwidth=0.3, relheight=0.15)
button_prot_2.place(relx=0.6, rely=0.075, relwidth=0.3, relheight=0.165)
#--------------------------------------------------Tela 3 (lateral direita)-------------------------------------------------------
canvas3 = Canvas(canvas_big, bg='LightSteelBlue1')
canvas3.place(relx=0.675, rely=0.0125, relwidth=0.3, relheight=0.7)
canvas3.place(relx=0.675, rely=0.275, relwidth=0.3, relheight=0.7)
#Seleção de protocolo:
......@@ -83,38 +87,94 @@ protocol_list3.insert(2,"Basal bipolar")
protocol_list3.insert(3,"TBS unipolar")
protocol_list3.insert(4,"TBS bipolar")
protocol_list3.insert(5,"PBS")
protocol_list3.place(relx=0.1, rely=0.075, relwidth=0.5, relheight=0.15)
protocol_list3.place(relx=0.1, rely=0.075, relwidth=0.5, relheight=0.165)
button_prot_3 = Button(canvas3, text="Selecionar", command = lambda:select_protocol(canvas3, protocol_list3.get(ACTIVE)))
button_prot_3.place(relx=0.6, rely=0.075, relwidth=0.3, relheight=0.15)
#--------------------------------------------------Tela de avisos (log) e envios ao microcontrolador--------------------------------------------
canvas4 = Canvas(canvas_big, bg='DeepSkyBlue3')
canvas4.place(relx=0.025, rely=0.725, relwidth=0.95, relheight=0.25)
log = Text(canvas4)
log.place(relx=0.025, rely=0.075, relwidth=0.5, relheight=0.85)
button_prot_3.place(relx=0.6, rely=0.075, relwidth=0.3, relheight=0.165)
#--------------------------------------------------Tela de avisos (log), ajuda, info e envios ao microcontrolador--------------------------------------------
canvas4 = Canvas(canvas_big, bg='LightCyan2')
canvas4.place(relx=0.025, rely=0.0125, relwidth=0.95, relheight=0.25)
canvaslog = Canvas(canvas4, bg='LightCyan2')
canvaslog.place(relx=0.55, rely=0.075, relwidth=0.42, relheight=0.85)
scroll = Scrollbar(canvaslog)
scroll.pack(side="right",fill="y",expand=False)
log = Text(canvaslog, yscrollcommand=scroll.set)
log.place(relx=0, rely=0, relwidth=0.97, relheight=1)
log.config(state='disabled')
button_con = Button(canvas4, text="Estabelecer conexão com Arduino", command = lambda:detect_arduino())
button_con.place(relx=0.6, rely=0.1, relwidth=0.35, relheight=0.15)
button_send = Button(canvas4, text="Iniciar protocolos selecionados", command = lambda:send_protocol())
button_send.place(relx=0.6, rely=0.3, relwidth=0.35, relheight=0.15)
button_int = Button(canvas4, text="Interromper estimulação", command = lambda:interrupt_protocol())
button_int.place(relx=0.6, rely=0.5, relwidth=0.35, relheight=0.15)
def writeToLog(msg):
scroll.config(command=log.yview)
con_img = Image.open("img_con.PNG")
con_image = ImageTk.PhotoImage(con_img.resize((20,20)))
play_img = Image.open("img_play.PNG")
play_image = ImageTk.PhotoImage(play_img.resize((20,20)))
stop_img = Image.open("img_stop.PNG")
stop_image = ImageTk.PhotoImage(stop_img.resize((20,20)))
skip_img = Image.open("img_skip.PNG")
skip_image = ImageTk.PhotoImage(skip_img.resize((20,20)))
button_con = Button(canvas4, text=" Estabelecer conexão com Arduino", image=con_image, compound="left", command = lambda:detect_arduino())
button_con.place(relx=0.33, rely=0.1, relwidth=0.2, relheight=0.15)
button_send = Button(canvas4, text=" Iniciar protocolos selecionados", image=play_image, compound="left", command = lambda:send_protocol())
button_send.place(relx=0.33, rely=0.3, relwidth=0.2, relheight=0.15)
button_int = Button(canvas4, text=" Parar processo de estimulação", image=stop_image, compound="left", command = lambda:interrupt_protocol())
button_int.place(relx=0.33, rely=0.5, relwidth=0.2, relheight=0.15)
button_skip = Button(canvas4, text=" Avançar para próximo protocolo", image=skip_image, compound="left", command = lambda:jump_protocol())
button_skip.place(relx=0.33, rely=0.7, relwidth=0.2, relheight=0.15)
est_image = Image.open("neuroest.PNG")
est_photo = ImageTk.PhotoImage(est_image.resize((100,100)))
est_label = Label(canvas4, image=est_photo)
est_label.image = est_image
est_label.place(relx=0.015, rely=0.1, relwidth=0.076, relheight=0.52)
myFont = font.Font(family='Helvetica', size=12, weight='bold')
tit_text = Label(canvas4, text="Neuroestimulador", font = myFont, bg='LightCyan2')
tit_text.place(relx=0.1, rely=0.1, relwidth=0.15, relheight=0.1)
tit_text = Label(canvas4, text="Gerenciador de protocolos", bg='LightCyan2')
tit_text.place(relx=0.1, rely=0.2, relwidth=0.15, relheight=0.1)
help_img = Image.open("img_help.PNG")
help_image = ImageTk.PhotoImage(help_img.resize((20,20)))
button_help = Button(canvas4, text=" Ajuda", image=help_image, compound="left", command = lambda:interrupt_protocol())
button_help.place(relx=0.1, rely=0.4, relwidth=0.15, relheight=0.15)
ab_img = Image.open("img_ab.PNG")
ab_image = ImageTk.PhotoImage(ab_img.resize((20,20)))
button_ab = Button(canvas4, text=" Sobre", image=ab_image, compound="left", command = lambda:windowAbout())
button_ab.place(relx=0.1, rely=0.6, relwidth=0.15, relheight=0.15)
#Função para escrita no log:
def writeToLog(msg):
numlines = log.index('end - 1 line').split('.')[0]
log['state'] = 'normal'
if numlines==9:
log.delete(1.0, 2.0)
if log.index('end-1c')!='1.0':
log.insert('end', '\n')
now = datetime.datetime.now()
log.insert('end', "[")
log.insert('end', now.hour)
log.insert('end', ":")
log.insert('end', now.minute)
log.insert('end', "]")
log.insert('end', " ")
log.insert('end', msg)
log['state'] = 'disabled'
log.see("end")
#Função para definicação de protocolo:
def select_protocol(canvas, protocol):
def InputValidation(S):
if S.isdigit():
return True
else:
canvas.bell()
return False
vcmd = (canvas.register(InputValidation), '%S')
list = canvas.place_slaves()
for l in list:
if(l!=prot_text1 and l!=prot_text2 and l!=prot_text3 and l!=protocol_list1 and l!=protocol_list2 and l!=protocol_list3 and l!=button_prot_1 and l!=button_prot_2 and l!=button_prot_3):
......@@ -124,34 +184,34 @@ def select_protocol(canvas, protocol):
prot_photo = ImageTk.PhotoImage(prot_image.resize((420,110)))
prot_label = Label(canvas, image=prot_photo)
prot_label.image = prot_photo
prot_label.place(relx=0.0, rely=0.225, relwidth=1, relheight=0.275)
prot_label.place(relx=0.0, rely=0.24, relwidth=1, relheight=0.275)
n_items_basal = 6
height_items_basal = 0.5 / n_items_basal
i=0
T_text = Label(canvas, text="Intervalo T (us):")
T_text.place(relx=0, rely=0.5+(i*height_items_basal), relwidth=0.4, relheight=height_items_basal)
T_entry = Entry(canvas, justify=CENTER)
T_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
T_entry.place(relx=0.4, rely=0.5+(i*height_items_basal), relwidth=0.3, relheight=height_items_basal)
T_lim = Label(canvas, text="Limites: 5us-1000us")
T_lim.place(relx=0.6, rely=0.5+(i*height_items_basal), relwidth=0.4, relheight=height_items_basal)
i = i+1
IPI_text = Label(canvas, text="Intervalo IPI (ms):")
IPI_text.place(relx=0, rely=0.5+(i*height_items_basal), relwidth=0.4, relheight=height_items_basal)
IPI_entry = Entry(canvas, justify=CENTER)
IPI_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
IPI_entry.place(relx=0.4, rely=0.5+(i*height_items_basal), relwidth=0.3, relheight=height_items_basal)
IPI_lim = Label(canvas, text="Limites: 1ms-64ms")
IPI_lim.place(relx=0.6, rely=0.5+(i*height_items_basal), relwidth=0.4, relheight=height_items_basal)
i = i+1
ITI_text = Label(canvas, text="Intervalo ITI (s):")
ITI_text.place(relx=0, rely=0.5+(i*height_items_basal), relwidth=0.4, relheight=height_items_basal)
ITI_entry = Entry(canvas, justify=CENTER)
ITI_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
ITI_entry.place(relx=0.4, rely=0.5+(i*height_items_basal), relwidth=0.3, relheight=height_items_basal)
ITI_lim = Label(canvas, text="Limites: 1s-4s")
ITI_lim.place(relx=0.6, rely=0.5+(i*height_items_basal), relwidth=0.4, relheight=height_items_basal)
i = i+1
dur_text = Label(canvas, text="Duração (min):")
dur_text.place(relx=0, rely=0.5+(i*height_items_basal), relwidth=0.4, relheight=height_items_basal)
dur_entry = Entry(canvas, justify=CENTER)
dur_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
dur_entry.place(relx=0.4, rely=0.5+(i*height_items_basal), relwidth=0.3, relheight=height_items_basal)
dur_lim = Label(canvas, text="Limites: 1min - 30min")
dur_lim.place(relx=0.6, rely=0.5+(i*height_items_basal), relwidth=0.4, relheight=height_items_basal)
......@@ -174,34 +234,34 @@ def select_protocol(canvas, protocol):
prot_photo = ImageTk.PhotoImage(prot_image.resize((420,110)))
prot_label = Label(canvas, image=prot_photo)
prot_label.image = prot_photo
prot_label.place(relx=0.0, rely=0.225, relwidth=1, relheight=0.275)
prot_label.place(relx=0.0, rely=0.24, relwidth=1, relheight=0.275)
n_items_basal_bi = 6
height_items_basal_bi = 0.5 / n_items_basal_bi
i=0
T_text = Label(canvas, text="Intervalo T (us):")
T_text.place(relx=0, rely=0.5+(i*height_items_basal_bi), relwidth=0.4, relheight=height_items_basal_bi)
T_entry = Entry(canvas, justify=CENTER)
T_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
T_entry.place(relx=0.4, rely=0.5+(i*height_items_basal_bi), relwidth=0.3, relheight=height_items_basal_bi)
T_lim = Label(canvas, text="Limites: 5us-1000us")
T_lim.place(relx=0.6, rely=0.5+(i*height_items_basal_bi), relwidth=0.4, relheight=height_items_basal_bi)
i = i+1
IPI_text = Label(canvas, text="Intervalo IPI (ms):")
IPI_text.place(relx=0, rely=0.5+(i*height_items_basal_bi), relwidth=0.4, relheight=height_items_basal_bi)
IPI_entry = Entry(canvas, justify=CENTER)
IPI_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
IPI_entry.place(relx=0.4, rely=0.5+(i*height_items_basal_bi), relwidth=0.3, relheight=height_items_basal_bi)
IPI_lim = Label(canvas, text="Limites: 1ms-64ms")
IPI_lim.place(relx=0.6, rely=0.5+(i*height_items_basal_bi), relwidth=0.4, relheight=height_items_basal_bi)
i = i+1
ITI_text = Label(canvas, text="Intervalo ITI (s):")
ITI_text.place(relx=0, rely=0.5+(i*height_items_basal_bi), relwidth=0.4, relheight=height_items_basal_bi)
ITI_entry = Entry(canvas, justify=CENTER)
ITI_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
ITI_entry.place(relx=0.4, rely=0.5+(i*height_items_basal_bi), relwidth=0.3, relheight=height_items_basal_bi)
ITI_lim = Label(canvas, text="Limites: 1s-4s")
ITI_lim.place(relx=0.6, rely=0.5+(i*height_items_basal_bi), relwidth=0.4, relheight=height_items_basal_bi)
i = i+1
dur_text = Label(canvas, text="Duração (min):")
dur_text.place(relx=0, rely=0.5+(i*height_items_basal_bi), relwidth=0.4, relheight=height_items_basal_bi)
dur_entry = Entry(canvas, justify=CENTER)
dur_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
dur_entry.place(relx=0.4, rely=0.5+(i*height_items_basal_bi), relwidth=0.3, relheight=height_items_basal_bi)
dur_lim = Label(canvas, text="Limites: 1min - 30min")
dur_lim.place(relx=0.6, rely=0.5+(i*height_items_basal_bi), relwidth=0.4, relheight=height_items_basal_bi)
......@@ -224,48 +284,48 @@ def select_protocol(canvas, protocol):
prot_photo = ImageTk.PhotoImage(prot_image.resize((450,130)))
prot_label = Label(canvas, image=prot_photo)
prot_label.image = prot_photo
prot_label.place(relx=0.0, rely=0.225, relwidth=1, relheight=0.275)
prot_label.place(relx=0.0, rely=0.24, relwidth=1, relheight=0.275)
n_items_tbs = 9
height_items_tbs = 0.5 / n_items_tbs
i=0
T_text = Label(canvas, text="Intervalo T (ms):")
T_text.place(relx=0, rely=0.5+(i*height_items_tbs), relwidth=0.4, relheight=height_items_tbs)
T_entry = Entry(canvas, justify=CENTER)
T_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
T_entry.place(relx=0.4, rely=0.5+(i*height_items_tbs), relwidth=0.3, relheight=height_items_tbs)
T_lim = Label(canvas, text="Limites: 1ms-100ms")
T_lim.place(relx=0.6, rely=0.5+(i*height_items_tbs), relwidth=0.4, relheight=height_items_tbs)
i=i+1
IPI_text = Label(canvas, text="Intervalo IPI (ms):")
IPI_text.place(relx=0, rely=0.5+(i*height_items_tbs), relwidth=0.4, relheight=height_items_tbs)
IPI_entry = Entry(canvas, justify=CENTER)
IPI_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
IPI_entry.place(relx=0.4, rely=0.5+(i*height_items_tbs), relwidth=0.3, relheight=height_items_tbs)
IPI_lim = Label(canvas, text="Limites: 1ms-100ms")
IPI_lim.place(relx=0.6, rely=0.5+(i*height_items_tbs), relwidth=0.4, relheight=height_items_tbs)
i=i+1
n_ep_text = Label(canvas, text="Nº de epochs por trem:")
n_ep_text.place(relx=0, rely=0.5+(i*height_items_tbs), relwidth=0.4, relheight=height_items_tbs)
n_ep_entry = Entry(canvas, justify=CENTER)
n_ep_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
n_ep_entry.place(relx=0.4, rely=0.5+(i*height_items_tbs), relwidth=0.3, relheight=height_items_tbs)
n_ep_lim = Label(canvas, text="Limites: 1-20")
n_ep_lim.place(relx=0.6, rely=0.5+(i*height_items_tbs), relwidth=0.4, relheight=height_items_tbs)
i=i+1
IEI_text = Label(canvas, text="Intervalo IEI (ms):")
IEI_text.place(relx=0, rely=0.5+(i*height_items_tbs), relwidth=0.4, relheight=height_items_tbs)
IEI_entry = Entry(canvas, justify=CENTER)
IEI_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
IEI_entry.place(relx=0.4, rely=0.5+(i*height_items_tbs), relwidth=0.3, relheight=height_items_tbs)
IEI_lim = Label(canvas, text="Limites: 200ms-1000ms")
IEI_lim.place(relx=0.6, rely=0.5+(i*height_items_tbs), relwidth=0.4, relheight=height_items_tbs)
i=i+1
ITI_text = Label(canvas, text="Intervalo ITI (s):")
ITI_text.place(relx=0, rely=0.5+(i*height_items_tbs), relwidth=0.4, relheight=height_items_tbs)
ITI_entry = Entry(canvas, justify=CENTER)
ITI_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
ITI_entry.place(relx=0.4, rely=0.5+(i*height_items_tbs), relwidth=0.3, relheight=height_items_tbs)
ITI_lim = Label(canvas, text="Limites: 1s-20s")
ITI_lim.place(relx=0.6, rely=0.5+(i*height_items_tbs), relwidth=0.4, relheight=height_items_tbs)
i=i+1
dur_text = Label(canvas, text="Duração (min):")
dur_text.place(relx=0, rely=0.5+(i*height_items_tbs), relwidth=0.4, relheight=height_items_tbs)
dur_entry = Entry(canvas, justify=CENTER)
dur_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
dur_entry.place(relx=0.4, rely=0.5+(i*height_items_tbs), relwidth=0.3, relheight=height_items_tbs)
dur_lim = Label(canvas, text="Limites: 1min - 30min")
dur_lim.place(relx=0.6, rely=0.5+(i*height_items_tbs), relwidth=0.4, relheight=height_items_tbs)
......@@ -285,48 +345,48 @@ def select_protocol(canvas, protocol):
prot_photo = ImageTk.PhotoImage(prot_image.resize((450,130)))
prot_label = Label(canvas, image=prot_photo)
prot_label.image = prot_photo
prot_label.place(relx=0.0, rely=0.225, relwidth=1, relheight=0.275)
prot_label.place(relx=0.0, rely=0.24, relwidth=1, relheight=0.275)
n_items_tbs_bi = 9
height_items_tbs_bi = 0.5 / n_items_tbs_bi
i=0
T_text = Label(canvas, text="Intervalo T (ms):")
T_text.place(relx=0, rely=0.5+(i*height_items_tbs_bi), relwidth=0.4, relheight=height_items_tbs_bi)
T_entry = Entry(canvas, justify=CENTER)
T_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
T_entry.place(relx=0.4, rely=0.5+(i*height_items_tbs_bi), relwidth=0.3, relheight=height_items_tbs_bi)
T_lim = Label(canvas, text="Limites: 1ms-100ms")
T_lim.place(relx=0.6, rely=0.5+(i*height_items_tbs_bi), relwidth=0.4, relheight=height_items_tbs_bi)
i=i+1
IPI_text = Label(canvas, text="Intervalo IPI (ms):")
IPI_text.place(relx=0, rely=0.5+(i*height_items_tbs_bi), relwidth=0.4, relheight=height_items_tbs_bi)
IPI_entry = Entry(canvas, justify=CENTER)
IPI_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
IPI_entry.place(relx=0.4, rely=0.5+(i*height_items_tbs_bi), relwidth=0.3, relheight=height_items_tbs_bi)
IPI_lim = Label(canvas, text="Limites: 1ms-100ms")
IPI_lim.place(relx=0.6, rely=0.5+(i*height_items_tbs_bi), relwidth=0.4, relheight=height_items_tbs_bi)
i=i+1
n_ep_text = Label(canvas, text="Nº de epochs por trem:")
n_ep_text.place(relx=0, rely=0.5+(i*height_items_tbs_bi), relwidth=0.4, relheight=height_items_tbs_bi)
n_ep_entry = Entry(canvas, justify=CENTER)
n_ep_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
n_ep_entry.place(relx=0.4, rely=0.5+(i*height_items_tbs_bi), relwidth=0.3, relheight=height_items_tbs_bi)
n_ep_lim = Label(canvas, text="Limites: 1-20")
n_ep_lim.place(relx=0.6, rely=0.5+(i*height_items_tbs_bi), relwidth=0.4, relheight=height_items_tbs_bi)
i=i+1
IEI_text = Label(canvas, text="Intervalo IEI (ms):")
IEI_text.place(relx=0, rely=0.5+(i*height_items_tbs_bi), relwidth=0.4, relheight=height_items_tbs_bi)
IEI_entry = Entry(canvas, justify=CENTER)
IEI_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
IEI_entry.place(relx=0.4, rely=0.5+(i*height_items_tbs_bi), relwidth=0.3, relheight=height_items_tbs_bi)
IEI_lim = Label(canvas, text="Limites: 200ms-1000ms")
IEI_lim.place(relx=0.6, rely=0.5+(i*height_items_tbs_bi), relwidth=0.4, relheight=height_items_tbs_bi)
i=i+1
ITI_text = Label(canvas, text="Intervalo ITI (s):")
ITI_text.place(relx=0, rely=0.5+(i*height_items_tbs_bi), relwidth=0.4, relheight=height_items_tbs_bi)
ITI_entry = Entry(canvas, justify=CENTER)
ITI_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
ITI_entry.place(relx=0.4, rely=0.5+(i*height_items_tbs_bi), relwidth=0.3, relheight=height_items_tbs_bi)
ITI_lim = Label(canvas, text="Limites: 1s-20s")
ITI_lim.place(relx=0.6, rely=0.5+(i*height_items_tbs_bi), relwidth=0.4, relheight=height_items_tbs_bi)
i=i+1
dur_text = Label(canvas, text="Duração (min):")
dur_text.place(relx=0, rely=0.5+(i*height_items_tbs_bi), relwidth=0.4, relheight=height_items_tbs_bi)
dur_entry = Entry(canvas, justify=CENTER)
dur_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
dur_entry.place(relx=0.4, rely=0.5+(i*height_items_tbs_bi), relwidth=0.3, relheight=height_items_tbs_bi)
dur_lim = Label(canvas, text="Limites: 1min - 30min")
dur_lim.place(relx=0.6, rely=0.5+(i*height_items_tbs_bi), relwidth=0.4, relheight=height_items_tbs_bi)
......@@ -346,48 +406,48 @@ def select_protocol(canvas, protocol):
prot_photo = ImageTk.PhotoImage(prot_image.resize((450,140)))
prot_label = Label(canvas, image=prot_photo)
prot_label.image = prot_photo
prot_label.place(relx=0.0, rely=0.225, relwidth=1, relheight=0.275)
prot_label.place(relx=0.0, rely=0.24, relwidth=1, relheight=0.275)
n_items_pbs = 8
height_items_pbs = 0.5 / n_items_pbs
i=0
PP_text = Label(canvas, text="Intervalo do pulso PP(us):")
PP_text.place(relx=0, rely=0.5+(i*height_items_pbs), relwidth=0.4, relheight=height_items_pbs)
PP_entry = Entry(canvas, justify=CENTER)
PP_text.place(relx=0, rely=0.5+(i*height_items_pbs), relwidth=0.4, relheight=height_items_pbs)
PP_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
PP_entry.place(relx=0.4, rely=0.5+(i*height_items_pbs), relwidth=0.3, relheight=height_items_pbs)
PP_lim = Label(canvas, text="Limites: 5us-1000us")
PP_lim.place(relx=0.6, rely=0.5+(i*height_items_pbs), relwidth=0.4, relheight=height_items_pbs)
i=i+1
PPI_text = Label(canvas, text="Intervalo PPI (ms):")
PPI_text.place(relx=0, rely=0.5+(i*height_items_pbs), relwidth=0.4, relheight=height_items_pbs)
PPI_entry = Entry(canvas, justify=CENTER)
PPI_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
PPI_entry.place(relx=0.4, rely=0.5+(i*height_items_pbs), relwidth=0.3, relheight=height_items_pbs)
PPI_lim = Label(canvas, text="Limites: 1ms-64ms")
PPI_lim.place(relx=0.6, rely=0.5+(i*height_items_pbs), relwidth=0.4, relheight=height_items_pbs)
i=i+1
T_text = Label(canvas, text="Intervalo T (us):")
T_text.place(relx=0, rely=0.5+(i*height_items_pbs), relwidth=0.4, relheight=height_items_pbs)
T_entry = Entry(canvas, justify=CENTER)
T_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
T_entry.place(relx=0.4, rely=0.5+(i*height_items_pbs), relwidth=0.3, relheight=height_items_pbs)
T_lim = Label(canvas, text="Limites: 5us-1000us")
T_lim.place(relx=0.6, rely=0.5+(i*height_items_pbs), relwidth=0.4, relheight=height_items_pbs)
i=i+1
IPI_text = Label(canvas, text="Intervalo IPI (us):")
IPI_text.place(relx=0, rely=0.5+(i*height_items_pbs), relwidth=0.4, relheight=height_items_pbs)
IPI_entry = Entry(canvas, justify=CENTER)
IPI_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
IPI_entry.place(relx=0.4, rely = 0.5+(i*height_items_pbs), relwidth=0.3, relheight=height_items_pbs)
IPI_lim = Label(canvas, text="Limites: 5us-1000us")
IPI_lim.place(relx=0.6, rely=0.5+(i*height_items_pbs), relwidth=0.4, relheight=height_items_pbs)
i=i+1
IBI_text = Label(canvas, text="Intervalo IBI (ms):")
IBI_text.place(relx=0, rely=0.5+(i*height_items_pbs), relwidth=0.4, relheight=height_items_pbs)
IBI_entry = Entry(canvas, justify=CENTER)
IBI_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
IBI_entry.place(relx=0.4, rely=0.5+(i*height_items_pbs), relwidth=0.3, relheight=height_items_pbs)
IBI_lim = Label(canvas, text="Limites: 200ms-1000ms")
IBI_lim.place(relx=0.6, rely=0.5+(i*height_items_pbs), relwidth=0.4, relheight=height_items_pbs)
i=i+1
dur_text = Label(canvas, text="Duração (min):")
dur_text.place(relx=0, rely=0.5+(i*height_items_pbs), relwidth=0.4, relheight=height_items_pbs)
dur_entry = Entry(canvas, justify=CENTER)
dur_entry = Entry(canvas, justify=CENTER, validate='key', vcmd=vcmd)
dur_entry.place(relx=0.4, rely = 0.5+(i*height_items_pbs), relwidth=0.3, relheight=height_items_pbs)
dur_lim = Label(canvas, text="Limites: 1min - 30min")
dur_lim.place(relx=0.6, rely = 0.5+(i*height_items_pbs), relwidth=0.4, relheight=height_items_pbs)
......@@ -422,29 +482,33 @@ def select_par_basal(canvas, T, IPI, ITI, dur):
global IPI_1
global ITI_1
global dur_1
T_1 = str(T_f)
IPI_1 = str(IPI_f)
ITI_1 = str(ITI_f)
dur_1 = str(dur_f)
T_f += 256
IPI_f += 256
ITI_f += 256
dur_f += 256
T_1 = T_f.to_bytes(2,'little')
IPI_1 = IPI_f.to_bytes(2,'little')
ITI_1 = ITI_f.to_bytes(2,'little')
dur_1 = dur_f.to_bytes(2,'little')
print(T_1)
print(IPI_1)
print(ITI_1)
print(dur_1)
if (canvas==canvas2):
global T_f_2
global IPI_f_2
global ITI_f_2
global dur_f_2
T_f_2 = T_f
IPI_f_2 = IPI_f
ITI_f_2 = ITI_f
dur_f_2 = dur_f
if (canvas==canvas3):
global T_f_3
global IPI_f_3
global ITI_f_3
global dur_f_3
T_f_3 = T_f
IPI_f_3 = IPI_f
ITI_f_3 = ITI_f
dur_f_3 = dur_f
writeToLog("Parâmetros definidos.")
except:
writeToLog("Algum erro ocorreu. Tente preencher todos os parâmetros.")
......@@ -470,29 +534,20 @@ def select_par_basal_bi(canvas, T, IPI, ITI, dur):
global IPI_1
global ITI_1
global dur_1
T_1 = str(T_f)
IPI_1 = str(IPI_f)
ITI_1 = str(ITI_f)
dur_1 = str(dur_f)
if (canvas==canvas2):
global T_f_2
global IPI_f_2
global ITI_f_2
global dur_f_2
T_f_2 = T_f
IPI_f_2 = IPI_f
ITI_f_2 = ITI_f
dur_f_2 = dur_f
if (canvas==canvas3):
global T_f_3
global IPI_f_3
global ITI_f_3
global dur_f_3
T_f_3 = T_f
IPI_f_3 = IPI_f
ITI_f_3 = ITI_f
dur_f_3 = dur_f
writeToLog("Parâmetros definidos.")
except:
writeToLog("Algum erro ocorreu. Tente preencher todos os parâmetros.")
......@@ -529,12 +584,8 @@ def select_par_TBS(canvas, T, IPI, n_ep, IEI, ITI, dur):
global IEI_1
global ITI_1
global dur_1
T_1 = str(T_f)
IPI_1 = str(IPI_f)
n_ep_1 = str(n_ep_f)
IEI_1 = str(IEI_f)
ITI_1 = str(ITI_f)
dur_1 = str(dur_f)
if (canvas==canvas2):
global T_f_2
global IPI_f_2
......@@ -542,12 +593,7 @@ def select_par_TBS(canvas, T, IPI, n_ep, IEI, ITI, dur):
global IEI_f_2
global ITI_f_2
global dur_f_2
T_f_2 = T_f
IPI_f_2 = IPI_f
n_ep_f_2 = n_ep_f
IEI_f_2 = IEI_f
ITI_f_2 = ITI_f
dur_f_2 = dur_f
if (canvas==canvas3):
global T_f_3
global IPI_f_3
......@@ -555,12 +601,7 @@ def select_par_TBS(canvas, T, IPI, n_ep, IEI, ITI, dur):
global IEI_f_3
global ITI_f_3
global dur_f_3
T_f_3 = T_f
IPI_f_3 = IPI_f
n_ep_f_3 = n_ep_f
IEI_f_3 = IEI_f
ITI_f_3 = ITI_f
dur_f_3 = dur_f
writeToLog("Parâmetros definidos.")
except:
writeToLog("Algum erro ocorreu. Tente preencher todos os parâmetros.")
......@@ -596,12 +637,7 @@ def select_par_TBS_bi(canvas, T, IPI, n_ep, IEI, ITI, dur):
global IEI_1
global ITI_1
global dur_1
T_1 = str(T_f)
IPI_1 = str(IPI_f)
n_ep_1 = str(n_ep_f)
IEI_1 = str(IEI_f)
ITI_1 = str(ITI_f)
dur_1 = str(dur_f)
if (canvas==canvas2):
global T_f_2
global IPI_f_2
......@@ -609,12 +645,7 @@ def select_par_TBS_bi(canvas, T, IPI, n_ep, IEI, ITI, dur):
global IEI_f_2
global ITI_f_2
global dur_f_2
T_f_2 = T_f
IPI_f_2 = IPI_f
n_ep_f_2 = n_ep_f
IEI_f_2 = IEI_f
ITI_f_2 = ITI_f
dur_f_2 = dur_f
if (canvas==canvas3):
global T_f_3
global IPI_f_3
......@@ -622,12 +653,7 @@ def select_par_TBS_bi(canvas, T, IPI, n_ep, IEI, ITI, dur):
global IEI_f_3
global ITI_f_3
global dur_f_3
T_f_3 = T_f
IPI_f_3 = IPI_f
n_ep_f_3 = n_ep_f
IEI_f_3 = IEI_f
ITI_f_3 = ITI_f
dur_f_3 = dur_f
writeToLog("Parâmetros definidos.")
except:
writeToLog("Algum erro ocorreu. Tente preencher todos os parâmetros.")
......@@ -662,12 +688,7 @@ def select_par_PBS(canvas, PP, PPI, T, IPI, IBI, dur):
global IPI_f_1
global IBI_f_1
global dur_f_1
PP_f_1 = PP_f
PPI_f_1 = PPI_f
T_f_1 = T_f
IPI_f_1 = IPI_f
IBI_f_1 = IBI_f
dur_f_1 = dur_f
if (canvas==canvas2):
global PP_f_2
global PPI_f_2
......@@ -675,12 +696,7 @@ def select_par_PBS(canvas, PP, PPI, T, IPI, IBI, dur):
global IPI_f_2
global IBI_f_2
global dur_f_2
PP_f_2 = PP_f
PPI_f_2 = PPI_f
T_f_2 = T_f
IPI_f_2 = IPI_f
IBI_f_2 = IBI_f
dur_f_2 = dur_f
if (canvas==canvas3):
global PP_f_3
global PPI_f_3
......@@ -688,17 +704,41 @@ def select_par_PBS(canvas, PP, PPI, T, IPI, IBI, dur):
global IPI_f_3
global IBI_f_3
global dur_f_3
PP_f_3 = PP_f
PPI_f_3 = PPI_f
T_f_3 = T_f
IPI_f_3 = IPI_f
IBI_f_3 = IBI_f
dur_f_3 = dur_f
writeToLog("Parâmetros definidos.")
except:
writeToLog("Algum erro ocorreu. Tente preencher todos os parâmetros.")
def recvFromArduino():
startMarker = 60
endMarker = 62
ck = ""
x = "z" # any value that is not an end- or startMarker
byteCount = -1 # to allow for the fact that the last increment will be one too many
while ord(x) != startMarker:
x = arduino.read()
while ord(x) != endMarker:
if ord(x) != startMarker:
ck = ck + x.decode("utf-8") # change for Python3
byteCount += 1
x = arduino.read()
return(ck)
def waitForArduino():