SHARE
TWEET

Untitled

a guest Jun 25th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #BOTÃO - INICIAR/ZERAR
  2.     self.iniciar_zerar = tk.Button(self)
  3.     self.iniciar_zerar['text'] = u'INICIAR/nZERAR'
  4.     self.iniciar_zerar['font'] = (fonte,tamanho_fonte_botao,'bold')
  5.     self.iniciar_zerar['width'] = 10
  6.     self.iniciar_zerar['relief'] = 'ridge'
  7.     self.iniciar_zerar['bd'] = 5
  8.     self.iniciar_zerar['command'] = lambda: self.medir()
  9.     self.iniciar_zerar.grid(row=1,column=1,rowspan=1,sticky=W+E+N+S,padx=padxx,pady=padyy,ipadx=0,ipady=0)
  10.  
  11.  
  12. def medir(self):
  13.     pn = 40
  14.     GPIO.remove_event_detect(pn)
  15.     GPIO.cleanup(pn)
  16.     global count
  17.     count = 0
  18.     lista1 = []
  19.     lista2 = []
  20.     pn = 40
  21.     GPIO.setmode(GPIO.BOARD)
  22.     GPIO.setup(pn, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
  23.  
  24.  
  25.     def countPulse(channel):
  26.         global count
  27.         nonlocal lista1
  28.         nonlocal lista2
  29.  
  30.         count = count + 1
  31.  
  32.         vazao_L = count*fator_k
  33.  
  34.         preco = vazao_L*self.valor
  35.  
  36.         VOLUME_L = "{0:.2f}".format(vazao_L)
  37.         VALOR_RS = "{0:.2f}".format(preco)
  38.  
  39.         self.litros_var.set(float(VOLUME_L))
  40.         self.reais_var.set(float(VALOR_RS))
  41.  
  42.         lista1.append(VOLUME_L)
  43.         lista2.append(VALOR_RS)
  44.         print(lista1[-1] + 'L' + ' --- ' + lista2[-1] + 'R$')
  45.  
  46.  
  47.         return lista1[-1], lista2[-1]
  48.  
  49.     GPIO.add_event_detect(pn, GPIO.RISING, callback = countPulse)
  50.     print(countPulse(1))
  51.     sleep(2)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top