@@ -2027,6 +2027,35 @@ def __init__(self, pin, pull_up=False, bounce_time=1.00):
20272027MotionSensor .when_motion = MotionSensor .when_activated
20282028MotionSensor .when_no_motion = MotionSensor .when_deactivated
20292029
2030+ class TouchSensor (Button ):
2031+ """
2032+ Represents a capacitive touch sensor (e.g. TTP223)
2033+
2034+ :param int pin:
2035+ The pin that the capacitive touch sensor is connected to.
2036+
2037+ :param bool pull_up:
2038+ If :data:`True`, the device will be pulled up to
2039+ HIGH. If :data:`False` (the default), the device will be pulled down to LOW.
2040+ Most capacitive touch sensors work with pull_up=False.
2041+
2042+ :param float bounce_time:
2043+ The bounce time for the device. If set, the device will ignore
2044+ any touch events that happen within the bounce time after a
2045+ touch event. This is useful to prevent false triggers from
2046+ electrical noise or multiple rapid touches.
2047+ Defaults to 0.02 seconds.
2048+ """
2049+
2050+ def __init__ (self , pin , pull_up = False , bounce_time = 0.02 ):
2051+ super ().__init__ (pin = pin , pull_up = pull_up , bounce_time = bounce_time )
2052+
2053+
2054+ TouchSensor .is_touched = TouchSensor .is_active
2055+ # Note: No alias for is_inactive - use 'not touch.is_touched' for clarity
2056+ TouchSensor .when_touched = TouchSensor .when_activated
2057+ TouchSensor .when_touch_ends = TouchSensor .when_deactivated
2058+
20302059
20312060class AnalogInputDevice (InputDevice , PinMixin ):
20322061 """
0 commit comments