Пример #1
0
    def __init__(self, width, height):
        self.width = width
        self.height = height
        self.tick = 0
        self.cells = {}
        self.cached_directions = [
            [-1, 1],  [0, 1],  [1, 1], # above
            [-1, 0],           [1, 0], # sides
            [-1, -1], [0, -1], [1, -1] # below
        ]

        self.populate_cells()
        self.prepopulate_neighbours()
        oledExp.driverInit()
        oledExp.setBrightness(255)
        oledExp.setDisplayMode(0)
Пример #2
0
# write a message
ret 	= oledExp.write("Invent the future")
print "write return: ", ret
if (ret != 0):
	exit()
time.sleep(2)

# invert the colours to normal
ret 	= oledExp.setDisplayMode(0)
print "setDisplayMode return: ", ret
if (ret != 0):
	exit()
time.sleep(2)

# set the highest brightness
ret 	= oledExp.setBrightness(255)
print "setBrightness return: ", ret
if (ret != 0):
	exit()
time.sleep(2)


# clear the display
ret 	= oledExp.clear()
print "clear return: ", ret
if (ret != 0):
	exit()

# set the cursor by pixel
ret 	= oledExp.setCursorByPixel(1,64)
print "setCursorByPixel return: ", ret
Пример #3
0
# write a message
ret = oledExp.write("Invent the future")
print "write return: ", ret
if (ret != 0):
    exit()
time.sleep(2)

# invert the colours to normal
ret = oledExp.setDisplayMode(0)
print "setDisplayMode return: ", ret
if (ret != 0):
    exit()
time.sleep(2)

# set the highest brightness
ret = oledExp.setBrightness(255)
print "setBrightness return: ", ret
if (ret != 0):
    exit()
time.sleep(2)

# clear the display
ret = oledExp.clear()
print "clear return: ", ret
if (ret != 0):
    exit()

# set the cursor by pixel
ret = oledExp.setCursorByPixel(1, 64)
print "setCursorByPixel return: ", ret
if (ret != 0):
Пример #4
0
# encoding: utf-8
from OmegaExpansion import oledExp
import math, time, os

## initialisation
print('Starting the program proofingBox...')

# initialisation the oled expansion
lcd = oledExp.driverInit()
if lcd != 0:
    print('Error initalizing OLED Expansion')
# set verbosity
oledExp.setVerbosity(0)
# set the brightness
lcd = oledExp.setBrightness(127)
if lcd != 0:
    print('Error setting the brightness for the OLED Expansion')

# set up the boot display (show an image for 10 seconds)
imgBoot = "/home/proofingBox/initImg.lcd"
if os.path.exists(imgBoot):
    oledExp.drawFromFile(imgBoot)
time.sleep(1)
oledExp.clear()

## get the target and actual temperature values
## TODO preparation the readout: https://docs.onion.io/omega2-docs/communicating-with-1w-devices.html
tempTrg = "25"
# tempAct = awk -F= '/t=/ {printf "%.03f\n", $2/1000}' /sys/devices/w1_bus_master1/XXXXX/w1_slave
tempAct = "21"
Пример #5
0
import time
import onionGpio
from OmegaExpansion import oledExp
from requests import get
from dns import resolver
from datetime import datetime

oledExp.driverInit(1)
oledExp.setBrightness(0)
oledExp.setTextColumns()

gpio_rled = onionGpio.OnionGpio(17)
gpio_gled = onionGpio.OnionGpio(16)
gpio_bled = onionGpio.OnionGpio(15)
gpio_rled.setOutputDirection(0)
gpio_gled.setOutputDirection(0)
gpio_bled.setOutputDirection(0)
time.sleep(0.25)  #Blink white 1 second to confirm LED function

flag_global_error = False


def color_blink(r, g, b, duration=0.25, sleep=0.25):
    #LED GPIO 1 means LOW and 0 means HIGH
    gpio_rled.setValue(1 - r)
    gpio_gled.setValue(1 - g)
    gpio_bled.setValue(1 - b)
    if duration > 0:
        time.sleep(duration)
        gpio_rled.setValue(1)
        gpio_gled.setValue(1)