Пример #1
0
    def test7_Display(self, mock_Adafruit_SSD1306, mock_wiringpi_ISR, mock_wiringpi_pinMode, \
            mock_wiringpi_setup):
        RESET_PIN = 4
        width = 200
        height = 100
        # ensure mocked Adafruit driver has width and height properties
        instance = mock_Adafruit_SSD1306.return_value
        instance.width = width
        instance.height = height

        display = Display(RESET_PIN)
        mock_Adafruit_SSD1306.assert_called_with(rst=RESET_PIN)
        assert display.width == width
        assert display.height == height
        display.image(path.dirname(path.realpath(filename)) + "/volumio.ppm")
Пример #2
0
#!/usr/bin/python
# Copyright (c) 2016 Michiel Fokke
# Author: Michiel Fokke <*****@*****.**>
# vim: set ts=4 sw=4 expandtab si:

import time
from volumio_buddy import Display, ScrollableText
from PIL import Image
from PIL import ImageFont
RESET_PIN = 26

display = Display(RESET_PIN)

# Initialize library.
display.clear()

label1='very long text that does not fit on the screen'
label2='Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed consequat id augue ac sollicitudin. Fusce quis cursus est. Nam volutpat eros faucibus consequat euismod. Integer ac imperdiet justo, non malesuada nisi. Nam bibendum urna sed bibendum auctor. Ut gravida ipsum quis justo luctus, consectetur malesuada sem rhoncus. In ac urna.'
label3='short text'

image = Image.new('1', (display.width, display.height))
font = ImageFont.truetype('pixChicago.ttf', 10)

scrollable1 = ScrollableText(label1, font)
scrollable2 = ScrollableText(label2, font)
scrollable3 = ScrollableText(label3, font)

try:
    while True:
#        for i in range(0, 5*int((scrollable2.textwidth-width)/5)+8, 10):
        for i in range(0, int(1e6), 10):
Пример #3
0
#!/usr/bin/python
# Copyright (c) 2016 Michiel Fokke
# Author: Michiel Fokke <*****@*****.**>
# vim: set ts=4 sw=4 expandtab si:

from sys import argv
from random import randrange
from volumio_buddy import Display, TwoLineTextModal

RESET_PIN = 26

display = Display(RESET_PIN)

if len(argv) > 1:
    display.image(argv[1])
else:
    display.image("volumio.ppm")

import time

try:
    # wait until ^C pressed
    while True:
        textlabel = ('text line 1', 'text line 2')
        display._modal_timeout = time.time() + 3
        display.display(
            TwoLineTextModal(display._image, display._modal_font,
                             textlabel).image())
        time.sleep(10)
        textlabel = ('more text 3', 'more text 4')
        display._modal_timeout = time.time() + 5
Пример #4
0
# LED pins (WiringPi numbering)
LED_RED = 23
LED_GREEN = 26
LED_BLUE = 22

# SSD3106 reset pin (not used)
RESET_PIN = 26

pipe = PipeWriter()

if fork() != 0:
    pipe.close(PipeWriter.OUT)
    led = RGBLED(LED_RED, LED_GREEN, LED_BLUE)
    led.set(0, 0, 10)

    display = Display(RESET_PIN)
    display.image(path.dirname(path.realpath(filename)) + "/volumio.ppm")
    display.start_updates()

    while True:
        # Ensure client restarts after network disconnection
        print "start websocket connection"
        client = VolumioClient()
        client.set_callback(print_state, client, display, led)

        # Wait for events from the websocket connection in separate thread
        client.wait()
        while True:
            print 'waiting for command'
            command = '%s' % pipe.read()
            print 'recieved command: %s' % command
Пример #5
0
# SSD3106 reset pin (not used)
RESET_PIN = 26

pipe = PipeWriter()

if fork() != 0:
    pipe.close(PipeWriter.OUT)
    led = RGBLED(LED_RED, LED_GREEN, LED_BLUE)
    led.set(0, 0, 10)

    battery = Battery()
    battery.set_warn_function(low_battery_warning, led)
    battery.set_empty_function(empty_battery)
    battery.start_monitor()

    display = Display(RESET_PIN)
    display.image(path.dirname(path.realpath(filename)) + "/volumio.ppm")
    display.set_modal_duration(3)
    menu_items = []
    menu_items.append(BatteryMenuItem())
    menu_items.append(IPMenuItem())
    menu_items.append(HotspotMenuItem())
    display.set_menu_items(menu_items)
    display.start_updates()

    while True:
        # Ensure client restarts after network disconnection
        print "start websocket connection"
        client = VolumioClient()
        client.set_callback(print_state, client, display, led)
Пример #6
0
#!/usr/bin/python
# Copyright (c) 2016 Michiel Fokke
# Author: Michiel Fokke <*****@*****.**>
# vim: set ts=4 sw=4 expandtab si:

from sys import argv
from random import randrange
from volumio_buddy import Display

RESET_PIN = 26

display = Display(RESET_PIN)

if len(argv) > 1:
    display.image(argv[1])
else:
    display.image("volumio.ppm")

import time

try:
    # wait until ^C pressed
    while True:
        display.volume_modal(randrange(100), 3)
        time.sleep(10)
finally:
    # clear screen before exiting
    display.clear()
Пример #7
0
#!/usr/bin/python
# Copyright (c) 2016 Michiel Fokke
# Author: Michiel Fokke <*****@*****.**>
# vim: set ts=4 sw=4 expandtab si:

from sys import argv
from volumio_buddy import Display

RESET_PIN = 26

display = Display(RESET_PIN)

if len(argv) > 1:
    display.image(argv[1])
else:
    display.image("volumio.ppm")

try:
# wait until ^C pressed
    while True:
        pass
finally:
# clear screen before exiting
    display.clear()