Exemplo n.º 1
0
LED_R_G = 0x01
LED_R_B = 0x02

LED_M_R = 0x03
LED_M_G = 0x04
LED_M_B = 0x05

LED_L_R = 0x06
LED_L_G = 0x07
LED_L_B = 0x08

leds = [0x00] * 18

# set gamma correction for backlight to normalise brightness
g_channel_gamma = [int(value / 1.6) for value in sn3218.default_gamma_table]
sn3218.channel_gamma(1, g_channel_gamma)
sn3218.channel_gamma(4, g_channel_gamma)
sn3218.channel_gamma(7, g_channel_gamma)

r_channel_gamma = [int(value / 1.4) for value in sn3218.default_gamma_table]
sn3218.channel_gamma(0, r_channel_gamma)
sn3218.channel_gamma(3, r_channel_gamma)
sn3218.channel_gamma(6, r_channel_gamma)

w_channel_gamma = [int(value / 24) for value in sn3218.default_gamma_table]
for i in range(9, 18):
    sn3218.channel_gamma(i, w_channel_gamma)

sn3218.enable()

Exemplo n.º 2
0
def off():
    """
    Turns off the backlight.
    """
    rgb(0, 0, 0)


def update():
    """
    Update backlight with changes to the LED buffer
    """
    sn3218.output(leds)


# set gamma correction for backlight to normalise brightness
g_channel_gamma = [int(value / 1.6) for value in sn3218.default_gamma_table]
sn3218.channel_gamma(1, g_channel_gamma)
sn3218.channel_gamma(4, g_channel_gamma)
sn3218.channel_gamma(7, g_channel_gamma)

r_channel_gamma = [int(value / 1.4) for value in sn3218.default_gamma_table]
sn3218.channel_gamma(0, r_channel_gamma)
sn3218.channel_gamma(3, r_channel_gamma)
sn3218.channel_gamma(6, r_channel_gamma)

w_channel_gamma = [int(value / 24) for value in sn3218.default_gamma_table]
for i in range(9, 18):
    sn3218.channel_gamma(i, w_channel_gamma)

sn3218.enable()
Exemplo n.º 3
0
    exit("This library requires the cap1xxx module\nInstall with: sudo pip install cap1xxx")


cap = cap1xxx.Cap1166(i2c_addr=0x2C, skip_init=True)

NUM_LEDS = 6
STEP_VALUE = 16

leds = [0x00] * 18  # B G R, B G R, B G R, B G R, B G R, B G R

# set gamma correction for backlight to normalise brightness
g_channel_gamma = [int(value / 1.6) for value in sn3218.default_gamma_table]
r_channel_gamma = [int(value / 1.4) for value in sn3218.default_gamma_table]

for x in range(0, 18, 3):
    sn3218.channel_gamma(x + 1, g_channel_gamma)
    sn3218.channel_gamma(x + 2, r_channel_gamma)

sn3218.enable()

graph_set_led_state = cap.set_led_state
graph_set_led_polarity = cap.set_led_polarity
graph_set_led_duty = cap.set_led_direct_duty


def use_rbg():
    """
    Swaps the Green and Blue channels on the LED backlight
  
    Use if you have a first batch Display-o-Tron 3K
    """
Exemplo n.º 4
0
        "This library requires the cap1xxx module\nInstall with: sudo pip install cap1xxx"
    )

cap = cap1xxx.Cap1166(i2c_addr=0x2C, skip_init=True)

NUM_LEDS = 6
STEP_VALUE = 16

leds = [0x00] * 18  # B G R, B G R, B G R, B G R, B G R, B G R

# set gamma correction for backlight to normalise brightness
g_channel_gamma = [int(value / 1.6) for value in sn3218.default_gamma_table]
r_channel_gamma = [int(value / 1.4) for value in sn3218.default_gamma_table]

for x in range(0, 18, 3):
    sn3218.channel_gamma(x + 1, g_channel_gamma)
    sn3218.channel_gamma(x + 2, r_channel_gamma)

sn3218.enable()

graph_set_led_state = cap.set_led_state
graph_set_led_polarity = cap.set_led_polarity
graph_set_led_duty = cap.set_led_direct_duty


def use_rbg():
    """Does nothing.

    Implemented for library compatibility with Dot3k backlight.

    """
Exemplo n.º 5
0
 def test_channel_gamma_wrong_channel(self):
     """channel_gamma fails with wrong type"""
     with self.assertRaisesRegex(TypeError, 'channel must be an integer'):
         sn3218.channel_gamma("apple", [0x88] * 256)
Exemplo n.º 6
0
 def test_channel_gamma_ok(self):
     """Set channel gamma"""
     sn3218.channel_gamma(0, [0x88] * 256)
     self.assertEqual(sn3218.channel_gamma_table[0], [0x88] * 256)
Exemplo n.º 7
0
 def test_channel_gamma_wrong_table_len(self):
     """channel_gamma fails with wrong length"""
     with self.assertRaisesRegex(TypeError, 'list of 256 integers'):
         sn3218.channel_gamma(0, [0x88] * 200)
Exemplo n.º 8
0
 def test_channel_gamma_wrong_table(self):
     """channel_gamma fails with wrong type"""
     with self.assertRaisesRegex(TypeError, 'must be a list'):
         sn3218.channel_gamma(0, (1, 2, 3))
Exemplo n.º 9
0
 def test_channel_gamma_wrong_channel_val(self):
     """channel_gamma fails with wrong value"""
     with self.assertRaisesRegex(ValueError, 'in the range 0..17'):
         sn3218.channel_gamma(999, [0x88] * 256)