コード例 #1
0
    time.sleep(0.01)
    fastloop_counter += 1
    if fastloop_counter > 9:
        fastloop_counter = 0
    else:
        continue

    led.value = not debounced_button.value

    if mode_initiated:
        mode_duration_counter = mode_duration_counter + 1

    icon_counter += 1
    if icon_counter > 7:
        icon_counter = 0
    left_circle.fill = left_colors[icon_counter]
    right_circle.fill = right_colors[icon_counter]

    if mode == 0:  # both solid red
        if not mode_initiated:
            mode_initiated = True
            display_line1("RED RED")
            display_line2("SOLID")
            display_line3(str(mode))
            left_colors = [
                D_RED, D_RED, D_RED, D_RED, D_RED, D_RED, D_RED, D_RED
            ]
            right_colors = [
                D_RED, D_RED, D_RED, D_RED, D_RED, D_RED, D_RED, D_RED
            ]
            neopixels[0] = RED
コード例 #2
0
ファイル: code.py プロジェクト: fourstops/enviroplus
                          "width"], ["data", 0, "images", "web", "height"]),
    image_resize=(WIDTH, HEIGHT - 15),
    image_position=(0, 0),
    text_font="/fonts/OpenSans-9.bdf",
    json_path=["data", 0, "title"],
    text_position=(4, HEIGHT - 9),
    text_color=0xFFFFFF)

circle = Circle(WIDTH - 8, HEIGHT - 7, 5, fill=0)
pyportal.splash.append(circle)
loopcount = 0
errorcount = 0
while True:
    response = None
    try:
        circle.fill = 0xFF0000
        itemid = random.randint(1, IMAGECOUNT)
        # itemid = 20 # portrait mode example
        # itemid = 21 # landscape mode example
        print("retrieving url:", APIURL + str(itemid))
        response = pyportal.fetch(APIURL + str(itemid))
        circle.fill = 0
        print("Response is", response)
        loopcount = loopcount + 1

    except (RuntimeError, KeyError, TypeError) as e:
        print("An error occured, retrying! -", e)
        print("loop counter:", loopcount)
        assert errorcount < 20, "Too many errors, stopping"
        errorcount = errorcount + 1
        time.sleep(60)
コード例 #3
0
ファイル: code.py プロジェクト: dnkorte/neopixel_color_finder
        # every 0.25 seconds we read knobs and update displays
        fastloop_counter = 0
        R_knob_last = R_knob
        G_knob_last = G_knob
        B_knob_last = B_knob

        R_knob = get_knob(analog_R_pin)
        G_knob = get_knob(analog_G_pin)
        B_knob = get_knob(analog_B_pin)

        if btn1_status == "short":
            print("button 1 short")
            print("entering show stored 1")
            btn1_status = "waiting"
            mode = "showing_stored_value"
            big_circle.fill = convert_tuple_to_hex(mem1_rgb)
            neopixels[0] = mem1_rgb
            neopixels[1] = mem1_rgb
            neopixels[4] = mem1_rgb
            neopixels.show()
            display_val_r(str(mem1_rgb[0]))
            display_val_g(str(mem1_rgb[1]))
            display_val_b(str(mem1_rgb[2]))
            display_val_h(hex(convert_tuple_to_hex(mem1_rgb)))

        if btn2_status == "short":
            print("button 2 short")
            print("entering show stored 2")
            btn2_status = "waiting"
            mode = "showing_stored_value"
            big_circle.fill = convert_tuple_to_hex(mem2_rgb)
コード例 #4
0
                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
コード例 #5
0
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
    else:
        chan_2_bubble.fill = None
コード例 #6
0
# reset_pin = DigitalInOut(board.G0)
# reset_pin.direction = Direction.OUTPUT
# reset_pin.value = False

# arial12 = bitmap_font.load_font("/fonts/Arial-12.bdf")
arial16 = bitmap_font.load_font("/fonts/Arial-16.bdf")
# arial24 = bitmap_font.load_font("/fonts/Arial-Bold-24.bdf")

display = board.DISPLAY

group = displayio.Group(max_size=25)
outer_circle = Circle(120, 120, 119, outline=0xFFFFFF, stroke=30)
group.append(outer_circle)

inner_circle = Circle(120, 120, 60, fill=0xFFFFFF, outline=0xFFFFFF)
group.append(inner_circle)

display.show(group)
time.sleep(0.01)

while True:
    time.sleep(1)

    for colorcode in my_aqi.all_color_codes():
        for colorcode2 in my_aqi.all_color_codes():
            outer_circle.outline = colorcode
            inner_circle.outline = colorcode2
            inner_circle.fill = colorcode2
            time.sleep(5)
        time.sleep(5)