Exemplo n.º 1
0
def setup():
    global _is_setup, captouch

    if _is_setup:
        return True

    captouch = cap1xxx.Cap1166(i2c_addr=0x2c)

    for x in range(6):
        captouch.on(x, event='press', handler=_handle_press)
        captouch.on(x, event='release', handler=_handle_release)

    # Unlink the LEDs since Touch pHAT's LEDs don't match up with the channels
    captouch._write_byte(cap1xxx.R_LED_LINKING, 0b00000000)

    _is_setup = True
Exemplo n.º 2
0
def setup():
    """Set up the touch input on GFX HAT"""
    global _cap1166, is_setup

    if is_setup:
        return

    _cap1166 = cap1xxx.Cap1166(i2c_addr=I2C_ADDR)

    for x in range(6):
        _cap1166.set_led_linking(x, 0)

    # Force recalibration
    _cap1166._write_byte(0x26, 0b00111111)
    _cap1166._write_byte(0x1F, 0b01000000)

    is_setup = True
Exemplo n.º 3
0
try:
    import sn3218
except ImportError:
    exit(
        "This library requires the sn3218 module\nInstall with: sudo pip install sn3218"
    )

try:
    import cap1xxx
except ImportError:
    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()