示例#1
0
gpio.setwarnings(False)
gpio.setmode(gpio.BCM)

# Setup switch pins
gpio.setup(SW1, gpio.IN, pull_up_down=gpio.PUD_DOWN)
gpio.setup(SW2, gpio.IN, pull_up_down=gpio.PUD_DOWN)
gpio.setup(TIR, gpio.IN, pull_up_down=gpio.PUD_DOWN)
gpio.setup(TOUCHLED, gpio.OUT)
gpio.setup(MOTIONLED, gpio.OUT)

# initiate LCD
lcd = initLCD()
#mesg("Prog. Started")

# Initialize pump
pump = pumpcontrol.Pump(gpio)

# enable the switches to move the pump
subprocess.call(
    "sudo python /home/pi/openbehavior/operantLicking/python/pumpmove.py" +
    " &",
    shell=True)

# Run the deviceinfo script
mesg("Hurry up, Wifi!")
os.system("/home/pi/openbehavior/wifi-network/deviceinfo.sh")

# Initialize touch sensor
tsensor = touchsensor.TouchSensor()

# turn lights on to indicate ready to run
        while (True):
            self.useropt = 'derp'
            self.dispMenu()
            self.useropt = str(input())
            self.switch1 = (self.pump).readSwitch()
            if self.useropt == '1':
                self.readSteps()
            elif self.useropt == '2':
                self.readSpeed()
            elif self.useropt == '3':
                self.readPitch()
            elif self.useropt == '4':
                self.readMlPerMm()
            elif self.useropt == '5':
                self.startMovement()
            elif self.useropt == '6':
                raise SystemExit
            else:
                print("Invalid choice. Please enter again.")
            clearScreen()

    # END Program Main Loop


# END CLASS PumpInterface

if __name__ == "__main__":
    p = pumpcontrol.Pump()
    pi = PumpInterface(p)
    pi.mainLoop()