Ejemplo n.º 1
0
 def set_manual_mode(self):
     lcd = self._lcd
     lcd.lcd_clear()
     lcd.lcd_puts('{:^15}'.format("Activar Bomba Manualmente?"), 1)
     lcd.lcd_puts('   SI  Cancelar', 2)
     start_wait = time.time()
     while ((time.time() - start_wait ) < 10) or \
             (self._but2.lastState == OneButton.CLICK and (self._but2.lastChangeTime > start_wait)): # Wait 10 secs or cancel
         self._but1.tick()
         self._but2.tick()
         if self._but1.lastState == OneButton.CLICK and (
                 self._but1.lastChangeTime > start_wait):
             self._manual_mode = True
             lcd.lcd_clear()
             lcd.lcd_puts('{:^15}'.format("Iniciando Bomba"), 1)
             lcd.lcd_puts('{:^15}'.format("Manualmente"), 2)
             time.sleep(2)
             stop_stations()
             gv.sd['mm'] = 0
             gv.sd['en'] = 0
             vals = [0] * len(gv.srvals)
             vals[gv.sd['mas'] - 1] = 1  # Start Pump
             gv.srvals = vals
             set_output()
             manual_master_start = time.time()
             # now we wait to cancel with other double press
             last_update = time.time()
             while True:
                 time.sleep(TICK_DELAY)
                 self._but1.tick()
                 self._but2.tick()
                 if (time.time() - last_update) > 5:
                     # Keep Forcing the current State!
                     gv.sd['mm'] = 0
                     gv.sd['en'] = 0
                     vals = [0] * len(gv.srvals)
                     vals[gv.sd['mas'] - 1] = 1
                     gv.scontrol.stations = vals
                     run_min = int((time.time() - manual_master_start) / 60)
                     run_sec = int((time.time() - manual_master_start) % 60)
                     lcd.lcd_clear()
                     lcd.lcd_puts('{:^15}'.format("Cancelar Bomba Manual?"),
                                  1)
                     lcd.lcd_puts(
                         ' Cancel - {:^3}:{}'.format(run_min, run_sec), 2)
                     last_update = time.time()
                 if self._but1.lastState == OneButton.CLICK and self._but1.lastChangeTime > manual_master_start:  # Cancel Manual Mode
                     lcd.lcd_clear()
                     lcd.lcd_puts('{:^15}'.format("Detentiendo Bomba"), 1)
                     lcd.lcd_puts('{:^15}'.format("Modo Automatico"), 2)
                     time.sleep(3)
                     stop_stations()
                     gv.srvals = [0] * len(gv.srvals)
                     set_output()
                     gv.sd['mm'] = 0
                     gv.sd['en'] = 1
                     break
Ejemplo n.º 2
0
def chatter(cct):
    stop_stations()
    t = 0
    for cnt in range(150):      
        t = 1 - t #  toggle cct
        gv.srvals[cct] = t      
        set_output()
        sleep(0.2)
        if stop:
            break
    #  switch everything off
    stop_stations()