コード例 #1
0
def test_wrong_number_of_pins():
    try:
        bitbang_6800(gpio=gpio, RS=7, E=8, PINS=[25, 24, 23])
    except AssertionError as ex:
        assert str(
            ex
        ) == 'You\'ve provided 3 pins but a bus must contain either four or eight pins'
コード例 #2
0
def test_unsupported_gpio_platform():
    try:
        bitbang_6800()
    except luma.core.error.UnsupportedPlatform as ex:
        assert str(ex) == 'GPIO access not available'
    except ImportError:
        pytest.skip(rpi_gpio_missing)
コード例 #3
0
def test_data():
    eight_to_four = lambda data: [
        f(x) for x in data for f in (lambda x: x >> 4, lambda x: 0x0F & x)
    ]

    data = (0x41, 0x42, 0x43)  # ABC
    serial = bitbang_6800(gpio=gpio, RS=7, E=8, PINS=[25, 24, 23, 18])

    serial.command(*eight_to_four([0x80]))
    serial.data(eight_to_four(data))

    setup = [call(gpio.RS, gpio.OUT), call(gpio.E, gpio.OUT)] + \
        [call(gpio.PINS[i], gpio.OUT) for i in range(4)]
    prewrite = lambda mode: [call(gpio.RS, mode), call(gpio.E, gpio.LOW)]
    pulse = [call(gpio.E, gpio.HIGH), call(gpio.E, gpio.LOW)]
    send = lambda v: [
        call(gpio.PINS[i], (v >> i) & 0x01) for i in range(serial._datalines)
    ]

    calls = \
        prewrite(gpio.CMD) + send(0x08) + pulse + send(0x00) + pulse + \
        prewrite(gpio.DATA) + \
        send(data[0] >> 4) + pulse + \
        send(data[0]) + pulse + \
        send(data[1] >> 4) + pulse + \
        send(data[1]) + pulse + \
        send(data[2] >> 4) + pulse + \
        send(data[2]) + pulse

    gpio.setup.assert_has_calls(setup)
    gpio.output.assert_has_calls(calls)
コード例 #4
0
def test_cleanup():
    serial = bitbang_6800(gpio=gpio)
    serial._managed = True
    serial.cleanup()
    assert_only_cleans_whats_setup(gpio)
コード例 #5
0
def test_cleanup():
    serial = bitbang_6800(gpio=gpio)
    serial._managed = True
    serial.cleanup()
    gpio.cleanup.assert_called_once_with()
コード例 #6
0
 def bitbang_6800(self):
     from luma.core.interface.parallel import bitbang_6800
     GPIO = self.__init_alternative_GPIO()
     return bitbang_6800(gpio=self.gpio or GPIO)
コード例 #7
0
ファイル: bitcoinPrice.py プロジェクト: voldig/oledScreen
from luma.core.interface.parallel import bitbang_6800
from luma.core.render import canvas
from luma.oled.device import ws0010
import time
import requests

serial = bitbang_6800(RS=7, E=8, PINS=[25,24,23,27])

device = ws0010(serial,rotate=2, selected_font='FT01') # this font supports '£' sign

owned = 0.001337

while (True):
    response = requests.get('https://api.coindesk.com/v1/bpi/currentprice.json')
    data = response.json()
    device.text = '!!! UPDATE !!!'
    currentPrice = data["bpi"]["GBP"]["rate_float"]
    toGbp = round(currentPrice * owned,2) 
    time.sleep(1)
    # other methods from the luma library doesn't seem to work with this particular screen
    device.text = '£' + str(data["bpi"]["GBP"]["rate"]) + '\n£' + str(toGbp)
    time.sleep(30)