def test6_RGBLED_set(self, mock_wiringpi_softPwmCreate, mock_wiringpi_softPwmWrite, \ mock_wiringpi_ISR, mock_wiringpi_pinMode, mock_wiringpi_setup): gpio_pin_r = 10 gpio_pin_g = 8 gpio_pin_b = 6 led = RGBLED(gpio_pin_r, gpio_pin_g, gpio_pin_b) calls = [call(gpio_pin_r, 1), call(gpio_pin_g, 1), call(gpio_pin_b, 1)] mock_wiringpi_pinMode.assert_has_calls(calls) calls = [ call(gpio_pin_r, 0, 100), call(gpio_pin_g, 0, 100), call(gpio_pin_b, 0, 100) ] mock_wiringpi_softPwmCreate.assert_has_calls(calls) r_level = 1 g_level = 2 b_level = 3 led.set(r_level, g_level, b_level) calls = [ call(gpio_pin_r, r_level), call(gpio_pin_g, g_level), call(gpio_pin_b, b_level) ] mock_wiringpi_softPwmWrite.assert_has_calls(calls) self.assertEqual(led.get(), (1, 2, 3))
ROT_ENC_2A = 4 ROT_ENC_2B = 5 # 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:
#!/usr/bin/python # Copyright (c) 2016 Michiel Fokke # Author: Michiel Fokke <*****@*****.**> # vim: set ts=4 sw=4 expandtab si: from time import sleep from volumio_buddy import RGBLED PIN_R = 23 PIN_G = 26 PIN_B = 22 led = RGBLED(PIN_R, PIN_G, PIN_B) for red in range(101): led.set(red, 0, 0) sleep(.1) for red in range(100,-1,-1): led.set(red, 0, 0) sleep(.1) for green in range(101): led.set(0, green, 0) sleep(.1) for green in range(100,-1,-1): led.set(0, green, 0) sleep(.1) for blue in range(101): led.set(0, 0, blue) sleep(.1) for blue in range(100, -1, -1): led.set(0, 0, blue)