def test_init_8bitmode(): interface._bitmode = 8 ws0010(interface) to_4 = \ [call(0, 0, 3, 57)] calls = \ to_4 + \ [call(DISPLAYOFF)] + \ [call(POWEROFF)] + \ [call(ENTRY)] + \ [call(POWERON | GRAPHIC)] + \ [call(DISPLAYON)] + \ [call(*[DDRAMADDR, CGRAMADDR])] + \ [call(*[DDRAMADDR, CGRAMADDR + 1])] interface.command.assert_has_calls(calls) # Data to clear the screen calls = \ [call(bytearray([0] * 100))] + \ [call(bytearray([0] * 100))] interface.data.assert_has_calls(calls)
def test_init_4bitmode(): ws0010(interface) to_4 = \ [call(0, 0, 0, 0, 0, 2, 2, 9)] calls = \ to_4 + \ [call(*bytes_to_nibbles([DISPLAYOFF]))] + \ [call(*bytes_to_nibbles([POWEROFF]))] + \ [call(*bytes_to_nibbles([ENTRY]))] + \ [call(*bytes_to_nibbles([POWERON | GRAPHIC]))] + \ [call(*bytes_to_nibbles([DISPLAYON]))] + \ [call(*bytes_to_nibbles([DDRAMADDR, CGRAMADDR]))] + \ [call(*bytes_to_nibbles([DDRAMADDR, CGRAMADDR + 1]))] interface.command.assert_has_calls(calls) # Data to clear the screen calls = \ [call(bytes_to_nibbles([0] * 100))] + \ [call(bytes_to_nibbles([0] * 100))] interface.data.assert_has_calls(calls)
def test_display(): interface._bitmode = 4 d = ws0010(interface) interface.reset_mock() # Use canvas to create an all white screen with canvas(d) as drw: drw.rectangle((0, 0, 99, 15), fill='white', outline='white') line1 = [ call.command(*bytes_to_nibbles([DDRAMADDR, CGRAMADDR])), call.data([0x0F] * 200) ] line2 = [ call.command(*bytes_to_nibbles([DDRAMADDR, CGRAMADDR + 1])), call.data([0x0F] * 200) ] interface.assert_has_calls(line1 + line2)
def test_get_font(): interface._bitmode = 8 device = ws0010(interface) img = Image.new('1', (11, 8), 0) device.font.current = 0 f0 = device.font.current f3 = device.get_font('FT11') drw = ImageDraw.Draw(img) assert f0.getsize('\u00E0') == (5, 8) assert f0.getsize('A\u00E0') == (11, 8) drw.text((0, 0), '\u00E0', font=f0, fill='white') # Font 0: α drw.text((6, 0), '\u00E0', font=f3, fill='white') # Font 3: à # Compare to image containing αà assert img.tobytes() == \ b'\x01\x00\x00\x80I\xc0\xa8 \x91\xe0\x92 i\xe0\x00\x00'
def test_unsupported_display_mode(): import luma.core try: ws0010(interface, width=99, height=15) except luma.core.error.DeviceDisplayModeError as ex: assert str(ex) == "Unsupported display mode: 99 x 15"
from luma.oled.device import ws0010 #import face_tracking import mic_vis import states from emotions import * event = Event() # Change the state to an emotion or animation def set_state(state=states.IDLE): event.set() time.sleep(.1) d.clear() event.clear() t = Thread(target=globals()[state].play, args=[d, event]) t.start() p = parallel(RS=7, E=8, PINS=[25, 24, 23, 27]) d = ws0010(p, selected_font=0) d.text = 'Welcome to Bit\nNow loading...' time.sleep(1) #set_state(states.FACE_TRACKING) set_state(states.MIC_VIS)
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)