y = [255, 255, 255] e = [0, 0, 0] O = [0, 0, 255] A = 0 B = 0 path = [ y, y, y, e, e, e, e, e, e, e, y, e, e, e, e, e, e, e, y, e, e, e, e, e, e, e, y, y, y, y, y, e, e, e, e, e, e, e, y, e, e, e, e, e, e, e, y, e, e, e, e, e, y, y, y, e, e, e, e, e, y, e, e, e ] while 1: sense.set_pixels(path) sense.set_pixel(A, B, O) pitch = sense.get_orientation()['pitch'] roll = sense.get_orientation()['roll'] print('Pitch:', pitch) print('Roll:', roll) if 270 < pitch < 315 and A < 7: A += 1 if 45 < pitch < 90 and A > 0: A -= 1 if 45 < roll < 90 and B < 7: B += 1 if 270 < roll < 315 and B > 0: B -= 1 current = sense.get_pixel(A, B) if current == e: A = 0 B = 0 sleep(0.5)
if event.action == 'held' and event.direction == 'middle': xy_flag = x * 10 + y if xy_flag not in list_flag: list_flag.append(xy_flag) sense.set_pixel(x, y, green) else: list_flag.remove(xy_flag) if event.action == 'pressed': sense.set_pixel(x, y, old_color) if event.direction == 'down' and y < 7: y = y + 1 old_color = sense.get_pixel(x, y) elif event.direction == 'up' and y > 0: y = y - 1 old_color = sense.get_pixel(x, y) elif event.direction == 'right' and x < 7: x = x + 1 old_color = sense.get_pixel(x, y) elif event.direction == 'left' and x > 0: x = x - 1 old_color = sense.get_pixel(x, y)
#on comment for now to try to stop seconds from blinking # if (s.get_pixel((sec_stripeX[sec_LED_current]), sec_stripeY[sec_LED_current])) == nothing: s.set_pixel((sec_stripeX[sec_LED_current]), sec_stripeY[sec_LED_current], sec_pixel_color) # else: # s.set_pixel((sec_stripeX[sec_LED_current]), sec_stripeY[sec_LED_current], nothing) #--now toggle on the hour-LED------------------ hour_LED_current = get_hour_pixel() if loglevel_deep: print(ticker(), "toggling the hour-LED now:") if loglevel_deep: print(ticker(), "the current hour: ", hour_LED_current, "vs. true hour: ", hour_true) x = (hour_LED_current[0])[0] y = (hour_LED_current[0])[1] if s.get_pixel(x, y) == [0, 0, 0]: was_off = True else: was_off = False if was_off: s.set_pixel(x, y, pink) # s.set_pixel(x, y, hour_stripe_color[hour_true]) if loglevel_deep: print(ticker(), "turned ON hour LED x,y now: ", x, y) if hour_LED_current[1] != (1, 1): x = (hour_LED_current[1])[0] y = (hour_LED_current[1])[1] s.set_pixel(x, y, pink) # s.set_pixel(x, y, hour_stripe_color[hour_true]) if loglevel_deep: