Пример #1
0
# Display106a.py
# Ticker, constructor with parameters

from py7seg import Py7Seg

ps = Py7Seg()
ip = "x192-168-1-13"
ps.showTicker(ip, count=2, speed=4, blocking=True)
ps.showText("donE")
Пример #2
0
    for i in range(5):  # Send bit pattern starting from bit b4
        if control & 0x10:  # Check bit b4
            GPIO.output(SPI_MOSI, HIGH)
        else:
            GPIO.output(SPI_MOSI, LOW)
        control <<= 1 # Shift left
        GPIO.output(SPI_CLK, HIGH) # Clock pulse
        GPIO.output(SPI_CLK, LOW)

    # Get reply
    data = 0
    for i in range(11):  # Read 11 bits and insert at right
        GPIO.output(SPI_CLK, HIGH)  # Clock pulse
        GPIO.output(SPI_CLK, LOW)
        data <<= 1  # Shift left, LSB = 0
        if GPIO.input(SPI_MISO): # If high, LSB = 1,
            data |= 0x1

    GPIO.output(SPI_CS, HIGH) # Disable chip
    return data

setup()
channel = 0
ps = Py7Seg() # xxx
t = 0
while True:
    data = readADC(channel)
    print t, "s:", data
    ps.showText("%4d" %data) # xxx
    t += 0.1
    time.sleep(0.1)
# Display102.py
# Show displayable chars
# Enter text from terminal

from py7seg import Py7Seg

print "Displayable chars:", Py7Seg.getDisplayableChars()
ps = Py7Seg()
ps.showText("run")
while True:
    print "Enter text (x to terminate)",
    text = raw_input()  # Fetch the input from the terminal
    if text == "x":
        break
    ps.showText(text)
ps.showText("donE")