示例#1
0
#CircuitPlaygroundExpress_CapTouch

import touchio
import board
import time

touch1 = touchio.TouchIn(board.A1)
touch2 = touchio.TouchIn(board.A2)
touch3 = touchio.TouchIn(board.A3)
touch4 = touchio.TouchIn(board.A4)
touch5 = touchio.TouchIn(board.A5)
touch6 = touchio.TouchIn(board.A6)
touch7 = touchio.TouchIn(board.A7)

while True:
    if touch1.value:
        print("A1 touched!")
    if touch2.value:
        print("A2 touched!")
    if touch3.value:
        print("A3 touched!")
    if touch4.value:
        print("A4 touched!")
    if touch5.value:
        print("A5 touched!")
    if touch6.value:
        print("A6 touched!")
    if touch7.value:
        print("A7 touched!")

    time.sleep(0.01)
"""
This example shows how to use the debouncer library on the signals coming from
a cap-sense pin with touchio.
"""
import time
import board
import touchio
from adafruit_debouncer import Debouncer

touch_pad = board.A1
touch = touchio.TouchIn(touch_pad)
touch_debounced = Debouncer(touch)

while True:
    touch_debounced.update()
    if touch_debounced.fell:
        print("Just released")
    if touch_debounced.rose:
        print("Just pressed")
    if touch_debounced.value:
        print("touching")
    else:
        # print('not touching')
        pass
    time.sleep(0.05)
示例#3
0
# Red, green, blue, and simple mixes of 2 or 3.
# Add your own choices here.
COLORS = (
    (0, 255, 0),
    (0, 0, 255),
    (255, 0, 0),
    (0, 255, 255),
    (255, 255, 0),
    (255, 0, 255),
    (255, 255, 255),
)

# The two left touch pads adjust the brightness.
# The right touch pad changes colors.
# Hold down or just tap.
brightness_down = touchio.TouchIn(board.D0)
brightness_up = touchio.TouchIn(board.D2)
change_color = touchio.TouchIn(board.D1)

dotstar = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
BRIGHTNESS_STEPS = 15
# Start at medium brightness, green.
brightness_step = 8
color_index = 0

while True:
    if brightness_down.value:
        # Don't go below 1.
        brightness_step = max(1, brightness_step - 1)

    if brightness_up.value:
# SPDX-FileCopyrightText: 2021 Jeff Epler for Adafruit Industries
#
# SPDX-License-Identifier: MIT

import time
import adafruit_dotstar
from rainbowio import colorwheel
import board
import touchio

pixel = adafruit_dotstar.DotStar(board.APA102_SCK,
                                 board.APA102_MOSI,
                                 1,
                                 brightness=.1)

touch = touchio.TouchIn(board.D1)

hue = 0
while True:
    hue = hue + touch.value * 3
    if hue > 255:  # Wrap back around to red
        hue = hue - 255
    pixel[0] = colorwheel(hue)
    time.sleep(.05)
import adafruit_lis3dh
from neopixel_write import neopixel_write

# CUSTOMIZE SENSITIVITY HERE: smaller numbers = more sensitive to motion
HIT_THRESHOLD = 250
SWING_THRESHOLD = 125

NUM_PIXELS = 30  # NeoPixel strip length (in pixels)
NEOPIXEL_PIN = board.EXTERNAL_NEOPIXEL  # Pin where NeoPixels are connected
STRIP = neopixel.NeoPixel(NEOPIXEL_PIN,
                          NUM_PIXELS,
                          brightness=1,
                          auto_write=False)
STRIP.fill(0)  # NeoPixels off ASAP on startup
STRIP.show()
TOUCH = touchio.TouchIn(board.A2)  # Rightmost capacitive touch pad
AUDIO = audioio.AudioOut(board.A0)  # Speaker
MODE = 0  # Initial mode = OFF
FRAMES = 10  # Pre-calculated animation frames

# Set up accelerometer on I2C bus, 4G range:
I2C = busio.I2C(board.SCL, board.SDA)
try:
    ACCEL = adafruit_lis3dh.LIS3DH_I2C(I2C, address=0x18)  # Production board
except:
    ACCEL = adafruit_lis3dh.LIS3DH_I2C(I2C, address=0x19)  # Beta hardware
ACCEL.range = adafruit_lis3dh.RANGE_4_G


def hsv_to_rgb(hue, saturation, value):
    """
示例#6
0
 def _touch(self, i):
     if not isinstance(self._touches[i], touchio.TouchIn):
         self._touches[i] = touchio.TouchIn(self._touches[i])
         self._touches[i].threshold += self._touch_threshold_adjustment
     return self._touches[i].value
示例#7
0
"""
CircuitPython Touch Input Example - Blinking an LED using a capacitive touch pad.

This example is meant for boards that have capacitive touch pads, and no simple way to wire up
a button. If there is a simple way to wire up a button, or a button built into the board, use
the standard Digital Input template and example.

Update TOUCH_PAD_PIN to the pin for the capacitive touch pad you wish you use.

For example:
If are using a BLM Badge and plan to use the first pad, change TOUCH_PAD_PIN to CAP1.
"""
import board
import digitalio
import touchio

led = digitalio.DigitalInOut(board.D13)
led.direction = digitalio.Direction.OUTPUT

touch = touchio.TouchIn(board.TOUCH_PAD_PIN)

while True:
    if touch.value:
        led.value = True
    else:
        led.value = False
        pass  # not always supported by every board!

bpm = 120  # Beats per minute, change this to suit your tempo

# Enable the speaker
speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
speaker_enable.direction = digitalio.Direction.OUTPUT
speaker_enable.value = True

# Make the input capacitive touchpads
capPins = (board.A1, board.A2, board.A3, board.A4, board.A5, board.A6,
           board.TX)

touchPad = []
for i in range(7):
    touchPad.append(touchio.TouchIn(capPins[i]))

# The seven files assigned to the touchpads
audiofiles = [
    "bd_tek.wav", "elec_hi_snare.wav", "elec_cymbal.wav", "elec_blip2.wav",
    "bd_zome.wav", "bass_hit_c.wav", "drum_cowbell.wav"
]

audio = AudioOut(board.SPEAKER)


def play_file(filename):
    print("playing file " + filename)
    file = open(filename, "rb")
    wave = WaveFile(file)
    audio.play(wave)
try:
    if getattr(board, "CAP_PIN"):
        # Create digitalio objects and pull low for HalloWing M4
        cap_pin = digitalio.DigitalInOut(board.CAP_PIN)
        cap_pin.direction = digitalio.Direction.OUTPUT
        cap_pin.value = False
    if getattr(board, "SPEAKER_ENABLE"):
        # Enable the Speaker
        speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
        speaker_enable.direction = digitalio.Direction.OUTPUT
        speaker_enable.value = True
except AttributeError:
    pass

# Create the touchio objects for HalloWing M0
back_button = touchio.TouchIn(back_pin)
forward_button = touchio.TouchIn(forward_pin)

# Setup the speaker output
a = audioio.AudioOut(board.SPEAKER)


# Helper function that takes in the file name string, splits it at the period, and keeps only the
# beginning of the string. i.e. kitten.bmp becomes kitten.
def basename(file_name):
    return file_name.rsplit('.', 1)[0]


# Helper function to handle wav file playback
def play_file(wav_file_name):
    try:
示例#10
0
                               board.APA102_MOSI,
                               1,
                               brightness=0.5)

# Built in red LED
led = DigitalInOut(board.D13)
led.direction = Direction.OUTPUT

# Analog audio output on A0, using two audio files
audiofiles = ["rimshot.wav", "laugh.wav"]

# Analog input on A1
analog1in = AnalogIn(board.A1)

# Capacitive touch on A2
touch = touchio.TouchIn(board.A2)

# Digital input with pullup on D7, D9, and D10
buttons = []
for p in [board.D7, board.D9, board.D10]:
    button = DigitalInOut(p)
    button.direction = Direction.INPUT
    button.pull = Pull.UP
    buttons.append(button)

# Servo on D12
servo_pwm = pulseio.PWMOut(board.D12, frequency=50)
servo = servo.Servo(servo_pwm)

# NeoPixel strip (of 16 LEDs) connected on D5
NUMPIXELS = 16
示例#11
0
# create the pixel and turn it off
pixel = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.1)
pixel.fill(0x0)

time.sleep(1)  # Sleep for a bit to avoid a race condition on some systems
keyboard = Keyboard(usb_hid.devices)
keyboard_layout = KeyboardLayoutUS(keyboard)  # We're in the US :)

# create the switch, add a pullup, start it with not being pressed
button = DigitalInOut(board.SWITCH)
button.switch_to_input(pull=Pull.DOWN)
button_state = False

# create the captouch element and start it with not touched
touch = touchio.TouchIn(board.TOUCH)
touch_state = False

# print a string on keypress
key_output = "Hello World!\n"

# one character on keypress
# key_output = Keycode.A

# multiple simultaneous keypresses
# key_output = (Keycode.SHIFT, Keycode.A)  # capital A
# key_output = (Keycode.CONTROL, Keycode.ALT, Keycode.DELETE) # three finger salute!

# complex commands! we make a list of dictionary entries for each command
# each line has 'keys' which is either a single key, a list of keys, or a string
# then the 'delay' is in seconds, since we often need to give the computer a minute
示例#12
0
                while temp1_count < 3:
                    cpx.play_tone(280, 1.0)
                    temp1_count += 1
                cpx.pixels.fill((0, 255, 0))
                sleep(0.5)
                cpx.pixels.fill((0, 0, 0))

        if cpx.button_a:
            print('Light Value: ', cpx.light)
            cpx.pixels.fill((255, 255, 0))
            sleep(0.5)
            cpx.pixels.fill((0, 0, 0))

    else:
        #moisture sensor. fancy light output included. same thing on thresholds here.
        touch = touchio.TouchIn(A1)
        if cpx.button_a:
            print('Moisture Level: ', touch.raw_value)
            sleep(2.0)
            if touch.raw_value < 2700:
                cpx.play_tone(300, 1.0)
                cpx.pixels.fill((55, 0, 0))
                sleep(0.5)
                cpx.pixels[0] = (0, 0, 0)
                sleep(0.2)
                cpx.pixels[1] = (0, 0, 0)
                sleep(0.2)
                cpx.pixels[2] = (0, 0, 0)
                sleep(0.2)
                cpx.pixels[3] = (0, 0, 0)
                sleep(0.2)
import time
import board
import pulseio
from adafruit_motor import servo
import touchio

touch_A5 = touchio.TouchIn(board.A5) #setting up wire in pin
touch_A4 = touchio.TouchIn(board.A4) #setting up wire in pin
touch = touchio.TouchIn 


pwm = pulseio.PWMOut(board.A2, duty_cycle=2 ** 15, frequency=50) #setting up pwm 
my_servo = servo.Servo(pwm)

angle = 0 #amgle starts at zero

while True:
    my_servo.angle = angle
    if touch_A4.value: #if wire 4 gets touched
        print("Touched A4")
        if angle < 180: #if angle is less then 180 add 1 to angle
         angle += 1
        time.sleep(0.05)
    if touch_A5.value: #if wire 5 gets touched 
        print("Touched A5") 
        if angle > 0: #if wire is less then subtract 1
         angle -= 1 
        time.sleep(0.05)


# Circuit Playground Capacitive Touch

import time
import board
import touchio

touch_A1 = touchio.TouchIn(board.A1)
touch_A2 = touchio.TouchIn(board.A2)
touch_A3 = touchio.TouchIn(board.A3)
touch_A4 = touchio.TouchIn(board.A4)
touch_A5 = touchio.TouchIn(board.A5)
touch_A6 = touchio.TouchIn(board.A6)
touch_TX = touchio.TouchIn(board.TX)

while True:
    if touch_A1.value:
        print("A1 touched!")
    if touch_A2.value:
        print("A2 touched!")
    if touch_A3.value:
        print("A3 touched!")
    if touch_A4.value:
        print("A4 touched!")
    if touch_A5.value:
        print("A5 touched!")
    if touch_A6.value:
        print("A6 touched!")
    if touch_TX.value:
        print("TX touched!")

    time.sleep(0.01)
示例#15
0
    pins = [
        pin
        for pin in [getattr(board, p) for p in dir(board) if p not in exclude]
        if isinstance(pin, Pin)
    ]
    pin_names = []
    for pin_object in pins:
        if pin_object not in pin_names:
            pin_names.append(pin_object)
    return pin_names


for possible_touch_pin in get_pin_names():  # Get the pin name.
    try:
        touch_pin_object = touchio.TouchIn(
            possible_touch_pin
        )  # Attempt to create the touch object on each pin.
        # Print the touch-capable pins that do not need, or already have, an external pulldown.
        print("Touch on:", str(possible_touch_pin).replace("board.", ""))
    except ValueError as error:  # A ValueError is raised when a pin is invalid or needs a pulldown.
        # Obtain the message associated with the ValueError.
        error_message = getattr(error, "message", str(error))
        if ("pulldown" in
                error_message  # If the ValueError is regarding needing a pulldown...
            ):
            print("Touch (no pulldown) on:",
                  str(possible_touch_pin).replace("board.", ""))
        else:
            print("No touch on:",
                  str(possible_touch_pin).replace("board.", ""))
    except TypeError:  # Error returned when checking a non-pin object in dir(board).
import board
import pulseio
import touchio
from adafruit_slideshow import SlideShow, PlayBackDirection
#pylint: disable=no-member

forward_button = touchio.TouchIn(board.TOUCH4)
back_button = touchio.TouchIn(board.TOUCH1)

brightness_up = touchio.TouchIn(board.TOUCH3)
brightness_down = touchio.TouchIn(board.TOUCH2)

slideshow = SlideShow(board.DISPLAY, pulseio.PWMOut(board.TFT_BACKLIGHT), folder="/",
                      auto_advance=False, dwell=0)

while True:
    if forward_button.value:
        slideshow.direction = PlayBackDirection.FORWARD
        slideshow.advance()
    if back_button.value:
        slideshow.direction = PlayBackDirection.BACKWARD
        slideshow.advance()

    if brightness_up.value:
        slideshow.brightness += 0.001
    elif brightness_down.value:
        slideshow.brightness -= 0.001
示例#17
0
)

led = DigitalInOut(board.LED)  # defaults to input
led.direction = Direction.OUTPUT

pitch_up_index = 22
pitch_down_index = 21
mod_up_index = 19
mod_down_index = 18
chan_up_index = 20
chan_down_index = 17

touch_ins = []
touchs = []
for pin in touch_pins:
    touchin = touchio.TouchIn(pin)
    touchin.threshold += touch_threshold_adjust
    touch_ins.append(touchin)
    touchs.append(Debouncer(touchin))

print("\n----------")
print("picotouch hello")
while True:
    for i in range(len(touchs)):
        touch = touchs[i]
        touch.update()
        if touch.rose:
            led.value = True
            if i == chan_up_index:
                print('chan up!')
                midi_channel = min(midi_channel + 1, 15)
示例#18
0
import time
import board
import touchio
import audioio
from digitalio import DigitalInOut, Direction

# enable the speaker
spkrenable = DigitalInOut(board.SPEAKER_ENABLE)
spkrenable.direction = Direction.OUTPUT
spkrenable.value = True

touch1 = touchio.TouchIn(board.A1)

a = audioio.AudioOut(board.A0)

previous = touch1.value


def play_file(filename):
    print("playing file " + filename)
    f = open(filename, "rb")
    wave = audioio.WaveFile(f)
    a.play(wave)


while True:
    play_file('drumSamples/bd_tek.wav')

    #    previous = current

    time.sleep(1)
示例#19
0
# It is highly recommended to connect the speaker output to a speaker system to enhance the game play
spkrenable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
spkrenable.direction = digitalio.Direction.OUTPUT
spkrenable.value = True

# Mute Switch for Sound
#sound_switch = digitalio.DigitalInOut(board.D7)
#sound_switch.direction = digitalio.Direction.INPUT
#sound_switch.pull = digitalio.Pull.UP

# Beginning of Code Section for Game Input Selection Options
#
# Comment and Uncomment code approriately based on the type of input you want to play the game
# CPX TOUCH INPUT OPTION
# Left Move Touch Option for Offensive Player
button_left_move = touchio.TouchIn(board.A4)
# Right Move Touch Option for Offensive Player
button_right_move = touchio.TouchIn(board.A3)

# CPX BUTTON A and BUTTON B INPUT OPTION
# Left Move CPX Button Option for Offensive Player
#button_left_move = digitalio.DigitalInOut(board.BUTTON_A)
#button_left_move.direction = digitalio.Direction.INPUT
#button_left_move.pull = digitalio.Pull.DOWN
# Right Move CPX Button Option for Offensive Player
#button_right_move = digitalio.DigitalInOut(board.BUTTON_B)
#button_right_move.direction = digitalio.Direction.INPUT
#button_right_move.pull = digitalio.Pull.DOWN

# CPX BUTTON SHIELD INPUT OPTION
# Left Move CPX Button Shield Option for Offensive Player
示例#20
0
# use the touchio with CPE to read capacitive touch input and print data

# import modules
import board
import time
import touchio
import neopixel

# declare objects and variables
# declare touchIn object on CPE cap-touch pin (A1 - A6)
touchPin = touchio.TouchIn(board.A1)
a2_in = touchio.TouchIn(board.A2)
a3_in = touchio.TouchIn(board.A3)
a4_in = touchio.TouchIn(board.A4)
a5_in = touchio.TouchIn(board.A5)
a6_in = touchio.TouchIn(board.A6)

on_off_val = 0
color_1_val = 0
color_2_val = 0
color_3_val = 0

# use the neopixels to show if the touch pin is touched
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10)
COLOR = (0, 25, 255)
CLEAR = (0, 0, 0)

change_step = 50
# repeat forever
while True:
    # gather input
示例#21
0
# Trinket IO demo - captouch

import time

import board
import touchio

touch0 = touchio.TouchIn(board.D1)
touch1 = touchio.TouchIn(board.D3)
touch2 = touchio.TouchIn(board.D4)

while True:
    if touch0.value:
        print("D1 touched!")
    if touch1.value:
        print("D3 touched!")
    if touch2.value:
        print("D4 touched!")
    time.sleep(0.01)
示例#22
0
import time
import board
import pulseio # This module makes pwm objects work
import touchio # This is the module necessary to make capacitive touch work
from adafruit_motor import servo # Getting the servo library so its commands will work

touch_A1 = touchio.TouchIn(board.A1) #These are the two pins that I just have wires sticking out of
touch_A2 = touchio.TouchIn(board.A2) #When you touch either of the two wires, it grounds and you can make something happen

# create a PWMOut object on Pin A2.
pwm = pulseio.PWMOut(board.D9, duty_cycle=2 ** 15, frequency=50) #This is the setup for my servo, it's similar to that of an LED

angle = 90 # Starting the servo in the middle, not moving
# Create a servo object, my_servo.
my_servo = servo.Servo(pwm)

while True:
    if touch_A1.value: # If the first wire is touched
        if angle <= 179: # and the angle isn't too big
            my_servo.angle = angle 
            time.sleep(.03)
            angle = angle+1 # Move the servo one direction
    if touch_A2.value: # If the other wire is touched
        if angle >= 1: # and the angle isn't too small
            my_servo.angle = angle
            time.sleep(.03)
            angle = angle-1 # Move the servo the other direction

示例#23
0
#Cap touch servo
import time
import board
import pulseio
from adafruit_motor import servo
import touchio
 
 
touch_A1 = touchio.TouchIn(board.A1)   
touch_A2 = touchio.TouchIn(board.A2)
# create a PWMOut object on Pin A2.
pwm = pulseio.PWMOut(board.D5, duty_cycle=2 ** 15, frequency=50)
angle = 0
# Create a servo object, my_servo.
my_servo = servo.Servo(pwm)
 
while True:
    if touch_A1.value:
        print("Touched A1!")
        if angle < 180:
            angle = angle + 5
        my_servo.angle = angle
        time.sleep(0.05)
    if touch_A2.value:
        print("Touched A2!")
        if angle > 0:
            angle = angle - 5
        my_servo.angle = angle
        time.sleep(0.05)
示例#24
0
import time  #pylint: disable-msg=import-error
import board  #pylint: disable-msg=import-error
import pulseio  #pylint: disable-msg=import-error
import touchio  #pylint: disable-msg=import-error
import adafruit_motor  #pylint: disable-msg=import-error
from adafruit_motor import servo  #pylint: disable-msg=import-error

pwm = pulseio.PWMOut(board.A2, duty_cycle=2**15, frequency=50)
touch_pad = board.A3  #pin for first touch wire
touch_pad2 = board.A5  #pin for second touch wire
my_servo = servo.Servo(pwm)
touch = touchio.TouchIn(touch_pad)
touch2 = touchio.TouchIn(touch_pad2)
my_servo.angle = 90  #puts servo in the middle

while True:

    if touch.value:  #if first touch wire is being pushed
        if my_servo.angle > 179.1:  #if it reached 180 degrees
            my_servo.angle = 1  #go back to 1 degree
        else:  #if it is between 1 and 180 degrees
            my_servo.angle += 1  #keep moving to the right
        print(my_servo.angle)  #print angle
        time.sleep(0.05)
    if touch2.value:  #if second wire is touched
        if my_servo.angle < .9:  #if it reached 1 degree
            my_servo.angle = 179  #go back to 179 degrees
        else:  #if it is between 1 and 179
            my_servo.angle -= 1  #move to the left
        print(my_servo.angle)
        time.sleep(0.05)
# Gemma IO demo - captouch

import time

import board
import touchio

touch0 = touchio.TouchIn(board.A0)
touch1 = touchio.TouchIn(board.A1)
touch2 = touchio.TouchIn(board.A2)

while True:
    if touch0.value:
        print("A0 touched!")
    if touch1.value:
        print("A1 touched!")
    if touch2.value:
        print("A2 touched!")
    time.sleep(0.01)
示例#26
0
# Touch button.
import time
import board
import touchio
import neopixel
import digitalio
from digitalio import DriveMode

led = neopixel.NeoPixel(board.NEOPIXEL, 1)
led.brightness = 1

play_touch = touchio.TouchIn(board.A0)
touch_up = touchio.TouchIn(board.A2)
touch_down = touchio.TouchIn(board.A4)

play_button = digitalio.DigitalInOut(board.D13)
down_button = digitalio.DigitalInOut(board.D8)
up_button = digitalio.DigitalInOut(board.D4)


def setup():
    play_button.direction = digitalio.Direction.OUTPUT
    down_button.direction = digitalio.Direction.OUTPUT
    up_button.direction = digitalio.Direction.OUTPUT
    play_button.drive_mode = DriveMode.PUSH_PULL
    down_button.drive_mode = DriveMode.PUSH_PULL
    up_button.drive_mode = DriveMode.PUSH_PULL


def launcher():
    setup()
"""
CircuitPython Capacitive Two Touch Pad Example - Print to the serial console when a pad is touched.

Update TOUCH_PAD_PIN_ONE to the first touch pad pin name for the board you're using.
Update TOUCH_PAD_PIN_TWO to the pin name for the second touch pad.

For example:
If you are using the BLM Badge, update TOUCH_PAD_PIN_ONE to CAP1, and TOUCH_PAD_PIN_TWO to CAP2.
If using a CPX, update TOUCH_PAD_PIN to A1, and TOUCH_PAD_PIN_TWO to A2.
"""
import time
import board
import touchio

touch_one = touchio.TouchIn(board.TOUCH_PAD_PIN_ONE)
touch_two = touchio.TouchIn(board.TOUCH_PAD_PIN_TWO)

while True:
    if touch_one.value:
        print("Pad one touched!")
    if touch_two.value:
        print("Pad two touched!")
    time.sleep(0.1)
示例#28
0
import time
import board
import pulseio
from adafruit_motor import servo
import touchio

# create a PWMOut object on A2.
pwm = pulseio.PWMOut(board.A2, duty_cycle=2 ** 15, frequency=50)

# sets the pins for the touch sensing wires
touch_A1 = touchio.TouchIn(board.A1)
touch_A0 = touchio.TouchIn(board.A0)

# Create a servo named serv.
serv = servo.Servo(pwm)

angle = 0


print("Here we go!")
while True:
    if touch_A0.value and angle < 180:
        print("Touched A0!")
        angle += 3
        serv.angle = angle
    elif touch_A1.value and angle > 0:
        angle -= 3
        print("Touched A1!")
        serv.angle = angle
    time.sleep(.05)
    print("Done")
示例#29
0
#FILENAME = "afbanner.bmp"
#FILENAME = "blinka.bmp"
#FILENAME = "ghost.bmp"
#FILENAME = "helix-32x30.bmp"
#FILENAME = "wales2-107x30.bmp"
#FILENAME = "pumpkin.bmp"
#FILENAME = "rainbow.bmp"
#FILENAME = "rainbowRoad.bmp"
#FILENAME = "rainbowZig.bmp"
#FILENAME = "skull.bmp"
#FILENAME = "adabot.bmp"
#FILENAME = "green_stripes.bmp"
#FILENAME = "red_blue.bmp"
#FILENAME = "minerva.bmp"

TOUCH = touchio.TouchIn(board.A5)  #  capacitive touch pad
SPEED = 10000
SPEED_ADJUST = 2500  # This value changes the increment for button speed adjustments
BRIGHTNESS = 1.0  # Set brightness here, NOT in NeoPixel constructor
GAMMA = 2.7  # Adjusts perceived brighthess linearity
NUM_PIXELS = 30  # NeoPixel strip length (in pixels)
NEOPIXEL_PIN = board.A1  # Pin where NeoPixels are connected
DELAY_TIME = 0.01  # Timer delay before it starts
LOOP = False  # Set to True for looping

# button setup
button_a = DigitalInOut(board.BUTTON_A)
button_a.direction = Direction.INPUT
button_a.pull = Pull.DOWN

button_b = DigitalInOut(board.BUTTON_B)
midi_channel = 1
midi = adafruit_midi.MIDI(midi_out=usb_midi.ports[1],
                          out_channel=midi_channel-1)

# CPX counter-clockwise order of touch capable pads (i.e. not A0)
pads = [board.A4,
        board.A5,
        board.A6,
        board.A7,
        board.A1,
        board.A2,
        board.A3]

# The touch pads calibrate themselves as they are created, just once here
touchpads = [touchio.TouchIn(pad) for pad in pads]
del pads  # done with that

pb_midpoint = 8192
pitch_bend_value = pb_midpoint  # mid point - no bend
min_pb_change = 250

mod_wheel = 0
min_mod_change = 5

# button A is on left (usb at top)
button_left = digitalio.DigitalInOut(board.BUTTON_A)
button_left.switch_to_input(pull=digitalio.Pull.DOWN)
button_right = digitalio.DigitalInOut(board.BUTTON_B)
button_right.switch_to_input(pull=digitalio.Pull.DOWN)
switch_left = digitalio.DigitalInOut(board.SLIDE_SWITCH)