예제 #1
0
def dispQrCode(data, imageFile='qr-code.lcd'):
    # setup the QR Code generator
    qr = qrcode.QRCode(
        version=3,
        error_correction=qrcode.constants.ERROR_CORRECT_L,
        box_size=10,
        border=1,
    )

    print '> Encoding %d characters' % (len(data))
    qr.add_data(data)
    qr.make(fit=True)

    matrix = qr.get_matrix()
    matrixRows = len(matrix)
    matrixCols = len(matrix[0])
    print '> Generated QR Code: %dx%d pixels' % (matrixCols, matrixRows)

    # check the size
    if matrixCols > oledImage.SCREEN_WIDTH or matrixRows > oledImage.SCREEN_HEIGHT:
        print 'ERROR: Generated QR code is too large for the OLED Display! Try less text!'
        exit()

    # double the QR code size if it's less than half of the OLED size
    dMatrix = oledImage.doubleMatrixSize(matrix)
    xOffset = oledImage.SCREEN_WIDTH / 2 - len(dMatrix[0]) / 2

    ## convert the QR code to an OLED image
    screen = oledImage.convertToOledImg(dMatrix, xOffset, 0)
    oledImage.printToFile(screen, imageFile)

    ## display the image on the OLED Expansion
    oledExp.driverInit()  # initialize the screen
    oledExp.setDisplayMode(1)  # invert the colours
    oledExp.drawFromFile(imageFile)  # display the image file
예제 #2
0
def start_write():
    if oledExp.driverInit() != 0:
        print 'ERROR: Could not initialize the OLED Expansion'
        return False

# this clears the screen
    oledExp.clear()

    # this sets the colour
    oledExp.setDisplayMode(0)

    #this sets it to receive text
    oledExp.setTextColumns()

    #this places the cursor on the second row, first column
    oledExp.setCursor(1, 0)

    oledExp.write('Welcome.')

    oledExp.setCursor(3, 0)

    oledExp.write('Loading ticker..')

    oledExp.setCursor(5, 0)

    oledExp.write('Prices in EUR.')
예제 #3
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)
예제 #4
0
# initialize
ret 	= oledExp.driverInit()
print "driverInit return: ", ret
if (ret != 0):
	exit()

# write a character
ret 	= oledExp.writeChar('x')
print "writeChar return: ", ret
if (ret != 0):
	exit()
time.sleep(2)

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

# dim
ret 	= oledExp.setDim(1)
print "setDim return: ", ret
if (ret != 0):
	exit()
time.sleep(2)

# clear the display
ret 	= oledExp.clear()
print "clear return: ", ret
예제 #5
0
from OmegaExpansion import oledExp
from time import localtime, strftime

date = strftime("%d %b %Y %H:%M", localtime())

# this clears the screen
oledExp.clear()

# this sets the colour
oledExp.setDisplayMode(0)

#this sets it to receive text
oledExp.setTextColumns()

#this places the cursor on the second row, first column
oledExp.setCursor(1, 0)

#this writes the time and date
oledExp.write(date)

# first json response printed
#oledExp.setCursor(3,0)
#oledExp.write(c_1_sym+': '+str(c_1_price)+' '+c_1_per+'%')
예제 #6
0
# initialize
ret = oledExp.driverInit()
print "driverInit return: ", ret
if (ret != 0):
    exit()

# write a character
ret = oledExp.writeChar('x')
print "writeChar return: ", ret
if (ret != 0):
    exit()
time.sleep(2)

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

# dim
ret = oledExp.setDim(1)
print "setDim return: ", ret
if (ret != 0):
    exit()
time.sleep(2)

# clear the display
ret = oledExp.clear()
print "clear return: ", ret
예제 #7
0
import OmegaExpansion.oledExp as oled

oled.driverInit()
oled.setDisplayPower(1)
oled.setDisplayMode(0)
oled.clear()

oled.setCursor(0, 0)
oled.write("Hello")
oled.setCursor(2, 0)
oled.write("World!")
예제 #8
0
def write():
    ### this gets the date and time
    date = time.strftime("%d %b %Y %H:%M")
    #time_now = time.strftime("%X")

    ### these are the API calls for the four currencies
    response_1 = urllib2.urlopen(
        'https://api.coinmarketcap.com/v1/ticker/bitcoin/?convert=EUR')
    r_1 = json.load(response_1)

    response_2 = urllib2.urlopen(
        'https://api.coinmarketcap.com/v1/ticker/monero/?convert=EUR')
    r_2 = json.load(response_2)

    response_3 = urllib2.urlopen(
        'https://api.coinmarketcap.com/v1/ticker/iconomi/?convert=EUR')
    r_3 = json.load(response_3)

    response_4 = urllib2.urlopen(
        'https://api.coinmarketcap.com/v1/ticker/siacoin/?convert=EUR')
    r_4 = json.load(response_4)

    ### this sets a place value for the Decimal round up
    cents = Decimal('0.001')
    #cents2 = Decimal('0.0001')

    ### these set the JSON resturns to variables
    c_1 = r_1[0]
    c_2 = r_2[0]
    c_3 = r_3[0]
    c_4 = r_4[0]

    ### this grabs info from the dictionaries, and makes them variables
    c_1_sym = c_1['symbol']
    #c_1_price = round(float(c_1['price_eur']), 2)
    c_1_price = c_1['price_eur']
    c_1_price = Decimal(c_1_price).quantize(cents, ROUND_HALF_UP)
    c_1_per = c_1['percent_change_24h']

    c_2_sym = c_2['symbol']
    #c_2_price = round(float(c_2['price_eur']), 2)
    c_2_price = c_2['price_eur']
    c_2_price = Decimal(c_2_price).quantize(cents, ROUND_HALF_UP)
    c_2_per = c_2['percent_change_24h']

    c_3_sym = c_3['symbol']
    #c_3_price = round(float(c_3['price_eur']), 2)
    c_3_price = c_3['price_eur']
    c_3_price = Decimal(c_3_price).quantize(cents, ROUND_HALF_UP)
    c_3_per = c_3['percent_change_24h']

    c_4_sym = c_4['symbol']
    #c_3_price = round(float(c_3['price_eur']), 2)
    c_4_price = c_4['price_eur']
    c_4_price = Decimal(c_4_price).quantize(cents, ROUND_HALF_UP)
    c_4_per = c_4['percent_change_24h']

    ### this is the write to screen process
    if oledExp.driverInit() != 0:
        print 'ERROR: Could not initialize the OLED Expansion'
        return False

    ### this clears the screen
    oledExp.clear()

    ### this sets the colour
    oledExp.setDisplayMode(0)

    ### this sets it to receive text
    oledExp.setTextColumns()

    ### this places the cursor on the second row, first column
    oledExp.setCursor(1, 0)

    ### oledExp.write('  '+date+' '+time_now)
    oledExp.write(date)

    oledExp.setCursor(3, 0)
    oledExp.write(c_1_sym + ': ' + str(c_1_price) + ' ' + c_1_per + '%')

    oledExp.setCursor(4, 0)
    oledExp.write(c_2_sym + ': ' + str(c_2_price) + '  ' + c_2_per + '%')

    oledExp.setCursor(5, 0)
    oledExp.write(c_3_sym + ': ' + str(c_3_price) + '   ' + c_3_per + '%')

    oledExp.setCursor(6, 0)
    oledExp.write(c_4_sym + ':  ' + str(c_4_price) + '  ' + c_4_per + '%')

    ### this sets the scroll type, speed, etc
    oledExp.scroll(0, 0, 0, 8 - 1)
예제 #9
0
import OmegaExpansion.oledExp as oled

oled.driverInit()
oled.setDisplayPower(1)
oled.setDisplayMode(0)
oled.clear()

oled.setCursor(0, 0)
oled.write("Hello")
oled.setCursor(2,0)
oled.write("World!")