From ef46f5c43227c2d207e3957523ee419313e2ba92 Mon Sep 17 00:00:00 2001 From: George Harker Date: Wed, 30 Oct 2024 17:10:13 -0700 Subject: [PATCH] repo url updates --- adafruit_seesaw/encoder.py | 73 +++++++++++++++++----------------- adafruit_seesaw/keypad.py | 2 +- adafruit_seesaw/neopixel.py | 3 +- adafruit_seesaw/robohat.py | 2 +- adafruit_seesaw/samd09.py | 2 +- adafruit_seesaw/seesaw.py | 2 +- adafruit_seesaw/tftshield18.py | 5 ++- 7 files changed, 46 insertions(+), 43 deletions(-) diff --git a/adafruit_seesaw/encoder.py b/adafruit_seesaw/encoder.py index a8d4f4a..3e8a7ba 100644 --- a/adafruit_seesaw/encoder.py +++ b/adafruit_seesaw/encoder.py @@ -29,21 +29,21 @@ import struct from dataclasses import dataclass from enum import IntEnum -from typing import NamedTuple -from typing import ClassVar +from typing import ClassVar, List, NamedTuple + try: from micropython import const except ImportError: - def const(x): return x from adafruit_seesaw.seesaw import Seesaw + __version__ = "0.0.0-auto.0" -__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git" +__repo__ = "https://github.com/georgeharker/Adafruit_CircuitPython_seesaw.git" _ENCODER_BASE = const(0x11) @@ -74,6 +74,21 @@ class EncoderError(Exception): pass +class EncoderEdge(IntEnum): + #: Indicates that the switch is currently pressed + EDGE_HIGH = 0 + #: Indicates that the switch is currently released + EDGE_LOW = 1 + #: Indicates that the switch was recently pressed + EDGE_FALLING = 2 + #: Indicates that the switch was recently released + EDGE_RISING = 3 + #: Indicates that the value was recently changed + VALUE_CHANGE = 4 + #: Indicates that the delta was recently updated + DELTA = 5 + + @dataclass class SeesawEncoderResponse: response_type: ResponseType @@ -83,7 +98,7 @@ class SeesawEncoderResponse: def __post_init__(self): try: self.response_type = ResponseType(self.response_type) - except Exception as e: + except Exception as e: # noqa: F841 # print(e) self.responseType = ResponseType.TYPE_INVALID @@ -98,19 +113,14 @@ def unpack_from(cls, buf: bytearray, frm: int): return SeesawEncoderResponse(*cls.unpacker.unpack_from(buf, frm)) -# pylint: disable=too-few-public-methods +@dataclass class EncoderEvent: """Holds information about a key event in its properties - :param int num: The number of the key - :param int edge: One of the EDGE propertes of `adafruit_seesaw.keypad.Keypad` + :param int num: The number of the encoder + :param int edge: One of the EDGE propertes of `EncoderEdge` """ - def __init__(self, num, edge): - self.number = int(num) - self.edge = int(edge) - - # pylint: enable=too-few-public-methods @@ -121,22 +131,9 @@ class Encoder(Seesaw): :param int addr: I2C address of the SeeSaw device :param ~digitalio.DigitalInOut drdy: Pin connected to SeeSaw's 'ready' output""" - #: Indicates that the switch is currently pressed - EDGE_HIGH = 0 - #: Indicates that the switch is currently released - EDGE_LOW = 1 - #: Indicates that the switch was recently pressed - EDGE_FALLING = 2 - #: Indicates that the switch was recently released - EDGE_RISING = 3 - #: Indicates that the value was recently changed - VALUE_CHANGE = 4 - #: Indicates that the delta was recently updated - DELTA = 5 - packer: ClassVar[struct.Struct] = struct.Struct('>I') - def __init__(self, i2c_bus, addr=0x49, drdy=None, num_encoders = _NUM_ENCODERS): + def __init__(self, i2c_bus, addr: int =0x49, drdy=None, num_encoders: int = _NUM_ENCODERS): super(Encoder, self).__init__(i2c_bus, addr, drdy, rd_delay=0.0001, wr_delay=0.0001) self._interrupt_enabled = False @@ -145,12 +142,12 @@ def __init__(self, i2c_bus, addr=0x49, drdy=None, num_encoders = _NUM_ENCODERS): self._tx_count = 0 @property - def interrupt_enabled(self): + def interrupt_enabled(self) -> bool: """Retrieve or set the interrupt enable flag""" return self._interrupt_enabled @interrupt_enabled.setter - def interrupt_enabled(self, value): + def interrupt_enabled(self, value: bool) -> None: if value not in (True, False): raise ValueError("interrupt_enabled must be True or False") @@ -162,7 +159,7 @@ def interrupt_enabled(self, value): self.write8(_ENCODER_BASE, _ENCODER_INTENCLR, enc | 0x01 << 4) @property - def count(self): + def count(self) -> int: """Retrieve or set the number of event""" try: self._tx_count += 1 @@ -172,11 +169,11 @@ def count(self): raise EncoderError("CORRUPTED %s" % list(["%x" % x for x in buf])) if d.data < 0: raise EncoderError("CORRUPTED %s" % list(["%x" % x for x in buf])) - except OSError as e: + except OSError as e: # noqa: F841 self._tx_errors += 1 # print(e) return 0 - except EncoderError as e: + except EncoderError as e: # noqa: F841 self._tx_errors += 1 # print(e) return 0 @@ -184,12 +181,14 @@ def count(self): # pylint: disable=unused-argument, no-self-use @count.setter - def count(self, value): + def count(self, value) -> None: raise AttributeError("count is read only") # pylint: enable=unused-argument, no-self-use - def set_event(self, enc, edge, enable): + def set_event(self, enc: int, + edge: int, # EncoderEdge + enable: bool): """Control which kinds of events are set :param int enc: The encoder number @@ -204,7 +203,7 @@ def set_event(self, enc, edge, enable): cmd = self.packer.pack((enable << 20) | (1 << (edge + 4)) | enc) self.write(_ENCODER_BASE, _ENCODER_EVENT, cmd) - def read_encoders(self, num): + def read_encoders(self, num: int) -> List[SeesawEncoderResponse]: """Read data from the keypad :param int num: The number of bytes to read""" @@ -214,11 +213,11 @@ def read_encoders(self, num): self.read(_ENCODER_BASE, _ENCODER_FIFO, buf) return [SeesawEncoderResponse.unpack_from(buf, i * 4) for i in range(0, num)] - except OSError as e: + except OSError as e: # noqa: F841 self._tx_errors += 1 # print(e) return [] - except EncoderError as e: + except EncoderError as e: # noqa: F841 self._tx_errors += 1 # print(e) return [] diff --git a/adafruit_seesaw/keypad.py b/adafruit_seesaw/keypad.py index e89c9f5..1e5bd50 100644 --- a/adafruit_seesaw/keypad.py +++ b/adafruit_seesaw/keypad.py @@ -44,7 +44,7 @@ def const(x): __version__ = "0.0.0-auto.0" -__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git" +__repo__ = "https://github.com/georgeharker/Adafruit_CircuitPython_seesaw.git" _KEYPAD_BASE = const(0x10) diff --git a/adafruit_seesaw/neopixel.py b/adafruit_seesaw/neopixel.py index 78035ed..ed60220 100644 --- a/adafruit_seesaw/neopixel.py +++ b/adafruit_seesaw/neopixel.py @@ -44,7 +44,7 @@ def const(x): __version__ = "1.2.3" -__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git" +__repo__ = "https://github.com/georgeharker/Adafruit_CircuitPython_seesaw.git" _NEOPIXEL_BASE = const(0x0E) @@ -75,6 +75,7 @@ def const(x): ColorType4 = Tuple[float, float, float, float] ColorType = Union[ColorType3, ColorType4, int] + class NeoPixel: """Control NeoPixels connected to a seesaw diff --git a/adafruit_seesaw/robohat.py b/adafruit_seesaw/robohat.py index 0ff56a0..f72648b 100644 --- a/adafruit_seesaw/robohat.py +++ b/adafruit_seesaw/robohat.py @@ -35,7 +35,7 @@ def const(x): __version__ = "0.0.0-auto.0" -__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git" +__repo__ = "https://github.com/georgeharker/Adafruit_CircuitPython_seesaw.git" # Robo HAT MM1 Board: https://www.crowdsupply.com/robotics-masters/robo-hat-mm1 diff --git a/adafruit_seesaw/samd09.py b/adafruit_seesaw/samd09.py index 4b81f72..80f8e87 100644 --- a/adafruit_seesaw/samd09.py +++ b/adafruit_seesaw/samd09.py @@ -35,7 +35,7 @@ def const(x): __version__ = "0.0.0-auto.0" -__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git" +__repo__ = "https://github.com/georgeharker/Adafruit_CircuitPython_seesaw.git" _ADC_INPUT_0_PIN = const(0x02) _ADC_INPUT_1_PIN = const(0x03) diff --git a/adafruit_seesaw/seesaw.py b/adafruit_seesaw/seesaw.py index 7bda7ce..4ffae9f 100644 --- a/adafruit_seesaw/seesaw.py +++ b/adafruit_seesaw/seesaw.py @@ -65,7 +65,7 @@ def const(x): __version__ = "0.0.0-auto.0" -__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git" +__repo__ = "https://github.com/georgeharker/Adafruit_CircuitPython_seesaw.git" _STATUS_BASE = const(0x00) diff --git a/adafruit_seesaw/tftshield18.py b/adafruit_seesaw/tftshield18.py index 16b050d..e74cf6c 100755 --- a/adafruit_seesaw/tftshield18.py +++ b/adafruit_seesaw/tftshield18.py @@ -27,8 +27,10 @@ """ from collections import namedtuple + import board + try: from micropython import const except ImportError: @@ -39,8 +41,9 @@ def const(x): from adafruit_seesaw.seesaw import Seesaw + __version__ = "0.0.0-auto.0" -__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git" +__repo__ = "https://github.com/georgeharker/Adafruit_CircuitPython_seesaw.git" _TIMER_BASE = const(0x08) _TIMER_PWM = const(0x01)