Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #BOTÃO - INICIAR/ZERAR
- self.iniciar_zerar = tk.Button(self)
- self.iniciar_zerar['text'] = u'INICIAR/nZERAR'
- self.iniciar_zerar['font'] = (fonte,tamanho_fonte_botao,'bold')
- self.iniciar_zerar['width'] = 10
- self.iniciar_zerar['relief'] = 'ridge'
- self.iniciar_zerar['bd'] = 5
- self.iniciar_zerar['command'] = lambda: self.medir()
- self.iniciar_zerar.grid(row=1,column=1,rowspan=1,sticky=W+E+N+S,padx=padxx,pady=padyy,ipadx=0,ipady=0)
- def medir(self):
- pn = 40
- GPIO.remove_event_detect(pn)
- GPIO.cleanup(pn)
- global count
- count = 0
- lista1 = []
- lista2 = []
- pn = 40
- GPIO.setmode(GPIO.BOARD)
- GPIO.setup(pn, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
- def countPulse(channel):
- global count
- nonlocal lista1
- nonlocal lista2
- count = count + 1
- vazao_L = count*fator_k
- preco = vazao_L*self.valor
- VOLUME_L = "{0:.2f}".format(vazao_L)
- VALOR_RS = "{0:.2f}".format(preco)
- self.litros_var.set(float(VOLUME_L))
- self.reais_var.set(float(VALOR_RS))
- lista1.append(VOLUME_L)
- lista2.append(VALOR_RS)
- print(lista1[-1] + 'L' + ' --- ' + lista2[-1] + 'R$')
- return lista1[-1], lista2[-1]
- GPIO.add_event_detect(pn, GPIO.RISING, callback = countPulse)
- print(countPulse(1))
- sleep(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement