def pumpWater(timeInSeconds, plantNumber): if (timeInSeconds <= 0.0): return 0.0 if (plantNumber == 1): startPump() else: extendedPlants.turnOnExtendedPump(plantNumber, GDE_Ext1, GDE_Ext2) i = timeInSeconds while (i > 0.0): time.sleep(1); #Wait 1 second i = i -1.0 if (plantNumber == 1): stopPump() else: extendedPlants.turnOffExtendedPump(plantNumber, GDE_Ext1, GDE_Ext2) return 1
############# # Main Loop ############# while True: time.sleep(10.0) except KeyboardInterrupt: # here you put any code you want to run before the program # exits when you press CTRL+C print "exiting program" #except: # this catches ALL other exceptions including errors. # You won't get any error messages for debugging # so only use it once your code is working # print "Other error or exception occurred!" finally: #time.sleep(5) #GPIO.cleanup() # this ensures a clean exit stopPump() for i in range(2,config.plant_number+1): extendedPlants.turnOffExtendedPump(i, GDE_Ext1, GDE_Ext2) #saveState() print "done"