Esempio n. 1
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)
Esempio n. 2
0
# The MIT License (MIT)
# Copyright (c) 2020 Jan Cespivo, Jan Copak
# octopusLAB pubsub example

from examples.pubsub.ps_init import pubsub

from time import sleep
from util.octopus import oled_init
from util.display_segment import fourDigits

o = oled_init()

print("ps_oled:")
print("this is simple Micropython example | ESP32 & octopusLAB")
print()

o.clear()
o.contrast(10)
o.hline(0, 53, 128, 1)
o.text("octopusLAB 2020", 3, 1)
o.show()
sleep(2)


def display_show(text):
    o.clear()
    o.text("octopusLAB 2020", 3, 1)
    o.hline(0, 53, 128, 1)
    o.text(str(text), 3, 55)
    o.show()
Esempio n. 3
0
led.blink()

if isDisp7:
    try:
        from util.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 util.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')

#sleep for 10 seconds (20000 milliseconds)
machine.deepsleep(20000)
Esempio n. 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 util.octopus import oled_init
from util.shell 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