posy = 50

# Define Circle characteristics
circle_radius = 20
circle = Circle(posx, posy, circle_radius, fill=0x00FF00, outline=0xFF00FF)
main_group.append(circle)

# Define Circle Animation Steps
delta_x = 2
delta_y = 2

# Showing the items on the screen
display.show(main_group)

while True:

    if circle.y + circle_radius >= display.height - circle_radius:
        delta_y = -1
    if circle.x + circle_radius >= display.width - circle_radius:
        delta_x = -1
    if circle.x - circle_radius <= 0 - circle_radius:
        delta_x = 1
    if circle.y - circle_radius <= 0 - circle_radius:
        delta_y = 1

    circle.x = circle.x + delta_x
    circle.y = circle.y + delta_y

    time.sleep(0.02)
    gc.collect()
                current_mode = LTRS
                send_character(current_mode.index("LTRS"))
        # Send char mode at beginning of message and every 72 characters
        if char_count >= 72 or char_count == 0:
            print("Resending mode")
            if current_mode == LTRS:
                send_character(current_mode.index("LTRS"))
            elif current_mode == FIGS:
                send_character(current_mode.index("FIGS"))
            # reset counter
            char_count = 0
        print(char)
        send_character(current_mode.index(char))
        time.sleep(char_pause)
        # increment counter
        char_count += 1


message_pick = 0

while True:
    if clue.button_a:
        message_pick = (message_pick + 1) % 4  # loop through the lines
        dot.y = dot_y[message_pick]
        time.sleep(0.4)  # debounce

    if clue.button_b:
        dot.fill = VFD_GREEN
        send_message(messages[message_pick])
        dot.fill = VFD_BG
left_group = displayio.Group(max_size=4)
mask.left_display.show(left_group)

right_group = displayio.Group(max_size=4)
mask.right_display.show(right_group)

right_circle = Circle(SCREEN_SIZE // 2, SCREEN_SIZE // 2, 40, fill=0x0000FF)
right_group.append(right_circle)

left_circle = Circle(SCREEN_SIZE // 2, SCREEN_SIZE // 2, 40, fill=0x00AA66)
left_group.append(left_circle)

while True:
    # print(mask.boop)
    if mask.boop:
        left_circle.x = 0
        right_circle.x = SCREEN_SIZE - 40 - 40 - 2

        right_circle.y = SCREEN_SIZE // 4 - 40
        left_circle.y = SCREEN_SIZE // 4 - 40 + LEFT_Y_OFFSET
        print(mask.acceleration)
        print(mask.light)
        time.sleep(0.5)
    else:
        left_circle.x = SCREEN_SIZE // 2 - 40
        right_circle.x = SCREEN_SIZE // 2 - 40

        right_circle.y = SCREEN_SIZE // 2 - 40
        left_circle.y = SCREEN_SIZE // 2 - 40 + LEFT_Y_OFFSET
Esempio n. 4
0
nau7802.channel = 2  # Set to first channel
chan_2_zero = zero_channel()  # Re-calibrate and get raw zero offset value

clue.pixel[0] = (0, 16, 0)  # Set status indicator to green
clue.play_tone(1660, 0.15)
clue.play_tone(1440, 0.15)

### Main loop: Read sample, move bubble, and display values
while True:
    nau7802.channel = 1
    value = read(SAMPLE_AVG)
    chan_1_mass_gr = round((value - chan_1_zero) * CALIB_RATIO_1, 1)
    chan_1_mass_oz = round(chan_1_mass_gr * 0.03527, 2)
    chan_1_value.text = "%5.1f" % (chan_1_mass_gr)

    chan_1_bubble.y = int(map_range(chan_1_mass_gr, MIN_GR, MAX_GR, 240,
                                    0)) - 8
    if chan_1_mass_gr > MAX_GR or chan_1_mass_gr < MIN_GR:
        chan_1_bubble.fill = clue.RED
    else:
        chan_1_bubble.fill = None

    nau7802.channel = 2
    value = read(SAMPLE_AVG)
    chan_2_mass_gr = round((value - chan_2_zero) * CALIB_RATIO_2, 1)
    chan_2_mass_oz = round(chan_2_mass_gr * 0.03527, 2)
    chan_2_value.text = "%5.1f" % (chan_2_mass_gr)

    chan_2_bubble.y = int(map_range(chan_2_mass_gr, MIN_GR, MAX_GR, 240,
                                    0)) - 8
    if chan_2_mass_gr > MAX_GR or chan_2_mass_gr < MIN_GR:
        chan_2_bubble.fill = clue.RED