Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,12 +459,19 @@ lib/<component>/

### Coding conventions

- **Constants**: use `from micropython import const` in `const.py` files.
- **Constants**: use `from micropython import const` wrapper in `const.py` files.
- **Naming**: `snake_case` for new methods. Legacy `camelCase` is acceptable for I2C helpers to stay consistent with existing drivers.
- **Class inheritance**: `class Foo(object):` is the existing convention.
- **Time**: use `from time import sleep_ms` (not `utime`).
- **Time**: use `from time import sleep_ms` (not `utime`, not `sleep()` with float seconds).
- **Exceptions**: use `except Exception:` instead of bare `except:`.
- **No debug `print()`** in production driver code.

### Driver API conventions

- **Constructor signature**: `def __init__(self, i2c, ..., address=DEFAULT_ADDR)` — first parameter is always `i2c` (not `bus`), address uses keyword argument with a default from `const.py`.
- **Attributes**: `self.i2c` for the I2C bus, `self.address` for the device address (not `self.bus`, `self.addr`).
- **I2C helpers**: use private snake_case methods `_read_reg()`, `_write_reg()` for register access. Legacy names (`setReg`, `getReg`, `i2cReadBytes`, etc.) are acceptable in existing drivers but new drivers must use the standard naming.

### Linting

The project uses [ruff](https://docs.astral.sh/ruff/) (config in `pyproject.toml`).
Expand Down
2 changes: 1 addition & 1 deletion lib/apds9960/apds9960/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from time import sleep


class APDS9960:
class APDS9960(object):
class GestureData:
def __init__(self):
self.u_data = [0] * 32
Expand Down
14 changes: 7 additions & 7 deletions lib/bq27441/bq27441/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# Parameters for the current() function, to specify which current to read
# current_measure types
class CurrentMeasureType:
class CurrentMeasureType(object):
AVG = 0 # Average Current (DEFAULT)
STBY = 1 # Standby Current
MAX = 2 # Max Current
Expand All @@ -19,7 +19,7 @@ def __init__(self, value):


# Parameters for the capacity() function, to specify which capacity to read
class CapacityMeasureType:
class CapacityMeasureType(object):
REMAIN = 0 # Remaining Capacity (DEFAULT)
FULL = 1 # Full Capacity
AVAIL = 2 # Available Capacity
Expand All @@ -35,7 +35,7 @@ def __init__(self, value):


# Parameters for the soc() function
class SocMeasureType:
class SocMeasureType(object):
FILTERED = 0 # State of Charge Filtered (DEFAULT)
UNFILTERED = 1 # State of Charge Unfiltered

Expand All @@ -44,7 +44,7 @@ def __init__(self, value):


# Parameters for the soh() function
class SohMeasureType:
class SohMeasureType(object):
PERCENT = 0 # State of Health Percentage (DEFAULT)
SOH_STAT = 1 # State of Health Status Bits

Expand All @@ -53,7 +53,7 @@ def __init__(self, value):


# Parameters for the temperature() function
class TempMeasureType:
class TempMeasureType(object):
BATTERY = 0 # Battery Temperature (DEFAULT)
INTERNAL_TEMP = 1 # Internal IC Temperature

Expand All @@ -62,15 +62,15 @@ def __init__(self, value):


# Parameters for the setGPOUTFunction() funciton
class GpoutFunctionType:
class GpoutFunctionType(object):
SOC_INT = 0 # Set GPOUT to SOC_INT functionality
BAT_LOW = 1 # Set GPOUT to BAT_LOW functionality

def __init__(self, value):
self.value = value


class BQ27441:
class BQ27441(object):
"""BQ27441 class contains all major and minor functions use to read and control
the fuel gauge ic"""

Expand Down
2 changes: 1 addition & 1 deletion lib/ssd1327/ssd1327/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import framebuf


class SSD1327:
class SSD1327(object):
def __init__(self, width=128, height=128):
self.width = width
self.height = height
Expand Down
2 changes: 1 addition & 1 deletion lib/vl53l1x/vl53l1x/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
)


class VL53L1X:
class VL53L1X(object):
def __init__(self, i2c, address=0x29):
self.i2c = i2c
self.address = address
Expand Down
2 changes: 1 addition & 1 deletion lib/wsen-hids/wsen_hids/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
)


class WSEN_HIDS:
class WSEN_HIDS(object):
"""
MicroPython driver for the WSEN-HIDS 2525020210001.

Expand Down
2 changes: 1 addition & 1 deletion lib/wsen-pads/wsen_pads/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from wsen_pads.exceptions import *


class WSEN_PADS:
class WSEN_PADS(object):
Comment thread
nedseb marked this conversation as resolved.
"""
MicroPython driver for the Würth Elektronik WSEN-PADS pressure sensor.

Expand Down
Loading