""" Display the distance on the LCD """ from parlay.utils import setup, sleep, get_item_by_name, discover setup(ip="172.16.42.104") discover(force=False) LCD = get_item_by_name("LCD") # you can wait for complete on a handle if you want handle = LCD.send_parlay_command("init") handle.wait_for_complete() dist = get_item_by_name("DISTANCE_SENSOR") dist.init() #get a handle but DONT wait on it to finish since this loops forever handle = LCD.send_parlay_command("loop") handle = dist.send_parlay_command("poll_forever") print("STARTING...") for i in range(60): str_distance = "%.3f" % dist.DISTANCE print(str_distance) LCD.TEXT = str_distance sleep(1)
def blink(self, times): for x in range(int(times)): self.turn_green() sleep(1) self.turn_red() sleep(1)
""" Blink the light, but display the color on the LCD """ from parlay.utils import discover, get_item_by_name, sleep, setup setup(ip="172.16.42.104") discover(force=False) led = get_item_by_name("RG_LED") led.init() LCD = get_item_by_name("LCD") handle = LCD.send_parlay_command("init") handle.wait_for_complete() #get a handle but DONT wait on it to finish since this loops forever handle = LCD.send_parlay_command("loop") print "STARTING..." for i in range(30): LCD.TEXT = "GREEN" print LCD.TEXT led.turn_green() sleep(1) LCD.TEXT = "RED" print LCD.TEXT led.turn_red() sleep(1)
def slow_command_1(self): sleep(5) return "Command 1 Completed!"
def slow_command_2(self): sleep(5) return "Command 2 Completed!"
def blink(self, times): for x in xrange(int(times)): self.turn_green() sleep(1) self.turn_red() sleep(1)