diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b13412e..88d6597 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,20 +1,19 @@ repos: - - repo: https://github.com/python/black - rev: 23.11.0 - hooks: - - id: black - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v5.0.0 hooks: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.7 + rev: v0.11.4 hooks: + # Run the linter. - id: ruff + # Run the formatter. + - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.7.1 + rev: v1.15.0 hooks: - id: mypy name: mypy (library code) diff --git a/.readthedocs.yml b/.readthedocs.yml index ee18767..507dc5b 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,9 +1,13 @@ version: 2 +sphinx: + # Path to your Sphinx configuration file. + configuration: docs/conf.py + build: - os: "ubuntu-22.04" + os: "ubuntu-24.04" tools: - python: "3.11" + python: "latest" python: install: diff --git a/circuitpython_cirque_pinnacle.py b/circuitpython_cirque_pinnacle.py index 32b362b..221fb10 100644 --- a/circuitpython_cirque_pinnacle.py +++ b/circuitpython_cirque_pinnacle.py @@ -2,6 +2,7 @@ A driver module for the Cirque Pinnacle ASIC on the Cirque capacitive touch based circular trackpads. """ + __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/2bndy5/CircuitPython_Cirque_Pinnacle.git" import time @@ -40,9 +41,9 @@ PINNACLE_MUX_REF0: int = const(0x08) #: enables a builtin capacitor (~0.25 pF). PINNACLE_MUX_PNP: int = const(0x04) #: enable PNP sense line PINNACLE_MUX_NPN: int = const(0x01) #: enable NPN sense line -PINNACLE_CRTL_REPEAT: int = const(0x80) #: required for more than 1 measurement +PINNACLE_CTRL_REPEAT: int = const(0x80) #: required for more than 1 measurement #: triggers low power mode (sleep) after completing measurements -PINNACLE_CRTL_PWR_IDLE: int = const(0x40) +PINNACLE_CTRL_PWR_IDLE: int = const(0x40) # Defined constants for Pinnacle registers _FIRMWARE_ID: int = const(0x00) @@ -163,39 +164,66 @@ class PinnacleTouch: :param dr_pin: |dr_pin_parameter| - .. important:: |dr_pin_note| + .. versionchanged:: 2.0.0 ``dr_pin`` is a required parameter. - .. |dr_pin_parameter| replace:: The input pin connected to the Pinnacle ASIC's "Data - Ready" pin. If this parameter is not specified, then the SW_DR (software data - ready) flag of the STATUS register is used to determine if the data being - reported is new. + |dr_pin_required| - .. |dr_pin_note| replace:: This parameter must be specified if your application is - going to use the Pinnacle ASIC's `PINNACLE_ANYMEAS` mode (a rather experimental - measuring of raw ADC values). + .. |dr_pin_parameter| replace:: The input pin connected to the Pinnacle ASIC's "Data + Ready" pin. + .. |dr_pin_required| replace:: + Previously, this parameter was conditionally optional. """ - def __init__(self, dr_pin: Optional[digitalio.DigitalInOut] = None): + def __init__(self, dr_pin: digitalio.DigitalInOut): self.dr_pin = dr_pin - if self.dr_pin is not None: - self.dr_pin.switch_to_input() + self.dr_pin.switch_to_input() firmware_id, firmware_ver = self._rap_read_bytes(_FIRMWARE_ID, 2) - if firmware_id != 7 or firmware_ver != 0x3A: + self._rev2025: bool = firmware_id == 0x0E and firmware_ver == 0x75 + if not self._rev2025 and (firmware_id, firmware_ver) != (7, 0x3A): raise RuntimeError("Cirque Pinnacle ASIC not responding") self._intellimouse = False self._mode = PINNACLE_RELATIVE - self.detect_finger_stylus() + if not self._rev2025: + self.detect_finger_stylus() + else: + self.sample_rate = 100 self._rap_write(_Z_IDLE, 30) # z-idle packet count self._rap_write_bytes(_SYS_CONFIG, bytes(3)) # config data mode, power, etc - self.set_adc_gain(0) + if not self._rev2025: + self.set_adc_gain(0) while self.available(): self.clear_status_flags() - if not self.calibrate() and dr_pin is not None: + if not self.calibrate(): raise AttributeError( "Calibration did not complete. Check wiring to `dr_pin`." ) self.feed_enable = True + @property + def rev2025(self) -> bool: + """Is this trackpad using a newer firmware version? + + This read-only property describes if the Pinnacle ASIC uses a firmware revision + that was deployed on or around 2025. Consequently, some advanced configuration + is not possible with this undocumented firmware revision. + Thus, the following functionality is affected on the trackpads when this + property returns ``True``: + + - :py:attr:`~circuitpython_cirque_pinnacle.PinnacleTouch.sample_rate` cannot + exceed ``100`` + - :py:attr:`~circuitpython_cirque_pinnacle.PinnacleTouch.detect_finger_stylus()` + is non-operational + - :py:meth:`~circuitpython_cirque_pinnacle.PinnacleTouch.tune_edge_sensitivity()` + is non-operational + - :py:meth:`~circuitpython_cirque_pinnacle.PinnacleTouch.set_adc_gain()` + is non-operational + - :py:attr:`~circuitpython_cirque_pinnacle.PinnacleTouch.calibration_matrix` + is non-operational + + .. versionadded:: 2.0.0 + """ + return self._rev2025 + @property def feed_enable(self) -> bool: """This `bool` attribute controls if the touch/button event data is @@ -246,10 +274,6 @@ def data_mode(self, mode: int): self._rap_write(_FEED_CONFIG_1, 1 | mode) # set mode flag, enable feed self._intellimouse = False else: # for AnyMeas mode - if self.dr_pin is None: # AnyMeas requires the DR pin - raise AttributeError( - "need the Data Ready (DR) pin specified for AnyMeas mode" - ) # disable tracking computations for AnyMeas mode self._rap_write(_SYS_CONFIG, sys_config | 0x08) time.sleep(0.01) # wait for tracking computations to expire @@ -308,7 +332,7 @@ def relative_mode_config( self._rap_write_cmd(req_seq) # verify w/ cmd to read the device ID response = self._rap_read_bytes(0xF2, 3) - self._intellimouse = response.startswith(b"\xF3\x03") + self._intellimouse = response.startswith(b"\xf3\x03") def absolute_mode_config( self, z_idle_count: int = 30, invert_x: bool = False, invert_y: bool = False @@ -336,14 +360,10 @@ def absolute_mode_config( def available(self) -> bool: """Determine if there is fresh data to report. - If the ``dr_pin`` parameter is specified upon instantiation, then the specified - input pin is used to detect if the data is new. Otherwise the SW_DR flag in the - STATUS register is used to determine if the data is new. + This is just a convenience method to check the ``dr_pin.value``. :Returns: ``True`` if there is fresh data to report, otherwise ``False``. """ - if self.dr_pin is None: - return bool(self._rap_read(_STATUS) & 0x0C) return self.dr_pin.value def read( @@ -451,12 +471,17 @@ def sample_rate(self) -> int: """This attribute controls how many samples (of data) per second are reported. Valid values are ``100``, ``80``, ``60``, ``40``, ``20``, ``10``. Any other - input values automatically set the sample rate to 100 sps (samples per second). - Optionally, ``200`` and ``300`` sps can be specified, but using these values - automatically disables palm (referred to as "NERD" in the specification sheet) - and noise compensations. These higher values are meant for using a stylus with a - 2mm diameter tip, while the values less than 200 are meant for a finger or - stylus with a 5.25mm diameter tip. + input values automatically set the sample rate to ``100`` sps (samples per + second). + + Optionally (on older trackpads), ``200`` and ``300`` sps can be specified, but + using these values automatically disables palm (referred to as "NERD" in the + specification sheet) and noise compensations. These higher values are meant for + using a stylus with a 2mm diameter tip, while the values less than 200 are meant + for a finger or stylus with a 5.25mm diameter tip. + + .. warning:: The values ``200`` and ``300`` are |rev2025| Specifying these values on + newer trackpads will be automatically clamped to ``100``. This attribute only applies to `PINNACLE_RELATIVE` or `PINNACLE_ABSOLUTE` mode. Otherwise if `data_mode` is set to `PINNACLE_ANYMEAS`, then this attribute will @@ -467,7 +492,7 @@ def sample_rate(self) -> int: @sample_rate.setter def sample_rate(self, val: int): if self._mode != PINNACLE_ANYMEAS: - if val in (200, 300): + if val in (200, 300) and not self._rev2025: # disable palm & noise compensations self._rap_write(_FEED_CONFIG_3, 10) reload_timer = 6 if val == 300 else 0x09 @@ -476,7 +501,8 @@ def sample_rate(self, val: int): else: # enable palm & noise compensations self._rap_write(_FEED_CONFIG_3, 0) - self._era_write_bytes(0x019E, 0x13, 2) + if not self._rev2025: + self._era_write_bytes(0x019E, 0x13, 2) val = val if val in (100, 80, 60, 40, 20, 10) else 100 self._rap_write(_SAMPLE_RATE, val) @@ -489,6 +515,8 @@ def detect_finger_stylus( """This function will configure the Pinnacle ASIC to detect either finger, stylus, or both. + .. warning:: This method is |rev2025| Calling this method |rev2025-no-effect|. + :param enable_finger: ``True`` enables the Pinnacle ASIC's measurements to detect if the touch event was caused by a finger or 5.25 mm stylus. ``False`` disables this feature. Default is ``True``. @@ -502,6 +530,8 @@ def detect_finger_stylus( Consider adjusting the ADC matrix's gain to enhance performance/results using `set_adc_gain()` """ + if self._rev2025: + return finger_stylus = self._era_read(0x00EB) finger_stylus |= (enable_stylus << 2) | enable_finger self._era_write(0x00EB, finger_stylus) @@ -563,6 +593,9 @@ def calibration_matrix(self) -> List[int]: values stored in the Pinnacle ASIC's memory that is used for taking measurements. + .. warning:: This attribute is |rev2025| Using this attribute + |rev2025-no-effect| and return an empty `list`. + This matrix is not applicable in AnyMeas mode. Use this attribute to compare a prior compensation matrix with a new matrix that was either loaded manually by setting this attribute to a `list` of 46 signed 16-bit (short) integers or @@ -586,12 +619,16 @@ def calibration_matrix(self) -> List[int]: that differ by more than 500 and write this new matrix, with the average values, back into Pinnacle ASIC. """ + if self._rev2025: + return [] # combine every 2 bytes from resulting buffer into list of signed # 16-bits integers return list(struct.unpack("46h", self._era_read_bytes(0x01DF, 92))) @calibration_matrix.setter def calibration_matrix(self, matrix: List[int]): + if self._rev2025: + return matrix += [0] * (46 - len(matrix)) # pad short matrices w/ 0s for index in range(46): buf = struct.pack("h", matrix[index]) @@ -602,6 +639,8 @@ def set_adc_gain(self, sensitivity: int): """Sets the ADC gain in range [0, 3] to enhance performance based on the overlay type (does not apply to AnyMeas mode). + .. warning:: This method is |rev2025| Calling this method |rev2025-no-effect|. + :param sensitivity: Specifies how sensitive the ADC (Analog to Digital Converter) component is. ``0`` means most sensitive, and ``3`` means least sensitive. A value outside this range will raise a `ValueError` exception. @@ -610,6 +649,8 @@ def set_adc_gain(self, sensitivity: int): The official example code from Cirque for a curved overlay uses a value of ``1``. """ + if self._rev2025: + return if not 0 <= sensitivity < 4: raise ValueError("sensitivity is out of bounds [0,3]") val = self._era_read(0x0187) & 0x3F | (sensitivity << 6) @@ -620,11 +661,15 @@ def tune_edge_sensitivity( ): """Changes thresholds to improve detection of fingers. + .. warning:: This method is |rev2025| Calling this method |rev2025-no-effect|. + .. warning:: This function was ported from Cirque's example code and doesn't seem to have corresponding documentation. This function directly alters values in the Pinnacle ASIC's memory. USE AT YOUR OWN RISK! """ + if self._rev2025: + return self._era_write(0x0149, x_axis_wide_z_min) self._era_write(0x0168, y_axis_wide_z_min) @@ -634,7 +679,7 @@ def anymeas_mode_config( frequency: int = PINNACLE_FREQ_0, sample_length: int = 512, mux_ctrl: int = PINNACLE_MUX_PNP, - apperture_width: int = 500, + aperture_width: int = 500, ctrl_pwr_cnt: int = 1, ): """This function configures the Pinnacle ASIC to output raw ADC @@ -655,21 +700,21 @@ def anymeas_mode_config( and/or reference capacitors. Valid values are the constants defined in `AnyMeas mode Muxing`_. Additional combination of these constants is also allowed. Defaults to `PINNACLE_MUX_PNP`. - :param apperture_width: Sets the window of time (in nanoseconds) to allow for + :param aperture_width: Sets the window of time (in nanoseconds) to allow for the ADC to take a measurement. Valid values are multiples of 125 in range [``250``, ``1875``]. Erroneous values are clamped/truncated to this range. - .. note:: The ``apperture_width`` parameter has a inverse + .. note:: The ``aperture_width`` parameter has a inverse relationship/affect on the ``frequency`` parameter. The approximated frequencies described in this documentation are based on an aperture - width of 500 nanoseconds, and they will shrink as the apperture width + width of 500 nanoseconds, and they will shrink as the aperture width grows or grow as the aperture width shrinks. :param ctrl_pwr_cnt: Configure the Pinnacle to perform a number of measurements for each call to `measure_adc()`. Defaults to 1. Constants defined in `AnyMeas mode Control`_ can be used to specify if is sleep is allowed - (`PINNACLE_CRTL_PWR_IDLE` -- this is not default) or if repetitive - measurements is allowed (`PINNACLE_CRTL_REPEAT`) if number of measurements + (`PINNACLE_CTRL_PWR_IDLE` -- this is not default) or if repetitive + measurements is allowed (`PINNACLE_CTRL_REPEAT`) if number of measurements is more than 1. .. warning:: @@ -687,7 +732,7 @@ def anymeas_mode_config( buffer[0] = gain | frequency buffer[1] = max(1, min(int(sample_length / 128), 3)) buffer[2] = mux_ctrl - buffer[4] = max(2, min(int(apperture_width / 125), 15)) + buffer[4] = max(2, min(int(aperture_width / 125), 15)) buffer[6] = _PACKET_BYTE_1 buffer[9] = ctrl_pwr_cnt self._rap_write_bytes(_FEED_CONFIG_2, buffer) @@ -828,10 +873,16 @@ def _era_read(self, reg: int) -> int: prev_feed_state = self.feed_enable if prev_feed_state: self.feed_enable = False # accessing raw memory, so do this + if self._rev2025: + self.clear_status_flags() self._rap_write_bytes(_ERA_ADDR, bytes([reg >> 8, reg & 0xFF])) self._rap_write(_ERA_CONTROL, 1) # indicate reading only 1 byte - while self._rap_read(_ERA_CONTROL): # read until reg == 0 - pass # also sets Command Complete flag in Status register + if self._rev2025: + while not self.dr_pin.value: # wait for command to complete + pass + else: + while self._rap_read(_ERA_CONTROL): # read until reg == 0 + pass # also sets Command Complete flag in Status register buf = self._rap_read(_ERA_VALUE) # get value self.clear_status_flags() if prev_feed_state: @@ -843,11 +894,17 @@ def _era_read_bytes(self, reg: int, numb_bytes: int) -> bytes: prev_feed_state = self.feed_enable if prev_feed_state: self.feed_enable = False # accessing raw memory, so do this + if self._rev2025: + self.clear_status_flags() self._rap_write_bytes(_ERA_ADDR, bytes([reg >> 8, reg & 0xFF])) for _ in range(numb_bytes): self._rap_write(_ERA_CONTROL, 5) # indicate reading sequential bytes - while self._rap_read(_ERA_CONTROL): # read until reg == 0 - pass # also sets Command Complete flag in Status register + if self._rev2025: + while not self.dr_pin.value: # wait for command to complete + pass + else: + while self._rap_read(_ERA_CONTROL): # read until reg == 0 + pass # also sets Command Complete flag in Status register buf += bytes([self._rap_read(_ERA_VALUE)]) # get value self.clear_status_flags() if prev_feed_state: @@ -858,11 +915,17 @@ def _era_write(self, reg: int, value: int): prev_feed_state = self.feed_enable if prev_feed_state: self.feed_enable = False # accessing raw memory, so do this + if self._rev2025: + self.clear_status_flags() self._rap_write(_ERA_VALUE, value) # write value self._rap_write_bytes(_ERA_ADDR, bytes([reg >> 8, reg & 0xFF])) self._rap_write(_ERA_CONTROL, 2) # indicate writing only 1 byte - while self._rap_read(_ERA_CONTROL): # read until reg == 0 - pass # also sets Command Complete flag in Status register + if self._rev2025: + while not self.dr_pin.value: # wait for command to complete + pass + else: + while self._rap_read(_ERA_CONTROL): # read until reg == 0 + pass # also sets Command Complete flag in Status register self.clear_status_flags() if prev_feed_state: self.feed_enable = prev_feed_state # resume previous feed state @@ -872,12 +935,18 @@ def _era_write_bytes(self, reg: int, value: int, numb_bytes: int): prev_feed_state = self.feed_enable if prev_feed_state: self.feed_enable = False # accessing raw memory, so do this + if self._rev2025: + self.clear_status_flags() self._rap_write(_ERA_VALUE, value) # write value self._rap_write_bytes(_ERA_ADDR, bytes([reg >> 8, reg & 0xFF])) self._rap_write(_ERA_CONTROL, 0x0A) # indicate writing sequential bytes for _ in range(numb_bytes): - while self._rap_read(_ERA_CONTROL): # read until reg == 0 - pass # also sets Command Complete flag in Status register + if self._rev2025: + while not self.dr_pin.value: # wait for command to complete + pass + else: + while self._rap_read(_ERA_CONTROL): # read until reg == 0 + pass # also sets Command Complete flag in Status register self.clear_status_flags() if prev_feed_state: self.feed_enable = prev_feed_state # resume previous feed state @@ -889,17 +958,19 @@ class PinnacleTouchI2C(PinnacleTouch): :param i2c: The object of the I2C bus to use. This object must be shared among other driver classes that use the same I2C bus (SDA & SCL pins). - :param address: The slave I2C address of the Pinnacle ASIC. Defaults to ``0x2A``. :param dr_pin: |dr_pin_parameter| - .. important:: |dr_pin_note| + .. versionchanged:: 2.0.0 ``dr_pin`` is a required parameter. + + |dr_pin_required| + :param address: The slave I2C address of the Pinnacle ASIC. Defaults to ``0x2A``. """ def __init__( self, i2c: busio.I2C, + dr_pin: digitalio.DigitalInOut, address: int = 0x2A, - dr_pin: Optional[digitalio.DigitalInOut] = None, ): self._i2c = I2CDevice(i2c, address) super().__init__(dr_pin=dr_pin) @@ -938,24 +1009,26 @@ class PinnacleTouchSPI(PinnacleTouch): :param spi: The object of the SPI bus to use. This object must be shared among other driver classes that use the same SPI bus (MOSI, MISO, & SCK pins). :param ss_pin: The "slave select" pin output to the Pinnacle ASIC. - :param spi_frequency: The SPI bus speed in Hz. Default is the maximum 13 MHz. :param dr_pin: |dr_pin_parameter| - .. important:: |dr_pin_note| + .. versionchanged:: 2.0.0 ``dr_pin`` is a required parameter. + + |dr_pin_required| + :param spi_frequency: The SPI bus speed in Hz. Default is the maximum 13 MHz. """ def __init__( self, spi: busio.SPI, ss_pin: digitalio.DigitalInOut, + dr_pin: digitalio.DigitalInOut, spi_frequency: int = 13000000, - dr_pin: Optional[digitalio.DigitalInOut] = None, ): self._spi = SPIDevice(spi, chip_select=ss_pin, phase=1, baudrate=spi_frequency) super().__init__(dr_pin=dr_pin) def _rap_read(self, reg: int) -> int: - buf_out = bytes([reg | 0xA0]) + b"\xFB" * 3 + buf_out = bytes([reg | 0xA0]) + b"\xfb" * 3 buf_in = bytearray(len(buf_out)) with self._spi as spi: spi.write_readinto(buf_out, buf_in) @@ -963,7 +1036,7 @@ def _rap_read(self, reg: int) -> int: def _rap_read_bytes(self, reg: int, numb_bytes: int) -> bytearray: # using auto-increment method - buf_out = bytes([reg | 0xA0]) + b"\xFC" * (1 + numb_bytes) + b"\xFB" + buf_out = bytes([reg | 0xA0]) + b"\xfc" * (1 + numb_bytes) + b"\xfb" buf_in = bytearray(len(buf_out)) with self._spi as spi: spi.write_readinto(buf_out, buf_in) diff --git a/cspell.config.yml b/cspell.config.yml new file mode 100644 index 0000000..453a657 --- /dev/null +++ b/cspell.config.yml @@ -0,0 +1,23 @@ +version: "0.2" +words: + - adafruit + - autoattribute + - autoclass + - automethod + - ANYMEAS + - ASIC + - baudrate + - busio + - circuitpython + - datasheet + - digitalio + - intellimouse + - micropython + - MOSI + - Muxing + - pipx + - seealso + - sparkfun + - tolower + - trackpad + - trackpads diff --git a/docs/anymeas.rst b/docs/anymeas.rst index 9057e7a..d93ebeb 100644 --- a/docs/anymeas.rst +++ b/docs/anymeas.rst @@ -88,8 +88,8 @@ AnyMeas mode Control These constants control the number of measurements performed in `measure_adc()`. The number of measurements can range [0, 63]. -.. autodata:: circuitpython_cirque_pinnacle.PINNACLE_CRTL_REPEAT +.. autodata:: circuitpython_cirque_pinnacle.PINNACLE_CTRL_REPEAT :no-value: -.. autodata:: circuitpython_cirque_pinnacle.PINNACLE_CRTL_PWR_IDLE +.. autodata:: circuitpython_cirque_pinnacle.PINNACLE_CTRL_PWR_IDLE :no-value: diff --git a/docs/api.rst b/docs/api.rst index 4834c81..3d0f7b3 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -19,6 +19,7 @@ PinnacleTouch class :no-members: .. autoattribute:: circuitpython_cirque_pinnacle.PinnacleTouch.data_mode + .. autoattribute:: circuitpython_cirque_pinnacle.PinnacleTouch.rev2025 SPI & I2C Interfaces -------------------- diff --git a/docs/conf.py b/docs/conf.py index 26f1c07..946a861 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,5 +1,6 @@ # pylint: disable=invalid-name,too-few-public-methods """This file is for `sphinx-build` configuration""" + import os import sys @@ -86,6 +87,10 @@ :language: python :class: highlight .. default-literal-role:: python + +.. |rev2025| replace:: not supported on trackpads manufactured on or after 2025. + Defer to :py:attr:`~circuitpython_cirque_pinnacle.PinnacleTouch.rev2025`. +.. |rev2025-no-effect| replace:: on newer trackpads will have no effect """ # If true, '()' will be appended to :func: etc. cross-reference text. @@ -112,6 +117,13 @@ ], # Set the color and the accent color "palette": [ + { + "media": "(prefers-color-scheme)", + "toggle": { + "icon": "material/brightness-auto", + "name": "Switch to light mode", + }, + }, { "media": "(prefers-color-scheme: light)", "scheme": "default", diff --git a/examples/cirque_pinnacle_absolute_mode.py b/examples/cirque_pinnacle_absolute_mode.py index 1cfa37c..5373f78 100644 --- a/examples/cirque_pinnacle_absolute_mode.py +++ b/examples/cirque_pinnacle_absolute_mode.py @@ -1,6 +1,7 @@ """ A simple example of using the Pinnacle ASIC in absolute mode. """ + import math import sys import time @@ -17,21 +18,18 @@ print("Cirque Pinnacle absolute mode\n") -# a HW ``dr_pin`` is more efficient, but not required for Absolute or Relative modes -dr_pin = None -if not input("Use SW Data Ready? [y/N] ").lower().startswith("y"): - print("-- Using HW Data Ready pin.") - dr_pin = DigitalInOut(board.D7 if not IS_ON_LINUX else board.D25) +# the pin connected to the trackpad's DR pin. +dr_pin = DigitalInOut(board.D7 if not IS_ON_LINUX else board.D25) if not input("Is the trackpad configured for I2C? [y/N] ").lower().startswith("y"): print("-- Using SPI interface.") spi = board.SPI() ss_pin = DigitalInOut(board.D2 if not IS_ON_LINUX else board.CE0) - trackpad = PinnacleTouchSPI(spi, ss_pin, dr_pin=dr_pin) + trackpad = PinnacleTouchSPI(spi, ss_pin, dr_pin) else: print("-- Using I2C interface.") i2c = board.I2C() - trackpad = PinnacleTouchI2C(i2c, dr_pin=dr_pin) + trackpad = PinnacleTouchI2C(i2c, dr_pin) trackpad.data_mode = PINNACLE_ABSOLUTE # ensure Absolute mode is enabled trackpad.absolute_mode_config(z_idle_count=1) # limit idle packet count to 1 diff --git a/examples/cirque_pinnacle_anymeas_mode.py b/examples/cirque_pinnacle_anymeas_mode.py index fe31d25..22ab4cc 100644 --- a/examples/cirque_pinnacle_anymeas_mode.py +++ b/examples/cirque_pinnacle_anymeas_mode.py @@ -1,6 +1,7 @@ """ A simple example of using the Pinnacle ASIC in anymeas mode. """ + import sys import time import board @@ -15,18 +16,18 @@ print("Cirque Pinnacle anymeas mode\n") -# Using HW Data Ready pin as required for Anymeas mode +# the pin connected to the trackpad's DR pin. dr_pin = DigitalInOut(board.D7 if not IS_ON_LINUX else board.D25) if not input("Is the trackpad configured for I2C? [y/N] ").lower().startswith("y"): print("-- Using SPI interface.") spi = board.SPI() ss_pin = DigitalInOut(board.D2 if not IS_ON_LINUX else board.CE0) - trackpad = PinnacleTouchSPI(spi, ss_pin, dr_pin=dr_pin) + trackpad = PinnacleTouchSPI(spi, ss_pin, dr_pin) else: print("-- Using I2C interface.") i2c = board.I2C() - trackpad = PinnacleTouchI2C(i2c, dr_pin=dr_pin) + trackpad = PinnacleTouchI2C(i2c, dr_pin) trackpad.data_mode = PINNACLE_ANYMEAS diff --git a/examples/cirque_pinnacle_relative_mode.py b/examples/cirque_pinnacle_relative_mode.py index 9585280..4cc827e 100644 --- a/examples/cirque_pinnacle_relative_mode.py +++ b/examples/cirque_pinnacle_relative_mode.py @@ -1,6 +1,7 @@ """ A simple example of using the Pinnacle ASIC in relative mode. """ + import sys import time import board @@ -16,21 +17,18 @@ print("Cirque Pinnacle relative mode\n") -# a HW ``dr_pin`` is more efficient, but not required for Absolute or Relative modes -dr_pin = None -if not input("Use SW Data Ready? [y/N] ").lower().startswith("y"): - print("-- Using HW Data Ready pin.") - dr_pin = DigitalInOut(board.D7 if not IS_ON_LINUX else board.D25) +# the pin connected to the trackpad's DR pin. +dr_pin = DigitalInOut(board.D7 if not IS_ON_LINUX else board.D25) if not input("Is the trackpad configured for I2C? [y/N] ").lower().startswith("y"): print("-- Using SPI interface.") spi = board.SPI() ss_pin = DigitalInOut(board.D2 if not IS_ON_LINUX else board.CE0) - trackpad = PinnacleTouchSPI(spi, ss_pin, dr_pin=dr_pin) + trackpad = PinnacleTouchSPI(spi, ss_pin, dr_pin) else: print("-- Using I2C interface.") i2c = board.I2C() - trackpad = PinnacleTouchI2C(i2c, dr_pin=dr_pin) + trackpad = PinnacleTouchI2C(i2c, dr_pin) trackpad.data_mode = PINNACLE_RELATIVE # ensure mouse mode is enabled trackpad.relative_mode_config(True) # enable tap detection diff --git a/examples/cirque_pinnacle_usb_mouse.py b/examples/cirque_pinnacle_usb_mouse.py index 68cedee..24e8341 100644 --- a/examples/cirque_pinnacle_usb_mouse.py +++ b/examples/cirque_pinnacle_usb_mouse.py @@ -4,6 +4,7 @@ NOTE: This example won't work on Linux (eg. using Raspberry Pi GPIO pins). """ + import sys import time import board @@ -20,21 +21,18 @@ print("Cirque Pinnacle as a USB mouse\n") -# a HW ``dr_pin`` is more efficient, but not required for Absolute or Relative modes -dr_pin = None -if not input("Use SW Data Ready? [y/N] ").lower().startswith("y"): - print("-- Using HW Data Ready pin.") - dr_pin = DigitalInOut(board.D7 if not IS_ON_LINUX else board.D25) +# the pin connected to the trackpad's DR pin. +dr_pin = DigitalInOut(board.D7 if not IS_ON_LINUX else board.D25) if not input("Is the trackpad configured for I2C? [y/N] ").lower().startswith("y"): print("-- Using SPI interface.") spi = board.SPI() ss_pin = DigitalInOut(board.D2 if not IS_ON_LINUX else board.CE0) - trackpad = PinnacleTouchSPI(spi, ss_pin, dr_pin=dr_pin) + trackpad = PinnacleTouchSPI(spi, ss_pin, dr_pin) else: print("-- Using I2C interface.") i2c = board.I2C() - trackpad = PinnacleTouchI2C(i2c, dr_pin=dr_pin) + trackpad = PinnacleTouchI2C(i2c, dr_pin) trackpad.data_mode = PINNACLE_RELATIVE # ensure mouse mode is enabled # tell the Pinnacle ASIC to rotate the orientation of the axis data by +90 degrees diff --git a/setup.py b/setup.py index 87b326e..f38892e 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ """All setup/install info is now in pyproject.toml""" + from setuptools import setup setup()