cb.clear() if __name__ == '__main__': cb = CodeBug('/dev/tty.usbmodemfa141') cb.clear() while True: if cb.get_input("A"): outputString = subprocess.check_output(batteryCommand) # print outputString batteryLife = outputString.split("\t")[1].split("%")[0] # print batteryLife displayString(batteryLife+'%') elif cb.get_input("B"): outputString = subprocess.check_output(batteryCommand) batteryLife = int(outputString.split("\t")[1].split("%")[0]) # print batteryLife rows = batteryLife/20 # print rows for i in range(rows): cb.set_row(i,0b11111) # time.sleep(.1) units = batteryLife%20 # print units unitleds = ((units)/4) # print unitleds for i in range(unitleds): cb.set_led(i,rows,1) time.sleep(4) cb.clear()
if __name__ == '__main__': cb = CodeBug('/dev/tty.usbmodemfa141') cb.clear() while True: if cb.get_input("A"): outputString = subprocess.check_output(batteryCommand) # print outputString batteryLife = outputString.split("\t")[1].split("%")[0] # print batteryLife displayString(batteryLife + '%') elif cb.get_input("B"): outputString = subprocess.check_output(batteryCommand) batteryLife = int(outputString.split("\t")[1].split("%")[0]) # print batteryLife rows = batteryLife / 20 # print rows for i in range(rows): cb.set_row(i, 0b11111) # time.sleep(.1) units = batteryLife % 20 # print units unitleds = ((units) / 4) # print unitleds for i in range(unitleds): cb.set_led(i, rows, 1) time.sleep(4) cb.clear()
levelcounter = 0 headX = 2 headY = 2 snakeLength = len(snakeDirections) tailX = headX + snakeLength - 1 tailY = headY gameOver = False # debug_directions = [FOWARD,CLOCKWISE,CLOCKWISE,FOWARD,FOWARD,CLOCKWISE,CLOCKWISE,FOWARD,ANTICLOCKWISE,ANTICLOCKWISE,FOWARD,FOWARD,FOWARD] if __name__ == '__main__': cb = CodeBug('/dev/tty.usbmodemfa141') cb.clear() delay = 0.2 for i, x in enumerate(snakeDirections): cb.set_led(headX + i, headY, 1) cb.set_led(headX + 1, headY, 1) while not gameOver: if counter % 2500000 == 2490000: if cb.get_input("A"): # if debug_directions[0] == ANTICLOCKWISE: if movement == NORTH: movement = WEST else: movement += ANTICLOCKWISE elif cb.get_input("B"): # elif debug_directions[0] == CLOCKWISE: movement = (movement + CLOCKWISE) % 4 # del debug_directions[0]
levelcounter = 0 headX = 2 headY = 2 snakeLength = len(snakeDirections) tailX = headX + snakeLength -1 tailY = headY gameOver = False # debug_directions = [FOWARD,CLOCKWISE,CLOCKWISE,FOWARD,FOWARD,CLOCKWISE,CLOCKWISE,FOWARD,ANTICLOCKWISE,ANTICLOCKWISE,FOWARD,FOWARD,FOWARD] if __name__ == '__main__': cb = CodeBug('/dev/tty.usbmodemfa141') cb.clear() delay = 0.2 for i, x in enumerate(snakeDirections): cb.set_led(headX+i,headY, 1) cb.set_led(headX+1,headY, 1) while not gameOver: if counter % 2500000 == 2490000: if cb.get_input("A"): # if debug_directions[0] == ANTICLOCKWISE: if movement == NORTH: movement = WEST else: movement += ANTICLOCKWISE elif cb.get_input("B"): # elif debug_directions[0] == CLOCKWISE: movement = (movement+CLOCKWISE)%4 # del debug_directions[0]