# simple basic example - ESP32 + 7segment display

from time import sleep
from utils.octopus import oled_init, time_init, w, get_hhmm
from utils.display_segment import fourDigits

w()  # wifi connect
o = oled_init()


def oled_clock():
    timeString = get_hhmm()
    hh = int(timeString[:2])
    mm = int(timeString[3:5])
    fourDigits(o, hh, mm)
    sleep(0.5)
    fourDigits(o, hh, mm, 0)
    sleep(0.5)


time_init()  # server > time setup

print("oled_clock.py")
print("this is simple Micropython example | ESP32 & octopusLAB")
print()
o.clear()
o.contrast(10)
o.hline(0, 53, 128, 1)
o.text("octopusLAB 2019", 3, 1)
o.text("oled example .:.", 3, 55)
o.show()
Exemple #2
0
# get bitcoin

from time import sleep
import urequests, json
from utils.octopus import w
from shell.terminal import printTitle

w()


def bitcoin_usd():

    res = urequests.get("https://api.coinpaprika.com/v1/tickers/btc-bitcoin")
    btcusd = res.json()['quotes']["USD"]["price"]
    return float(btcusd)


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

while True:
    btc = bitcoin_usd()
    print(btc)
    sleep(10)
# 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()