Пример #1
0
# stopwatch

from time import sleep
from util.octopus import button_init, button, disp7_init
from util import printTitle

BB = button_init(0) # button boot = 0
# debounce: read 10 samples, only tolerate one false reading
debounce = 9

d7 = disp7_init()

select = 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 
Пример #2
0
def show_dice(num):
    di = 0
    oled.clear()
    # print(dice[num])
    for oR in range(3):
        for oC in range(3):
            # print(di, oR, oC)
            oled.fill_rect(20 * oR + 35, 20 * oC + 10, size, size,
                           dice[num][di])
            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)
Пример #3
0
# octopusLAB test - 2019
from time import sleep
from util.octopus import button_init, button, w, web_server, ap_init
from util.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()