Esempio n. 1
0
def main():
    global stdscr
    dir(curses)
    stdscr = curses.initscr()         # initialize ncurses display
    stdscr.nodelay(1)                 # dont wait for key presses
    curses.noecho()                   # dont echo key presses
    GZ.spi_set_width(2)               # Pass blocks of 2 bytes on SPI
    stdscr.erase() 
    stdscr.addstr("Toggling all outputs.\n")
    stdscr.addstr("Press 'n' for next test, any other key to stop.\n")
    key = 0
    while(True):
      exercise_outputs(0xff, 0x00);
      key = stdscr.getch()
      if (key != -1):
        break;
    if (str(unichr(key)) == "n"):
      stdscr.erase()
      stdscr.addstr("Toggling alternate outputs.\n")
      stdscr.addstr("Press 'n' for next test, any other key to stop.\n")
      while(True):
        exercise_outputs(0xaa, 0x55)
        key = stdscr.getch()
        if (key != -1):
          break;
    if (str(unichr(key)) == "n"):
      stdscr.erase()
      stdscr.addstr("Walking outputs.\n")
      stdscr.addstr("Press 'n' for next test, any other key to stop.\n")
      current = 0xfffe
      while(True):
        exercise_outputs(current, (current << 1) | 0x0001)
        current = (current << 2) | 0x03
        if ((current & 0xff) == 0xff):
          current = 0xfe
        key = stdscr.getch();
        if (key != -1):
          break;
    if (str(unichr(key)) == "n"):
      stdscr.erase()
      curses.curs_set(0)              # Hide the cursor
      stdscr.addstr("Toggling outputs (Bitwise).\n")
      stdscr.addstr("Press 'n' for next test, any other key to stop.\n")
      GZ.spi_write(a & 0x5555)        # Pass set up bytes to SPI
      while(True):
		for x in range(0, 15):
		  if (GZ.output_get(x)):
			  GZ.spi_reset(x);
		  else
		      GZ.spi_set(x);
        key = stdscr.getch()
        if (key != -1):
          break;
Esempio n. 2
0
def main():
    global stdscr
    dir(curses)
    stdscr = curses.initscr()         # initialize ncurses display
    stdscr.nodelay(1)                 # dont wait for key presses
    curses.noecho()                   # dont echo key presses
    GZ.spi_set_width(2)               # Pass blocks of 2 bytes on SPI
    stdscr.erase() 
    stdscr.addstr("Toggling all outputs.\n")
    stdscr.addstr("Press 'n' for next test, any other key to stop.\n")
    key = 0
    while(True):
      exercise_outputs(0xffff, 0x0000);
      key = stdscr.getch()
      if (key != -1):
        break;
    if (str(unichr(key)) == "n"):
      stdscr.erase()
      stdscr.addstr("Toggling alternate outputs.\n")
      stdscr.addstr("Press 'n' for next test, any other key to stop.\n")
      while(True):
        exercise_outputs(0xaaaa, 0x5555)
        key = stdscr.getch()
        if (key != -1):
          break;
    if (str(unichr(key)) == "n"):
      stdscr.erase()
      stdscr.addstr("Walking outputs.\n")
      stdscr.addstr("Press 'n' for next test, any other key to stop.\n")
      current = 0xfffe
      while(True):
        exercise_outputs(current, (current << 1) | 0x0001)
        current = (current << 2) | 0x03
        if ((current & 0xffff) == 0xffff):
          current = 0xfffe
        key = stdscr.getch();
        if (key != -1):
          break;
    if (str(unichr(key)) == "n"):
      stdscr.erase()
      curses.curs_set(0)              # Hide the cursor
      stdscr.addstr("Toggling outputs (Bitwise).\n")
      stdscr.addstr("Press 'n' for next test, any other key to stop.\n")
      GZ.spi_write(0x5555)            # Pass set up bytes to SPI
      while(True):
        for x in range(0, 15):
          if (GZ.output_get(x)):
            GZ.spi_reset(x)
          else:
            GZ.spi_set(x)
        key = stdscr.getch()
        time.sleep(0.1)
        if (key != -1):
          break;
    if (str(unichr(key)) == "n"):
      stdscr.erase()
      curses.curs_set(0)              # Hide the cursor
      stdscr.addstr("Reading inputs.\n")
      stdscr.addstr("Press 'n' for next test, any other key to stop.\n")
      while(True):
        display_inputs()
        key = stdscr.getch()
        if (key != -1):
          break;
    if (str(unichr(key)) == "n"):
      stdscr.erase()
      curses.curs_set(0)              # Hide the cursor
      stdscr.addstr("Reading bitwise inputs.\n")
      stdscr.addstr("Press any key to stop.\n")
      while(True):
        display_bitwise_inputs()
        key = stdscr.getch()
        if (key != -1):
          break;
      stdscr.move(stdscr.getyx()[0] + 1 ,0)
      curses.curs_set(1)
      stdscr.refresh()
    GZ.spi_close()                    # close SPI channel
    curses.reset_shell_mode()         # turn off ncurses
    return 0
Esempio n. 3
0
def main():
    global stdscr
    dir(curses)
    stdscr = curses.initscr()  # initialize ncurses display
    stdscr.nodelay(1)  # dont wait for key presses
    curses.noecho()  # dont echo key presses
    GZ.spi_set_width(2)  # Pass blocks of 2 bytes on SPI
    stdscr.erase()
    stdscr.addstr("Toggling all outputs.\n")
    stdscr.addstr("Press 'n' for next test, any other key to stop.\n")
    key = 0
    while (True):
        exercise_outputs(0xffff, 0x0000)
        key = stdscr.getch()
        if (key != -1):
            break
    if (str(unichr(key)) == "n"):
        stdscr.erase()
        stdscr.addstr("Toggling alternate outputs.\n")
        stdscr.addstr("Press 'n' for next test, any other key to stop.\n")
        while (True):
            exercise_outputs(0xaaaa, 0x5555)
            key = stdscr.getch()
            if (key != -1):
                break
    if (str(unichr(key)) == "n"):
        stdscr.erase()
        stdscr.addstr("Walking outputs.\n")
        stdscr.addstr("Press 'n' for next test, any other key to stop.\n")
        current = 0xfffe
        while (True):
            exercise_outputs(current, (current << 1) | 0x0001)
            current = (current << 2) | 0x03
            if ((current & 0xffff) == 0xffff):
                current = 0xfffe
            key = stdscr.getch()
            if (key != -1):
                break
    if (str(unichr(key)) == "n"):
        stdscr.erase()
        curses.curs_set(0)  # Hide the cursor
        stdscr.addstr("Toggling outputs (Bitwise).\n")
        stdscr.addstr("Press 'n' for next test, any other key to stop.\n")
        GZ.spi_write(0x5555)  # Pass set up bytes to SPI
        while (True):
            for x in range(0, 15):
                if (GZ.output_get(x)):
                    GZ.spi_reset(x)
                else:
                    GZ.spi_set(x)
            key = stdscr.getch()
            time.sleep(0.1)
            if (key != -1):
                break
    if (str(unichr(key)) == "n"):
        stdscr.erase()
        curses.curs_set(0)  # Hide the cursor
        stdscr.addstr("Reading inputs.\n")
        stdscr.addstr("Press 'n' for next test, any other key to stop.\n")
        while (True):
            display_inputs()
            key = stdscr.getch()
            if (key != -1):
                break
    if (str(unichr(key)) == "n"):
        stdscr.erase()
        curses.curs_set(0)  # Hide the cursor
        stdscr.addstr("Reading bitwise inputs.\n")
        stdscr.addstr("Press any key to stop.\n")
        while (True):
            display_bitwise_inputs()
            key = stdscr.getch()
            if (key != -1):
                break
        stdscr.move(stdscr.getyx()[0] + 1, 0)
        curses.curs_set(1)
        stdscr.refresh()
    GZ.spi_close()  # close SPI channel
    curses.reset_shell_mode()  # turn off ncurses
    return 0