time.sleep(1) #@webiopi.macro def led_on(): number = 8 writeNumber(number) time.sleep(1) #@webiopi.macro def led_off(): number = 9 writeNumber(number) time.sleep(1) # Start the webiopi server server = webiopi.Server(port=8000, login="******", password="******") # Start the webcam video stream os.system("streamer.sh") # Register the macros server.addMacro(stop) server.addMacro(forward) server.addMacro(left) server.addMacro(right) server.addMacro(backward) server.addMacro(stop) server.addMacro(servo_centre) server.addMacro(servo_left) server.addMacro(servo_right) server.addMacro(led_on)
GPIO.outputSequence(DATA_RLY,gpio8period, "0101010101010101010101010101") GPIO.outputSequence(DATA_RLY,gpio8period, "0101010101010101010101010101") GPIO.outputSequence(DATA_RLY,gpio8period, "0101010101010101010101010101") """ if __name__ == "__main__": """ execution starts here """ # webiopi.setDebug() # be verbose on stderr teletype.init(webiopi.GPIO) server = webiopi.Server(port=80, coap_port=None) #server.host="192.168.42.1" # add the macros which the browser will call server.addMacro(baud_rate_inc) server.addMacro(baud_rate_dec) server.addMacro(tty_start) server.addMacro(tty_stop) server.addMacro(tty_tx) server.addMacro(tty_tx_str) server.addMacro(tty_tx_ctl) server.addMacro(tty_test) webiopi.runLoop(loop) # never exits
# Initialization part # # -------------------------------------------------- # # Setup GPIOs GPIO.setFunction(L1, GPIO.OUT) GPIO.setFunction(R1, GPIO.OUT) stop() # -------------------------------------------------- # # Main server part # # -------------------------------------------------- # # Instantiate the server on the port 8000, it starts immediately in its own thread server = webiopi.Server(port=8000, login="******", password="******") # Register the macros so you can call it with Javascript and/or REST API server.addMacro(go_forward) #server.addMacro(go_backward) server.addMacro(turn_left) server.addMacro(turn_right) server.addMacro(stop) # -------------------------------------------------- # # Loop execution part # # -------------------------------------------------- # # Run our loop until CTRL-C is pressed or SIGTERM received webiopi.runLoop()
writeNumber(0) writeNumber(2) writeNumber(4) writeNumber(6) @webiopi.macro def relayOn_n(): writeNumber(1) writeNumber(3) writeNumber(5) writeNumber(7) # Start the webiopi server server = webiopi.Server(port=8000) # Add server macro server.addMacro(relayOff_1) server.addMacro(relayOn_1) server.addMacro(relayOff_2) server.addMacro(relayOn_2) server.addMacro(relayOff_3) server.addMacro(relayOn_3) server.addMacro(relayOff_4) server.addMacro(relayOn_4) server.addMacro(relayOff_n) server.addMacro(relayOn_n) # Run default loop webiopi.runLoop()
myMotor3.setSpeed(80) myMotor4.setSpeed(80) def speed2(): myMotor1.setSpeed(55) myMotor2.setSpeed(55) myMotor3.setSpeed(55) myMotor4.setSpeed(55) def speed1(): myMotor1.setSpeed(30) myMotor2.setSpeed(30) myMotor3.setSpeed(30) myMotor4.setSpeed(30) server = webiopi.Server(port=8000, login="******", password="******") server.addMacro(forward) server.addMacro(backward) server.addMacro(right) server.addMacro(left) server.addMacro(stop) server.addMacro(speed1) server.addMacro(speed2) server.addMacro(speed3) server.addMacro(speed4) server.addMacro(speed5) server.addMacro(speed6) server.addMacro(speed7) server.addMacro(speed8) server.addMacro(speed9)
# -------------------------------------------------- # # Setup GPIOs - toate porturile sunt de iesire GPIO.setFunction(B1, GPIO.OUT) GPIO.setFunction(B2, GPIO.OUT) GPIO.setFunction(B3, GPIO.OUT) GPIO.setFunction(B4, GPIO.OUT) GPIO.setFunction(B5, GPIO.OUT) # -------------------------------------------------- # # Main server part # # -------------------------------------------------- # # Instantiate the server on the port 8000, it starts immediately in its own thread server = webiopi.Server(port=8000, login="******", password="******") # -------------------------------------------------- # # Loop execution part # # -------------------------------------------------- # # Run our loop until CTRL-C is pressed or SIGTERM received webiopi.runLoop() # -------------------------------------------------- # # Termination part # # -------------------------------------------------- # # Stop the server server.stop()
def rights(): servo_rights() def center(): servo_center() def s_stop(): servo_stop() # -------------------------------------------------- # # WEBSERVER AND USER AUTH SETUP # # -------------------------------------------------- # server = webiopi.Server(port=9000, login="******", password="******") # -------------------------------------------------- # # JAVASCRIPT TO HTML MACROS # # -------------------------------------------------- # server.addMacro(go_forward) server.addMacro(go_backward) server.addMacro(turn_left) server.addMacro(turn_right) server.addMacro(stop) server.addMacro(left_s) server.addMacro(right_s) server.addMacro(normal_s)
GPIO.output(7, GPIO.LOW) GPIO.output(8, GPIO.LOW) GPIO.output(9, GPIO.LOW) GPIO.output(11, GPIO.LOW) GPIO.output(18, GPIO.LOW) GPIO.output(22, GPIO.LOW) GPIO.output(23, GPIO.LOW) GPIO.output(24, GPIO.LOW) GPIO.output(25, GPIO.LOW) # -------------------------------------------------- # # Main server part # # -------------------------------------------------- # # Instantiate the server on the port 8000, it starts immediately in its own thread server = webiopi.Server(port=8000) #, login="******", password="******") # or webiopi.Server(port=8000, passwdfile="/etc/webiopi/passwd") # -------------------------------------------------- # # Loop execution part # # -------------------------------------------------- # # Run our loop until CTRL-C is pressed or SIGTERM received webiopi.runLoop() # -------------------------------------------------- # # Termination part # # -------------------------------------------------- # # Cleanly stop the server server.stop()
# -------------------- # # Setup GPIOs GPIO.setFunction(CLOSE, GPIO.OUT) GPIO.setFunction(OPEN, GPIO.OUT) GPIO.setFunction(L1, GPIO.OUT) c_stop() light1_off() # -------------------- # # Main server # # -------------------- # # Instantiate the server on the port 8000, it starts immediately in its own thread server = webiopi.Server(port=3333, login="******", password="******") # Register the macros so you can call it with Javascript and/or REST API server.addMacro(curtain_open) server.addMacro(curtain_close) server.addMacro(curtain_stop) server.addMacro(l1_on) server.addMacro(l1_off) # -------------------- # # Loop # # -------------------- # # Run our loop until CTRL-C is pressed or SIGTERM received webiopi.runLoop()
GPIO.setup(GD1, GPIO.OUT, initial=GPIO.HIGH) GPIO.setup(GD2, GPIO.OUT, initial=GPIO.HIGH) # -------------------------------------------------- # # Start Webcam Sever # # -------------------------------------------------- # webcam = subprocess.Popen('./stream.sh') time.sleep(1) # -------------------------------------------------- # # Main server part # # -------------------------------------------------- # # Instantiate the server on the port 8000, it starts immediately in its own thread server = webiopi.Server(port=8000, coap_port=None, login="", password="") # Register the macros so you can call it with Javascript and/or REST API server.addMacro(toggle_garagedoor1) server.addMacro(toggle_garagedoor2) # -------------------------------------------------- # # Loop execution part # # -------------------------------------------------- # # Run our loop until CTRL-C is pressed or SIGTERM received webiopi.runLoop() # -------------------------------------------------- # # Termination part #
r.TurnInPlace(pyrobot.VELOCITY_SLOW, 'ccw') time.sleep(0.5) r.DriveStraight(pyrobot.VELOCITY_SLOW) time.sleep(0.25) r.DriveStraight(-pyrobot.VELOCITY_SLOW) time.sleep(.25) r.Stop() stop() # -------------------------------------------------- # # Main server part # # -------------------------------------------------- # # Instantiate the server on the port 8000, it starts immediately in its own thread server = webiopi.Server(port=8000, login="******", password="******") # Register the macros so you can call it with Javascript and/or REST API server.addMacro(go_forward) server.addMacro(go_backward) server.addMacro(turn_left) server.addMacro(turn_right) server.addMacro(stop) server.addMacro(led_on) server.addMacro(led_off) server.addMacro(MacroWithArgs) # -------------------------------------------------- # # Loop execution part # # -------------------------------------------------- #
for j in arr: time.sleep(0.01) for i in range(0,4): if i == j: GPIO.output(ports[i],GPIO.LOW) else: GPIO.output(ports[i],GPIO.HIGH) # -------------------------------------------------- # # Initialization part # # -------------------------------------------------- # # Setup GPIOs # -------------------------------------------------- # # Main server part # # -------------------------------------------------- # # Instantiate the server on the port 8000, it starts immediately in its own thread server = webiopi.Server(port=8001, login="******", password="******") # or webiopi.Server(port=8000, passwdfile="/etc/webiopi/passwd") # Register the macros so you can call it with Javascript and/or REST API server.addMacro(turnWebcam) server.addMacro(turnLed) # -------------------------------------------------- # # Loop execution part # # -------------------------------------------------- # # Run our loop until CTRL-C is pressed or SIGTERM received webiopi.runLoop() # If no specific loop is needed and defined above, just use # webiopi.runLoop() # here instead # -------------------------------------------------- # # Termination part # # -------------------------------------------------- #