Beispiel #1
0
def listener():
    global angular_speed, linear_speed
    key = getkey()
    count = 0
    while not rospy.is_shutdown():
        while not key:
            True
        if key==keys.UP:
            key_publisher.publish(1)
            move(linear_speed,0)
        elif key==keys.DOWN:
            key_publisher.publish(2)
            move(-linear_speed,0)
        elif key==keys.RIGHT:
            key_publisher.publish(3)
            move(0,-angular_speed)
        elif key==keys.LEFT:
            key_publisher.publish(4)
            move(0,angular_speed)
        elif key=='q':
            linear_speed = linear_speed*1.1
        elif key=='a':
            linear_speed = linear_speed*0.9
        elif key=='w':
            angular_speed = angular_speed*1.1
        elif key=='s':
            angular_speed = angular_speed*0.9
        key = getkey()
        count +=1
        print(count)
Beispiel #2
0
 def takeStudentDetails(self,rollNumber):
 
     firstName = input("Enter student First Name : or q to exit Registration " )
     if firstName == 'q':
         print("Registration Completed")
         exit()
         
     lastName =  input("Enter student Last Name : ")
     fullName = firstName + " " + lastName
     
     print("Entered Name is :")
     print(fullName)
     
     print("if Name is INcorrect and you want to re-enter the name press q/Q  ELSE press c/C to continue")
     key = getkey()
     if key == 'q' or key =='Q':
         return -1
     if key == 'c' or key =='C':
         print("We need to capture your image")
         print("press y/Y once you are ready")
         key = getkey()
         if key == 'y' or key == 'Y':
             frame = camera.takeStudentPhoto()
             #frame = self.takeStudentPhoto()
             self.createAugmentationAndSave(frame,rollNumber)
             #self.saveImages(frame,rollNumber)
     studentDict={}
     studentDict={'name':fullName,'facial_features':b'89'}
     return studentDict 
Beispiel #3
0
def showGameOver():
    call('clear')
    print("******** M E N U *********")
    print("\n\n\n\n")
    print("    G A M E    O V E R    ")
    print("\n")
    print("           orz            ")
    print("\n\n\n\n")
    print("**************************")
    getkey()
    call('clear')
Beispiel #4
0
def extract_words(*args):
    if not args:
        print("please supply site and additional info")
        return

    if args[0] == 'scp':
        if len(args) > 1:
            scp_num = args[1] or random.randint(1, 5000)
        else:
            scp_num = random.randint(1, 5000)

        scp_num = '{:0>3}'.format(scp_num)

        if len(args) > 2:
            words_num = int(args[2]) or 100
        else:
            words_num = 100


        unique_words = scpwp.get_all_unique_words(scp_num)

        all_known_words = set()
        all_known_words.update(data_handler.basic_words,
                               data_handler.known_words,
                               data_handler.awaiting_review_words,
                               data_handler.other_words,
                               {word.word for word in data_handler.reviewed_words})

        unique_words -= all_known_words
        unique_words = list(unique_words)[:words_num]

        print(f"Extracting words from scp-{scp_num}")
        print("Press 'A' to add word to reviews, "
              "'B' to add word to basic words, "
              "'K' to add word to known words, "
              "and 'O' to add word to other words.")

        for word in unique_words:
            print(word)
            key = getkey.getkey()
            while key not in 'abko':
                print("please, enter 'a', 'b', 'k', or 'o'")
                key = getkey.getkey()
            if key == 'a':
                data_handler.add_awaiting_review_word(word)
            elif key == 'b':
                data_handler.add_basic_word(word)
            elif key == 'k':
                data_handler.add_known_word(word)
            elif key == 'o':
                data_handler.add_other_word(word)

        data_handler.write()
Beispiel #5
0
    def displayFightResult(self):
        if self.own.state == "死亡":
            print("your HP is 0")
            print("press any key")
            getkey()
            return True

        elif self.enemy.state == "死亡":
            print("enemy's HP is 0")
            print("press any key")
            getkey()
            self.enemy.state = "死亡"
            return False
Beispiel #6
0
def main():
    if not os.path.isfile(output):
        with open(output, 'w') as f:
            f.write('wos_id,isSoftware\n')

    dfOut = pandas.read_csv(output)
    dfIn = pandas.read_csv(target, sep='\t')

    processedkeys = set(dfOut['wos_id'])

    newData = {
        'wos_id': [],
        'isSoftware': [],
    }

    count = 0
    total = len([w for w in dfIn['wos_id'] if w not in processedkeys])
    for i, row in dfIn.iterrows():
        if row['wos_id'] in processedkeys:
            continue
        count += 1

        print("\n" * 80)
        print("Paper number {} of {}, from {}".format(count, total,
                                                      row['source']))
        print()
        print(row['title'])
        print()
        print(row['abstract'])

        key = getkey.getkey()

        while key not in ['y', 'n', 'e']:
            print("Invalid key Pressed")
            key = getkey.getkey()

        if key == 'y':
            val = 1
        elif key == 'n':
            val = 0
        elif key == 'e':
            print("Exiting")
            break
        else:
            print("Somthing bad happend")
            import pdb
            pdb.set_trace()
        writeLine(row['wos_id'], val)
    print("Done")
Beispiel #7
0
def main():
    # load back json file # #
    with open('colors_ranges.json', 'r') as fp:
        data = json.load(fp)
    color_ranges = json.loads(data,cls=NumpyDecoder)
    
    # go to the device manager and see what com port your usb to serial adaptor is using.
    # eg ser = serial.Serial('COM1', 9600)
    ser = serial.Serial('COM3',4800,8,'n',1,timeout=100)

    cam = cv2.VideoCapture(0)
    lower_circle, upper_circle = color_ranges['lower_circle'], color_ranges['upper_circle']
    while True:
        _, img = cam.read()
        cv2.waitKey(33)
        key = getkey(blocking=False).decode('utf-8')
        if key =='q' or key =='Q':
            break
        if arrived(img, lower_circle, lower_circle)
            R = rotate(ser, 90)          # what to do if rotation fail
            
            box_seq = ['r','b','g','y']
            loaded = {'r':False,'b':False,'g':False,'y':False}
            for box in box_seq:
                if loaded[box]===False:
                    while True:
                        look(img, )
                        pass        #do CV searching...
Beispiel #8
0
def test_history():
    print "History tester"

    buffer_size = 100
    print "Creating history with buffer of size {}".format(buffer_size)
    history = PromptHistory(buffer_size=buffer_size)
    input_str = ""

    history.push("Esto")
    history.push("es")
    history.push("una")
    history.push("prueba")
    history.push("del")
    history.push("historial")
    history.print_history()
    while True:
        print "Press up or down keys: "
        # Get keyboard input
        key = getkey()
        if key == keys.UP:
            print "UP"
            content = history.peek_older()
            print "Content: {}".format(
                content if content is not None else "START")
        if key == keys.DOWN:
            print "DOWN"
            content = history.peek_newer()
            print "Content: {}".format(
                content if content is not None else "END")
        if key == 'q':
            break
    print "quit"
Beispiel #9
0
    def jog(self):

        rospy.loginfo("Entering jog loop")
        rospy.loginfo("    Use up/down arrows to increase/decrease jog speed")
        rospy.loginfo("    Use left/right arrows to jog joint")
        rospy.loginfo("    Use +/- to increase/decrease joint number")
        rospy.loginfo("Jogging joint %d", self._current_joint + 1)

        while not rospy.is_shutdown():
            key = getkey()
            if key == keys.UP:
                if self._edo_jog_speed < self.JOG_SPEED_MAX:
                    self._edo_jog_speed += 0.1
                    rospy.loginfo("Jog speed: %.1f", self._edo_jog_speed)
            elif key == keys.DOWN:
                if self._edo_jog_speed > self.JOG_SPEED_MIN:
                    self._edo_jog_speed -= 0.1
                    rospy.loginfo("Jog speed: %.1f", self._edo_jog_speed)
            elif key == keys.RIGHT:
                self.jog_command_pub.publish(self.create_jog_joint_command_message(1))
            elif key == keys.LEFT:
                self.jog_command_pub.publish(self.create_jog_joint_command_message(-1))
            elif key == keys.PLUS:
                self._current_joint = (self._current_joint + 1) % self.NUMBER_OF_JOINTS
                rospy.loginfo("Jogging joint %d", self._current_joint + 1)
            elif key == keys.MINUS:
                self._current_joint = (self._current_joint - 1) % self.NUMBER_OF_JOINTS
                rospy.loginfo("Jogging joint %d", self._current_joint + 1)
            elif key == keys.ESC:
                rospy.loginfo("Exiting joint jog loop")
                break
            else:
                rospy.loginfo("Wrong button was pressed")
Beispiel #10
0
def main():
    state = False
    #
    # Init obj
    print("INIT")
    re = rbq.Uniwersalreceiver()
    thr = threading.Thread(target=re.receive, daemon=True)
    thr.start()
    #thr.join()

    ##

    if state == False:
        state = True
        print("loop Start")
    while True:
        while re.g_return:
            re.g_return = False
        key = getkey()
        if key == keys.ESC:
            break
        elif key == keys.ENTER:
            print("ENTER")
            o_send = rbq.UniwersalSend()
            o_send.send('run')

        pass
def get_artificial_2():
    actions = []
    pen = [4,4]
    canvas = np.zeros((28,28))
    canvas[pen[0],pen[1]] = 1
    plt.imshow(canvas)
    plt.pause(0.1)
    while(True):
        print("Press U,D,L,R")
        key = getkey()
        if key == keys.UP:
            actions.append('up')
            pen[0] -= 1
        elif key == keys.DOWN:
            actions.append('down')
            pen[0] += 1
        elif key == keys.LEFT:
            actions.append('left')
            pen[1] -= 1
        elif key == keys.RIGHT:
            actions.append('right')
            pen[1] += 1
        else:
            break
        canvas[pen[0],pen[1]] = 1
        plt.imshow(canvas)
        plt.pause(0.1)
    return canvas, actions
def main_prompt():
    #global hints
    op = {
        "i": item_hint,
        "d": dead_hint,
        "w": woth_hint,
        "f": fool_hint,
        "u": undo_hint,
        "k": kill_hint,
        "n": woth_edit,
        "e": pexit
    }

    print(
        "\n====================================================================="
    )
    print("\n" + pc("(W)", "y") + "oth | " + pc("(N)", "g") + "ew Check | " +
          pc("(F)", "r") + "ool | " + pc("(I)", "c") + "tem | " +
          pc("(D)", "u") + "ead")
    print("\n" + pc("(U)", "w") + "ndo | " + pc("(K)", "w") + "ill | " +
          pc("(E)", "w") + "xit ",
          end="")
    c = getkey()
    try:
        op[c.lower()]()
    except SystemExit:
        print()
        writef()
        pass
    except:
        main_loop()
Beispiel #13
0
def rehearse(name):
    data, binder = read(name)
    scheduler = Scheduler(binder.sheets)

    with term.fullscreen():
        while scheduler.today:
            sheet = scheduler.today.pop()
            sheet.print_front(lambda text: printwrap(text, centery=True))
            getkey()
            sheet.print_back(lambda text: printwrap(text, centery=False))
            confidence = getnum()
            scheduler.schedule(sheet, confidence)
            print(term.clear())

    write(name, data)
    print("All done for today :D")
def servo_pub():

    steering_angle = 90
    speedy = 0
    msg = cmd()

    pub = rospy.Publisher('servo', cmd, queue_size=5)
    rospy.init_node('servo_pub', anonymous=True)
    rate = rospy.Rate(10)
    while not rospy.is_shutdown():
        key = getkey()
        if key in key_bindings.keys():
            if key == control_keys['s'] and speedy > -1:
                speedy = speedy - 1
            elif key == control_keys['w'] and speedy < 1:
                speedy = speedy + 1
            elif key == control_keys['a'] and steering_angle > 60:
                steering_angle = steering_angle - 30
            elif key == control_keys['d'] and steering_angle < 120:
                steering_angle = steering_angle + 30
            elif key == control_keys['space']:
                speedy = 0
                steering_angle = 90
        elif key == '\x03' or key == '\x71':  # ctr-c or q
            break
        else:
            continue
        msg.speedy = speedy
        msg.steering_angle = steering_angle
        rospy.loginfo(msg)
        pub.publish(msg)
        rate.sleep()
def main():
    # This is a non-blocking call that only loads the environment.
    env = UnityEnvironment(file_name=None, seed=1, side_channels=[])
    # Start interacting with the evironment.
    env.reset()
    print("connected")
    names = env.get_behavior_names()
    spec = env.get_behavior_spec(names[0])
    while True:
        env.step()
        dec, ter = env.get_steps(names[0])
        c = getkey.getkey(blocking=True)
        dir = [0.0, 0.0]
        if c == 'q':
            print('quitting')
            break
        if len(dec) == 0:
            print('empty')
            continue
        if c == 'w':
            dir[0] = 1.0
        elif c == 's':
            dir[0] = -1.0
        elif c == 'a':
            dir[1] = -1.0
        elif c == 'd':
            dir[1] = 1.0
        env.set_action_for_agent(names[0], 0, np.array(dir))
    return 0
Beispiel #16
0
def choosingMenu(enterList, header='Select an option:'):
    """
    :argument: list of options to display, optional heading
    :return: chosen option

    """
    chosen = 0
    key = '\0'
    system('clear')
    while key != '\n':
        print(header)

        for element in enterList:
            if element == enterList[
                    chosen]:  # Outputs chosen object with the format
                print("\033[7m" + element + "\033[27m")
            else:
                print(element)

        key = getkey()
        if key == keys.DOWN and chosen < len(enterList) - 1:
            chosen += 1
        if key == keys.UP and chosen > 0:
            chosen -= 1

        system('clear')

    return enterList[chosen]
Beispiel #17
0
def manual_control():

    # Setup ROS message handling
    rospy.init_node('manual', anonymous=True)

    # Pass command line argument 'r' for red, otherwise blue
    who = "red" if len(
        sys.argv) > 1 and sys.argv[1][0].lower() == 'r' else "blue"

    print("Controlling " + who + " sphero")
    mover = Mover(who)
    mover.ros_setup()

    # Agent control loop
    rate = rospy.Rate(10)  # Hz
    while not rospy.is_shutdown():
        key = getkey()
        if key == 'q': break  #quit
        elif key == keys.UP: mover.speed(+1)
        elif key == keys.DOWN: mover.speed(-1)
        elif key == keys.LEFT: mover.direct(-22)
        elif key == keys.RIGHT: mover.direct(+22)
        elif key == 't': mover.tail()
        elif key == 's': mover.stabilize()
        elif key == 'h': mover.sethead()
        elif key == 'r': mover.reset()
        elif key == 'p': mover.setpos()
        elif key == keys.SPACE: mover.send_twist()
        else:
            print("UP/DN-speed, LEFT/RGHT-direction, t-tail, s-stablize, h-heading, "\
                  "p-position, r-reset, q-quit")

        rate.sleep()
    return
Beispiel #18
0
    def selector(index):
        def print_menu(index, selector, lengend):
            selector %= len(index)
            u = os.system('clear')
            print(" ")
            print(legend)
            for i in range(len(index)):

                if selector == i:
                    print("   > - " + str(index[i]))
                else:
                    print("     - " + str(index[i]))
            print(" ")

        selector = 0
        running = True
        print_menu(index, selector, legend)
        while running:  # making a loop
            key = getkey()
            if key == keys.UP:
                selector -= 1
                print_menu(index, selector, legend)
            elif key == keys.DOWN:
                selector += 1
                print_menu(index, selector, legend)
            elif key == keys.ENTER:
                return selector % len(index)
Beispiel #19
0
 def key():
     global key
     key = ''
     try:
         key = getkey()
     except KeyboardInterrupt:
         pass
Beispiel #20
0
def user_input():
    global is_jumping
    global is_alive
    global jump_frames
    while is_alive:
        if getkey(True) == keys.SPACE and jump_frames <= 0:
            is_jumping = True
Beispiel #21
0
    def run(self, fps: int = 4, debug: bool = False):
        #Create threading for renderLoop and start it
        renderThread = threading.Thread(target=self.renderLoop,
                                        name="windowThread",
                                        kwargs={
                                            "fps": fps,
                                            "debug": debug
                                        })
        renderThread.start()

        #While loop for key presses
        while self.renderThread.is_alive():
            try:
                key = getkey()
            except KeyboardInterrupt:
                self.stopRenderThread()
            else:
                if key == "q":
                    self.stopRenderThread()
                elif key == keys.UP:
                    self.currentlySelected.moveUp(window=self)
                elif key == keys.DOWN:
                    self.currentlySelected.moveDown(window=self)
                elif key == keys.LEFT:
                    self.currentlySelected.moveLeft(window=self)
                elif key == keys.RIGHT:
                    self.currentlySelected.moveRight(window=self)

        print("Exiting Main")
 def manualControl(self):
     while(True):
         key = getkey()
         if key == 'w':
             self.value1 = 15
             self.value2 = 15
         elif key == 's':
             self.value1 = -15
             self.value2 = -15
         elif key == 'd':
             self.value1 = -15
             self.value2 = 15
         elif key == 'a':
             self.value1 = 15
             self.value2 = -15
         elif key == ' ':
             self.value1 = 0
             self.value2 = 0
         elif key == 'j':
             self.value3 = 10
             self.value4 = 10
         elif key == 'k':
             self.value3 = -10
             self.value4 = -10
         elif key == 'l':
             self.value3 = 0
             self.value4 = 0
         if self.shut:
             print('fechou')
             break
Beispiel #23
0
def select(crds):  # -> idxSet, zid
    assert type(crds) is HandCards, "TypeError: not HandCards"
    assert 0 < len(crds) <= 5, "IndexError: overrange"
    keyMap = {'Z': 0, 'X': 1, 'C': 2, 'V': 3, 'B': 4}
    keyStr = "ZXCVB"
    keyStr = keyStr[0:len(crds)]  # fix length to n
    print('use [%s] to select:' % keyStr)
    idxSet = set()
    selC, actLst = [], []
    while True:
        k = getkey(blocking=True)  # block version
        kn = keys.name(k)
        if len(kn) == 1 and kn in keyMap:
            if kn in idxSet:  # already in set
                idxSet ^= {keyMap[kn]}  # xor, flip
            else:
                idxSet |= {keyMap[kn]}  # or, update
            selC = Cards([crds[i] for i in idxSet])
            actLst = match(selC)
            print(selC, actLst)
        elif kn in {'ENTER', 'SPACE'} and len(actLst) > 0:
            if len(actLst) > 1:
                return idxSet, actLst[choose(actLst)]
            else:
                return idxSet, actLst[0]
        elif kn == "ESC":
            idxSet = set()
        else:
            pass
Beispiel #24
0
 def user_action(self):
     while True:
         allowed_keys = ['UP, DOWN, LEFT, RIGH, SPACE, q(quit), ESC']
         print("Press a key ({}): ".format(allowed_keys))
         # Read key.
         key = getkey()
         # Move keys.
         if key == keys.UP:
             self.uy = self.uy - 1 if self.uy > 0 else self.uy
         elif key == keys.DOWN:
             self.uy = self.uy + 1 if self.uy < self.size - 1 else self.uy
         elif key == keys.LEFT:
             self.ux = self.ux - 1 if self.ux > 0 else self.ux
         elif key == keys.RIGHT:
             self.ux = self.ux + 1 if self.ux < self.size - 1 else self.ux
         # Exit keys
         elif key in ['q', 'Q', keys.ESCAPE]:
             return False
         elif key == " ":
             # Check if the move is legal.
             if self.board_state[self.uy][self.ux] != "-":
                 print("Move not legal")
             else:
                 self.add_token(self.uy, self.ux, "X")
                 return True
         else:
             # Handle other text characters
             print("<bad key pressed>")
         self.print()
     return True
def show_test(name, content, sol_file_path, current_test, test_count):
    cpp_file = tempfile.NamedTemporaryFile(delete=False)
    cpp_file.write(content.encode())
    cpp_file.close()

    os.system("clear")
    print(str(current_test) + " / " + str(test_count) + " - " + name + "\n")
    diff_env = os.getenv('DIFF',
                         "/usr/local/bin/colordiff -a -d -w -y -W 200 ")
    os.system(diff_env + " " + cpp_file.name + " " + sol_file_path)
    os.unlink(cpp_file.name)
    print("\n")

    checks, sol_checks = get_checks(content, sol_file_path)

    if len(checks) == len(sol_checks):
        for i in range(0, len(checks)):
            print(colorize(checks[i].strip(), sol_checks[i].strip(), i))
    else:
        print("warning: check count not matching. this should not happen!")

    what = ""
    print("\nContinue? (ENTER) Abort? (ANY OTHER KEY)")
    while what != '\n':
        what = getkey()
        if what != '\n':
            sys.exit(0)
    print()
Beispiel #26
0
def get_user_commands():
    global heading, speed
    reset_msg = False
    key = getkey()
    if key == 'q':
        reset_msg = True
    elif key == keys.UP:
        speed += 1
    elif key == keys.DOWN:
        speed -= 1
    elif key == keys.LEFT:
        heading += np.pi / 16
    elif key == keys.RIGHT:
        heading -= np.pi / 16

    if speed < 0:
        speed = 0
    elif speed >= 250:
        speed = 250

    if heading < 0:
        heading += 360
    heading = heading % 360

    twist_msg = yaw_vel_to_twist(heading, speed)

    # Reset Sphero internal heading
    if reset_msg:
        pub_reset.publish(0)

    return twist_msg, reset_msg
Beispiel #27
0
    def user_action(self):
        allowed_keys = ['UP, DOWN, LEFT, RIGH, SPACE, f(add/remove mine flag), q(quit), ESC']
        print("Press a key ({}): ".format(allowed_keys))
        # Read key.
        key = getkey()
        # Move keys.
        if key == keys.UP:
            self.cur_y = self.cur_y-1 if self.cur_y > 0 else self.cur_y
        elif key == keys.DOWN:
            self.cur_y = self.cur_y+1 if self.cur_y < self.height-1 else self.cur_y
        elif key == keys.LEFT:
            self.cur_x = self.cur_x-1 if self.cur_x > 0 else self.cur_x
        elif key == keys.RIGHT:
            self.cur_x = self.cur_x+1 if self.cur_x < self.width-1 else self.cur_x
        # Bomb keys.
        elif key in ['f', 'F']:
            self.board_user_mines[self.cur_y][self.cur_x] = (not self.board_user_mines[self.cur_y][self.cur_x])
            # Check terminal condition.
            if self.discovered_all():
                # Unreveil all.
                self.print_board_final()
                print("CONGRATULATIONS! (you win)")
                return False
        # Exit keys
        elif key in ['q','Q', keys.ESCAPE]:
            return False
        elif key == " ":
            return self.action_unreveil()
        else:
            # Handle other text characters
            print("<bad key pressed>")

        return True
Beispiel #28
0
def showDeleteSuccess():
    call('clear')
    print("******** M E N U *********")
    print("\n\n\n\n\n")
    print("      delete success      ")
    print("\n\n\n\n\n")
    print("**************************")
    return getkey()
Beispiel #29
0
def showLoadSuccess():
    call('clear')
    print("******** M E N U *********")
    print("\n\n\n\n\n")
    print("       Load success       ")
    print("\n\n\n\n\n")
    print("**************************")
    return getkey()
Beispiel #30
0
def showSaveSuccess():
    call('clear')
    print("******** M E N U *********")
    print("\n\n\n\n\n")
    print("       Save success       ")
    print("\n\n\n\n\n")
    print("**************************")
    return getkey()
    def render(self):
        curtime = time.time()
        if curtime - self.last_rendered >= 1:
            self.last_rendered = curtime
            msg = ""
            if self.curlevel > 2:
                msg = ("%s (%s:%s) | ... | %s | %s (%s:%s) %s" % (
                    self.percentage(0),
                    IProgressStack.compact_time_difference(curtime - self.init_times[0]),
                    IProgressStack.compact_time_difference(self.expected_finish_time(curtime, 0)),
                    self.percentage(-2),
                    self.percentage(),
                    IProgressStack.compact_time_difference(curtime - self.init_times[-1]),
                    IProgressStack.compact_time_difference(self.expected_finish_time(curtime)),
                    self.message
                ))
            elif self.curlevel == 2:
                msg = ("%s (%s:%s) | %s | %s (%s:%s) %s" % (
                    self.percentage(0),
                    IProgressStack.compact_time_difference(curtime - self.init_times[0]),
                    IProgressStack.compact_time_difference(self.expected_finish_time(curtime, 0)),
                    self.percentage(1),
                    self.percentage(),
                    IProgressStack.compact_time_difference(curtime - self.init_times[-1]),
                    IProgressStack.compact_time_difference(self.expected_finish_time(curtime)),
                    self.message
                ))
            elif self.curlevel == 1:
                msg = ("%s (%s:%s) | %s (%s:%s) %s" % (
                    self.percentage(0),
                    IProgressStack.compact_time_difference(curtime - self.init_times[0]),
                    IProgressStack.compact_time_difference(self.expected_finish_time(curtime, 0)),
                    self.percentage(),
                    IProgressStack.compact_time_difference(curtime - self.init_times[-1]),
                    IProgressStack.compact_time_difference(self.expected_finish_time(curtime)),
                    self.message
                ))
            elif self.curlevel == 0:
                msg = ("%s (%s:%s) %s" % (
                    self.percentage(),
                    IProgressStack.compact_time_difference(curtime - self.init_times[-1]),
                    IProgressStack.compact_time_difference(self.expected_finish_time(curtime)),
                    self.message
                ))

            if len(msg) > self.msglen:
                self.msglen = len(msg)
                
            self.stream.write(msg.ljust(self.msglen) + "\r")

            return getkey() != 'q'
            
        else:
            return True
Beispiel #32
0
		print("reply:")
		print(data.decode());

def servo_set(pos):
	servo_cmd("set " + str(servo) + " " + str(pos) +"us")

if (os.path.exists(DEVFILE) == False):
	print("servod is not running!")
	sys.exit()

try:
	print("Press 'h' for help")
	servo_cmd("set "  + str(servo) + " range 0-3000us")
	servo_set(pulse)
	while(True):
		char = getkey.getkey(debug) # User input, but not displayed on the screen
		if (debug):
			print(char)
		if (char == 'h' or char == '?'):
			print("\t's' to select servo\n"
				  "\t'.' to decrement pulse width by 10us\n"
				  "\t',' to increment pulse width by 10 us\n"
				  "\t'>' to decrement pulse width by 100us\n"
				  "\t'<' to increment pulse width by 100us\n"
				  "\t'm' to write min\n"
				  "\t'x' to write max\n"
				  "\t']' to set min position\n"
				  "\t'[' to set max position\n"
				  "\t'i' to set mid position\n"
				  "\t'=' to reset calibration\n"
				  "\t'0' to turn servo off\n"