Esempio n. 1
0
            di += 1
    oled.show()

oled = oled_init()
bL = button_init()
bR = button_init(35)

print("start dice")
sleep(1)
oled.clear()

for d in range(6):
    show_dice(d+1)
    sleep(0.3)

def runAuto():
    ir = urandom.randint(1, 6)
    # print(ir)
    show_dice(ir)
    sleep(1)

while True:
    if button(bL)[0] > 8:
      ir = urandom.randint(1, 6)
      print(ir)
      show_dice(ir)
      sleep(0.1)

    if button(bR)[0] > 8:
        while True:
            runAuto()
Esempio n. 2
0
sec = 0
run = False

printTitle("stopwatch.py")
print("this is simple Micropython example | ESP32 & octopusLAB")
print()

while True:
    # print(select)
    if run:
        sec += 1
        d7.show(sec / 10)
        print(sec / 10)
        sleep(0.1)

    if button(BB)[0] >= debounce:
        # beep()
        select += 1
        sleep(0.3)

        if select == 1:
            run = True

        if select == 2:
            run = False

        if select == 3:
            sec = 0
            d7.show("0.0")

        if select > 3:
# octopusLAB test - 2019
from time import sleep
from utils.octopus import button_init, button, w, web_server, ap_init
from components.led import Led
led = Led(2)
button0 = button_init(0)
debounce = 9
ap = False

print("esp32 web server - start >")
for id in range(10):
    print(10 - id)
    led.blink()
    if button(button0)[0] >= debounce:
        print("button > AP_start")
        ap = True
        for id in range(5):
            led.blink(100, 100)
        break

sleep(1)
if ap: wc = ap = ap_init()
else: wc = w()

sleep(1)
web_server()