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")
#!/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
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 if command == 'volume_up':