コード例 #1
0
def _cleanup():
    if is_automation_hat():
        _t_auto_lights.stop()
        sn3218.output([0] * 18)

    _t_update_adc.stop()
    GPIO.cleanup()
コード例 #2
0
def setup():
    """Set up the backlight on GFX HAT"""
    global _sn3218
    import sn3218 as _sn3218

    _sn3218.enable()
    _sn3218.enable_leds(0b111111111111111111)
    _sn3218.output(_buf)
コード例 #3
0
ファイル: __init__.py プロジェクト: shortbloke/automation-hat
def _exit():
    if _t_update_lights:
        _t_update_lights.stop()
        _t_update_lights.join()

    if sn3218 is not None:
        sn3218.output([0] * 18)

    GPIO.cleanup()
コード例 #4
0
def _auto_lights():
    global _led_dirty

    input._auto_lights()
    analog._auto_lights()

    if _led_dirty:
        sn3218.output(_led_states)
        _led_dirty = False

    time.sleep(0.01)
コード例 #5
0
 def test_enable_leds(self):
     """Enable different combinations of LEDs"""
     sn3218.output([60] * 18)
     for _ in range(3):
         sn3218.enable_leds(0b101010101010101010)
         delay()
         sn3218.enable_leds(0b010101010101010101)
         delay()
         sn3218.enable_leds(0b000000000000000000)
         delay()
         sn3218.enable_leds(0b111111111111111111)
         delay()
コード例 #6
0
ファイル: backlight.py プロジェクト: GeorgN/dot3k
def update():
    """
    Update backlight with changes to the LED buffer
    """
    sn3218.output(leds)
コード例 #7
0
def update():
	sn3218.output(leds)
コード例 #8
0
 def test_output_1(self):
     """Output to LEDs"""
     sn3218.output([0x60] * 18)
     delay(0.5)
コード例 #9
0
ファイル: piglow.py プロジェクト: jamesjohn911/piglow
def show():
    '''
    Output the contents of the values list to PiGlow.
    '''
    sn3218.output(_values)
コード例 #10
0
ファイル: piglow.py プロジェクト: pimoroni/piglow
def show():
    """Output the contents of the values list to PiGlow."""

    sn3218.output(_values)
コード例 #11
0
 def test_enable_leds_non_int(self):
     """Enable fails with wrong type"""
     sn3218.output([60] * 18)
     with self.assertRaisesRegex(TypeError, 'must be an integer'):
         sn3218.enable_leds("banana")
コード例 #12
0
 def test_output_wrong_len(self):
     """output fails with wrong length"""
     with self.assertRaisesRegex(TypeError, 'list of 18 integers'):
         sn3218.output([0x60] * 99)
コード例 #13
0
 def test_output_wrong_type(self):
     """output fails with wrong type"""
     with self.assertRaisesRegex(TypeError, 'must be a list'):
         sn3218.output("apple")
コード例 #14
0
def update():
    sn3218.output(leds)
コード例 #15
0
def action_leds(action_level, one, two, three):
    """

    Formats the enable_mask for enabling/disabling LEDs

    Args:
        action_level (int): Level of LEDs  to be actioned
        one (int): Relay one status
        two (int): Relay two status
        three (int): Relay three status

    """

    # Initialise parameters
    global enable_mask

    # Set the enable_mask and return the value
    if action_level == 1 and one == 1 and two == 0 and three == 0:  # Level 1
        enable_mask = 0b111000000001000000
    elif action_level == 1 and one == 0 and two == 1 and three == 0:
        enable_mask = 0b111000000100000000
    elif action_level == 1 and one == 0 and two == 0 and three == 1:
        enable_mask = 0b111000010000000000
    elif action_level == 1 and one == 1 and two == 1 and three == 0:
        enable_mask = 0b111000000101000000
    elif action_level == 1 and one == 1 and two == 0 and three == 1:
        enable_mask = 0b111000010001000000
    elif action_level == 1 and one == 0 and two == 1 and three == 1:
        enable_mask = 0b111000010100000000
    elif action_level == 1 and one == 1 and two == 1 and three == 1:
        enable_mask = 0b111000010101000000
    elif action_level == 2 and one == 1 and two == 0 and three == 0:  # Level 2
        enable_mask = 0b111000000001000000
    elif action_level == 2 and one == 0 and two == 1 and three == 0:
        enable_mask = 0b111000000100000000
    elif action_level == 2 and one == 0 and two == 0 and three == 1:
        enable_mask = 0b111000010000000000
    elif action_level == 2 and one == 1 and two == 1 and three == 0:
        enable_mask = 0b111000000101000000
    elif action_level == 2 and one == 1 and two == 0 and three == 1:
        enable_mask = 0b111000010001000000
    elif action_level == 2 and one == 0 and two == 1 and three == 1:
        enable_mask = 0b111000010100000000
    elif action_level == 2 and one == 1 and two == 1 and three == 1:
        enable_mask = 0b111000010101000000
    elif action_level == 2 and one == 0 and two == 0 and three == 0:
        enable_mask = 0b011000000000000000
    elif action_level == 3 and one == 1 and two == 0 and three == 0:  # Level 3
        enable_mask = 0b100000000001000000
    elif action_level == 3 and one == 0 and two == 1 and three == 0:
        enable_mask = 0b100000000100000000
    elif action_level == 3 and one == 0 and two == 0 and three == 1:
        enable_mask = 0b100000010000000000
    elif action_level == 3 and one == 1 and two == 1 and three == 0:
        enable_mask = 0b100000000101000000
    elif action_level == 3 and one == 1 and two == 0 and three == 1:
        enable_mask = 0b100000010001000000
    elif action_level == 3 and one == 0 and two == 1 and three == 1:
        enable_mask = 0b100000010100000000
    elif action_level == 3 and one == 1 and two == 1 and three == 1:
        enable_mask = 0b100000010101000000
    elif action_level == 3 and one == 0 and two == 0 and three == 0:
        enable_mask = 0b000000000000000000

    # Enable/Disable LEDs
    enable_leds(enable_mask)
    output([int((math.sin(float(416) / 64.0) + 1.0) * 128.0)] * 18)
コード例 #16
0
def show():
    """Show changes to the backlight"""
    setup()
    _sn3218.output(_buf)
コード例 #17
0
def show():
    sn3218.output(led_values)
コード例 #18
0
def update():
    """
    Update backlight with changes to the LED buffer
    """
    sn3218.output(leds)
コード例 #19
0
def show():
    """Output the contents of the values list to PiGlow."""
    sn3218.output(_values)