# octopusLAB simple example # ESP32board with "BUILT_IN_LED" # parameter: delay [ms] from components.led import Led # from utils.octopus import led # short way from utils.pinout import set_pinout print("---examples/blink_param.py---") # _ARGS # ToDo parse: delay=1000,pin=25 delay = 1000 try: delay = (int(_ARGS[0])) print("delay = ", str(delay)) except Exception as e: print("Exception: {0}".format(e)) pinout = set_pinout() # set board pinout led = Led(pinout.BUILT_IN_LED) # BUILT_IN_LED = 2 # start main loop while True: led.blink(delay)
print("--- octopusLAB: test_led ---") print("-> init") from components.led import Led led = Led(2) print("-> blink()") led.blink() print("-> value() | toggle()") led.value(1) led.toggle() print("-" * 30)
uID5 = getUid(short=5) print("OctopusLAB edu shield 1, 2 x butn, OLED, BLE") # from utils.pinout import set_pinout # pinout = set_pinout() from components.button import Button from components.led import Led led = Led(2) led2 = Led(16) led3 = Led(17) oled = oled_init() led.blink(100) led2.blink(100) led3.blink(100) print("thread_blink") import _thread def tblink(num=20, period_ms=50): for _ in range(num): led.value(1) sleep_ms(period_ms) led.value(0) sleep_ms(period_ms)
# 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()
from time import sleep print("--- examples/test_shield.py ---") print("-" * 30) print("--- Led2 | Led3 ---") from components.led import Led l2 = Led(25) l3 = Led(27) l2.blink() l3.blink() print("--- buzzer ---") from components.buzzer import Buzzer piezzo = Buzzer(15) piezzo.beep() sleep(0.5) piezzo.beep() print("--- OLED ---") from utils.octopus import oled_init oled = oled_init() print("--- Button ---") from components.button import Button btn_L = Button(34, release_value=1) btn_R = Button(35, release_value=1) @btn_L.on_press def on_press_L_button():