from codex import * from time import sleep CENTER = 120 display.fill(BLACK) # vertical line display.draw_line(CENTER, 0, CENTER, 105, WHITE) display.draw_line(CENTER, 135, CENTER, 239, WHITE) # horizontal line display.draw_line(0, CENTER, 105, CENTER, YELLOW) display.draw_line(135, CENTER, 239, CENTER, YELLOW) x = CENTER y = CENTER color = RED while True: val = accel.read() tilt_x = val[0] scaledx = (tilt_x/16384) * 90 degreesx = int(scaledx) if degreesx < -120: degreesx = -120 if degreesx > 120: degreesx = 120 tilt_y = val[1] scaledy = (tilt_y/16384) * 90 degreesy = int(scaledy) if degreesy < -120: degreesy = -120 if degreesy > 120: degreesy = 120 x = CENTER + degreesx y = CENTER + degreesy display.dr_circle(x, y, 15, BLACK) if x > 100 and y > 100: color = WHITE if x > 100 and y <= 100: color = PINK if x < 100 and y < 100: color = CYAN if x < 100 and y <= 100: color = GREEN if degreesx < 0.010 and degreesx > -0.010: if degreesy < 0.10 and degreesy > -0.10: display.fill_rect(110, 110, 25, 25, GREEN) display.draw_text("*", scale=3, x=115, y=115, color=BLACK) else: display.fill_rect(110, 110, 25, 25, BLACK) display.draw_circle(x, y, 15, color) sleep(0.2)