Пример #1
0
# 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()
Пример #2
0
led.blink()

if isDisp7:
    try:
        from utils.octopus import disp7_init
        disp7 = disp7_init()
        disp7.show(get_hhmm("-"))
        sleep(3)
        disp7.show("        ")
    except Exception as e:
        print("Exception: {0}".format(e))

if isOled:
    try:
        from utils.octopus import oled_init
        oled = oled_init(runTest=False)
        sleep(1)
        oled.clear()
        oled.text("octopusLAB 2019",10,10)
        oled.text(get_hhmmss(), 10,20)
        oled.show()

        sleep(3)
        oled.poweroff()
    except Exception as e:
        print("Exception: {0}".format(e))


print('Im awake, but Im going to sleep')

Пример #3
0
# 4 5 6
# 7 8 9
size = 8

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)
Пример #4
0
# octopusLAB simple example 2019
# HW: ESP32 + i2c OLED display
# ampy -p /COM6 put examples/oled_random_lines.py main.py
# start: import examples/oled_random_lines

from utils.octopus import oled_init
from shell.terminal import printTitle
from os import urandom

o = oled_init()  # init oled display
o.fill(0)  # clear

# default coordinates for position
x = 0
y = 0

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

while True:
    old_x = x
    old_y = y
    # get new position
    x = int(urandom(1)[0] / 2)
    y = int(urandom(1)[0] / 4)

    o.line(old_x, old_y, x, y, 1)
    o.show()
    # sleep(0.1) # slow or fast