diff --git a/lib/apds9960/apds9960/device.py b/lib/apds9960/apds9960/device.py index bb11d64a..7a0a7838 100644 --- a/lib/apds9960/apds9960/device.py +++ b/lib/apds9960/apds9960/device.py @@ -1,8 +1,8 @@ +from time import sleep_ms + from apds9960.const import * from apds9960.exceptions import * -from time import sleep_ms - class APDS9960(object): class GestureData: diff --git a/lib/apds9960/examples/ambient_light.py b/lib/apds9960/examples/ambient_light.py index 25950334..77d77a13 100644 --- a/lib/apds9960/examples/ambient_light.py +++ b/lib/apds9960/examples/ambient_light.py @@ -1,8 +1,7 @@ from time import sleep -from machine import I2C - from apds9960 import uAPDS9960 as APDS9960 +from machine import I2C i2c = I2C(1) diff --git a/lib/apds9960/examples/gesture.py b/lib/apds9960/examples/gesture.py index 9dda3def..cb5ee2be 100644 --- a/lib/apds9960/examples/gesture.py +++ b/lib/apds9960/examples/gesture.py @@ -1,17 +1,16 @@ from time import sleep -from machine import I2C - +from apds9960 import uAPDS9960 as APDS9960 from apds9960.const import ( - APDS9960_DIR_NONE, + APDS9960_DIR_DOWN, + APDS9960_DIR_FAR, APDS9960_DIR_LEFT, + APDS9960_DIR_NEAR, + APDS9960_DIR_NONE, APDS9960_DIR_RIGHT, APDS9960_DIR_UP, - APDS9960_DIR_DOWN, - APDS9960_DIR_NEAR, - APDS9960_DIR_FAR, ) -from apds9960 import uAPDS9960 as APDS9960 +from machine import I2C i2c = I2C(1) diff --git a/lib/apds9960/examples/proximity.py b/lib/apds9960/examples/proximity.py index 4185940f..580371a9 100644 --- a/lib/apds9960/examples/proximity.py +++ b/lib/apds9960/examples/proximity.py @@ -1,8 +1,7 @@ from time import sleep -from machine import I2C - from apds9960 import uAPDS9960 as APDS9960 +from machine import I2C i2c = I2C(1) diff --git a/lib/bq27441/bq27441/device.py b/lib/bq27441/bq27441/device.py index 4772d958..94bcf6b5 100644 --- a/lib/bq27441/bq27441/device.py +++ b/lib/bq27441/bq27441/device.py @@ -1,10 +1,10 @@ -from bq27441.const import * -from bq27441.exceptions import * - +import struct from time import sleep_ms, ticks_ms + from machine import Pin -import struct +from bq27441.const import * +from bq27441.exceptions import * # Parameters for the current() function, to specify which current to read diff --git a/lib/bq27441/examples/fuel_gauge.py b/lib/bq27441/examples/fuel_gauge.py index 94e2b464..414c60a4 100644 --- a/lib/bq27441/examples/fuel_gauge.py +++ b/lib/bq27441/examples/fuel_gauge.py @@ -1,8 +1,7 @@ from time import sleep -from machine import I2C - from bq27441 import BQ27441 +from machine import I2C i2c = I2C(1) diff --git a/lib/daplink_flash/examples/config_zone.py b/lib/daplink_flash/examples/config_zone.py index 55fc4546..f1ffb47f 100644 --- a/lib/daplink_flash/examples/config_zone.py +++ b/lib/daplink_flash/examples/config_zone.py @@ -11,9 +11,10 @@ - CLEAR_CONFIG (0x32): erase the entire 1 KB zone """ -from machine import I2C from time import sleep_ms +from machine import I2C + i2c = I2C(1) addr = 0x3B passed = 0 diff --git a/lib/daplink_flash/examples/erase_flash.py b/lib/daplink_flash/examples/erase_flash.py index f40512b9..1777d886 100644 --- a/lib/daplink_flash/examples/erase_flash.py +++ b/lib/daplink_flash/examples/erase_flash.py @@ -1,8 +1,9 @@ """Erase all data from the flash memory.""" -from machine import I2C from time import sleep_ms + from daplink_flash import DaplinkFlash +from machine import I2C i2c = I2C(1) flash = DaplinkFlash(i2c) diff --git a/lib/daplink_flash/examples/flash_info.py b/lib/daplink_flash/examples/flash_info.py index 8af238ed..8be20f4c 100644 --- a/lib/daplink_flash/examples/flash_info.py +++ b/lib/daplink_flash/examples/flash_info.py @@ -1,7 +1,7 @@ """Display DAPLink Flash bridge status and filename.""" -from machine import I2C from daplink_flash import DaplinkFlash +from machine import I2C i2c = I2C(1) flash = DaplinkFlash(i2c) diff --git a/lib/daplink_flash/examples/read_file.py b/lib/daplink_flash/examples/read_file.py index 50c438ce..360e70a3 100644 --- a/lib/daplink_flash/examples/read_file.py +++ b/lib/daplink_flash/examples/read_file.py @@ -1,7 +1,7 @@ """Read and display the current file stored on flash.""" -from machine import I2C from daplink_flash import DaplinkFlash +from machine import I2C i2c = I2C(1) flash = DaplinkFlash(i2c) diff --git a/lib/daplink_flash/examples/sensor_log.py b/lib/daplink_flash/examples/sensor_log.py index 6a29f0fe..a6d82dad 100644 --- a/lib/daplink_flash/examples/sensor_log.py +++ b/lib/daplink_flash/examples/sensor_log.py @@ -5,9 +5,10 @@ for each column. """ -from machine import I2C from time import sleep_ms + from daplink_flash import DaplinkFlash +from machine import I2C # --- Configuration --- NUM_ROWS = 200 diff --git a/lib/daplink_flash/examples/write_csv.py b/lib/daplink_flash/examples/write_csv.py index e83b1256..03d9b742 100644 --- a/lib/daplink_flash/examples/write_csv.py +++ b/lib/daplink_flash/examples/write_csv.py @@ -1,8 +1,9 @@ """Write CSV data to flash via DAPLink bridge.""" -from machine import I2C from time import sleep_ms + from daplink_flash import DaplinkFlash +from machine import I2C i2c = I2C(1) flash = DaplinkFlash(i2c) diff --git a/lib/hts221/examples/humidity.py b/lib/hts221/examples/humidity.py index 356454e7..34cc7f5c 100644 --- a/lib/hts221/examples/humidity.py +++ b/lib/hts221/examples/humidity.py @@ -1,7 +1,8 @@ -from machine import I2C -from hts221 import HTS221 from time import sleep_ms + import pyb +from hts221 import HTS221 +from machine import I2C i2c = I2C(1) diff --git a/lib/hts221/hts221/device.py b/lib/hts221/hts221/device.py index 074783f6..687e17f7 100644 --- a/lib/hts221/hts221/device.py +++ b/lib/hts221/hts221/device.py @@ -1,6 +1,7 @@ -from machine import I2C from time import sleep_ms +from machine import I2C + from hts221.const import * diff --git a/lib/ism330dl/examples/basic_read.py b/lib/ism330dl/examples/basic_read.py index f9c60807..a9e70260 100644 --- a/lib/ism330dl/examples/basic_read.py +++ b/lib/ism330dl/examples/basic_read.py @@ -1,6 +1,7 @@ -from machine import I2C from time import sleep_ms + from ism330dl import ISM330DL +from machine import I2C i2c = I2C(1) diff --git a/lib/ism330dl/examples/motion_orientation.py b/lib/ism330dl/examples/motion_orientation.py index d98a404c..cf9e28bb 100644 --- a/lib/ism330dl/examples/motion_orientation.py +++ b/lib/ism330dl/examples/motion_orientation.py @@ -1,6 +1,7 @@ -from machine import I2C from time import sleep_ms + from ism330dl import ISM330DL +from machine import I2C i2c = I2C(1) diff --git a/lib/ism330dl/examples/static_orientation.py b/lib/ism330dl/examples/static_orientation.py index 2af04420..c2490fd2 100644 --- a/lib/ism330dl/examples/static_orientation.py +++ b/lib/ism330dl/examples/static_orientation.py @@ -1,6 +1,7 @@ -from machine import I2C from time import sleep_ms + from ism330dl import ISM330DL +from machine import I2C i2c = I2C(1) diff --git a/lib/ism330dl/ism330dl/__init__.py b/lib/ism330dl/ism330dl/__init__.py index 19358d98..929a2545 100644 --- a/lib/ism330dl/ism330dl/__init__.py +++ b/lib/ism330dl/ism330dl/__init__.py @@ -1,9 +1,9 @@ from ism330dl.device import ISM330DL from ism330dl.exceptions import ( - ISM330DLError, - ISM330DLNotFound, ISM330DLConfigError, + ISM330DLError, ISM330DLIOError, + ISM330DLNotFound, ) __all__ = [ diff --git a/lib/lis2mdl/examples/magnet_compass.py b/lib/lis2mdl/examples/magnet_compass.py index fb2d79c4..9aee2b93 100644 --- a/lib/lis2mdl/examples/magnet_compass.py +++ b/lib/lis2mdl/examples/magnet_compass.py @@ -1,8 +1,9 @@ # Example of heading reading with direction label from time import sleep_ms -from machine import I2C -from lis2mdl.device import LIS2MDL + from lis2mdl.const import * +from lis2mdl.device import LIS2MDL +from machine import I2C i2c = I2C(1) mag = LIS2MDL(i2c) diff --git a/lib/lis2mdl/examples/magnet_fieldForce.py b/lib/lis2mdl/examples/magnet_fieldForce.py index 4d09a064..809b7492 100644 --- a/lib/lis2mdl/examples/magnet_fieldForce.py +++ b/lib/lis2mdl/examples/magnet_fieldForce.py @@ -1,8 +1,9 @@ # Example of heading reading with direction label from time import sleep_ms -from machine import I2C -from lis2mdl.device import LIS2MDL + from lis2mdl.const import * +from lis2mdl.device import LIS2MDL +from machine import I2C i2c = I2C(1) mag = LIS2MDL(i2c) diff --git a/lib/lis2mdl/examples/magnet_test.py b/lib/lis2mdl/examples/magnet_test.py index a2f0424f..84bee76f 100644 --- a/lib/lis2mdl/examples/magnet_test.py +++ b/lib/lis2mdl/examples/magnet_test.py @@ -1,8 +1,9 @@ +import math from time import sleep_ms -from machine import I2C -from lis2mdl.device import LIS2MDL + from lis2mdl.const import * -import math +from lis2mdl.device import LIS2MDL +from machine import I2C # Définition des constantes pour remplacer les valeurs magiques MAGNETIC_FIELD_MIN = 5.0 diff --git a/lib/lis2mdl/lis2mdl/device.py b/lib/lis2mdl/lis2mdl/device.py index 259f630e..28225f05 100644 --- a/lib/lis2mdl/lis2mdl/device.py +++ b/lib/lis2mdl/lis2mdl/device.py @@ -1,10 +1,12 @@ # device.py # This driver is for the LIS2MDL magnetometer sensor. It provides methods for initialization, calibration, and reading magnetic field data. +import math +from time import sleep_ms + from machine import I2C + from lis2mdl.const import * -from time import sleep_ms -import math class LIS2MDL(object): diff --git a/lib/mcp23009e/examples/buttons.py b/lib/mcp23009e/examples/buttons.py index 4eb12755..760a0c37 100644 --- a/lib/mcp23009e/examples/buttons.py +++ b/lib/mcp23009e/examples/buttons.py @@ -4,8 +4,8 @@ """ from time import sleep -from machine import I2C, Pin +from machine import I2C, Pin from mcp23009e import MCP23009E from mcp23009e.const import * diff --git a/lib/mcp23009e/examples/i2c_scan.py b/lib/mcp23009e/examples/i2c_scan.py index da656ab1..2adc3a43 100644 --- a/lib/mcp23009e/examples/i2c_scan.py +++ b/lib/mcp23009e/examples/i2c_scan.py @@ -3,7 +3,8 @@ Utile pour trouver l'adresse correcte du MCP23009E """ from time import sleep -from machine import I2C,Pin + +from machine import I2C, Pin reset = Pin("RST_EXPANDER") reset.init(Pin.OUT) diff --git a/lib/mcp23009e/examples/test_basic.py b/lib/mcp23009e/examples/test_basic.py index 84bda42d..abb62032 100644 --- a/lib/mcp23009e/examples/test_basic.py +++ b/lib/mcp23009e/examples/test_basic.py @@ -4,8 +4,8 @@ """ from time import sleep -from machine import I2C, Pin +from machine import I2C, Pin from mcp23009e import MCP23009E from mcp23009e.const import * diff --git a/lib/mcp23009e/examples/test_interrupts.py b/lib/mcp23009e/examples/test_interrupts.py index 1901b1a3..b2bd1f68 100644 --- a/lib/mcp23009e/examples/test_interrupts.py +++ b/lib/mcp23009e/examples/test_interrupts.py @@ -4,8 +4,8 @@ """ from time import sleep -from machine import I2C, Pin +from machine import I2C, Pin from mcp23009e import MCP23009E from mcp23009e.const import * diff --git a/lib/mcp23009e/examples/test_led_simple.py b/lib/mcp23009e/examples/test_led_simple.py index caa8ed90..8c9f691b 100644 --- a/lib/mcp23009e/examples/test_led_simple.py +++ b/lib/mcp23009e/examples/test_led_simple.py @@ -8,8 +8,8 @@ """ from time import sleep -from machine import I2C, Pin +from machine import I2C, Pin from mcp23009e import MCP23009E, MCP23009ActiveLowPin from mcp23009e.const import * diff --git a/lib/mcp23009e/examples/test_output.py b/lib/mcp23009e/examples/test_output.py index e02a70ab..8c97d571 100644 --- a/lib/mcp23009e/examples/test_output.py +++ b/lib/mcp23009e/examples/test_output.py @@ -3,8 +3,8 @@ Ce script teste la configuration des GPIO en sortie et le contrôle de leur niveau """ import time -from machine import I2C, Pin +from machine import I2C, Pin from mcp23009e import MCP23009E, MCP23009Pin from mcp23009e.const import * diff --git a/lib/mcp23009e/examples/test_output_active_low.py b/lib/mcp23009e/examples/test_output_active_low.py index 6827497d..5202e831 100644 --- a/lib/mcp23009e/examples/test_output_active_low.py +++ b/lib/mcp23009e/examples/test_output_active_low.py @@ -14,8 +14,8 @@ """ from time import sleep -from machine import I2C, Pin +from machine import I2C, Pin from mcp23009e import MCP23009E, MCP23009Pin from mcp23009e.const import * diff --git a/lib/mcp23009e/examples/test_pin.py b/lib/mcp23009e/examples/test_pin.py index b705825d..0e988f18 100644 --- a/lib/mcp23009e/examples/test_pin.py +++ b/lib/mcp23009e/examples/test_pin.py @@ -4,8 +4,8 @@ """ from time import sleep -from machine import I2C, Pin +from machine import I2C, Pin from mcp23009e import MCP23009E, MCP23009Pin from mcp23009e.const import * diff --git a/lib/mcp23009e/examples/test_pin_irq.py b/lib/mcp23009e/examples/test_pin_irq.py index fc28defa..c87854f1 100644 --- a/lib/mcp23009e/examples/test_pin_irq.py +++ b/lib/mcp23009e/examples/test_pin_irq.py @@ -4,8 +4,8 @@ """ from time import sleep -from machine import I2C, Pin +from machine import I2C, Pin from mcp23009e import MCP23009E, MCP23009Pin from mcp23009e.const import * diff --git a/lib/mcp23009e/mcp23009e/__init__.py b/lib/mcp23009e/mcp23009e/__init__.py index 929ce189..6e6006c1 100644 --- a/lib/mcp23009e/mcp23009e/__init__.py +++ b/lib/mcp23009e/mcp23009e/__init__.py @@ -1,6 +1,6 @@ +from mcp23009e.active_low_pin import MCP23009ActiveLowPin from mcp23009e.device import MCP23009E from mcp23009e.pin import MCP23009Pin -from mcp23009e.active_low_pin import MCP23009ActiveLowPin __all__ = [ "MCP23009E", diff --git a/lib/mcp23009e/mcp23009e/device.py b/lib/mcp23009e/mcp23009e/device.py index 4da65c85..df7bd05c 100644 --- a/lib/mcp23009e/mcp23009e/device.py +++ b/lib/mcp23009e/mcp23009e/device.py @@ -1,9 +1,10 @@ -from machine import I2C, Pin from time import sleep_ms +from machine import I2C, Pin from mcp23009e.const import * + def _set_bit(reg, bit, value): """Modifie un bit spécifique dans un registre""" if value == 0: diff --git a/lib/mcp23009e/mcp23009e/pin.py b/lib/mcp23009e/mcp23009e/pin.py index 3a6c5631..42ad7b80 100644 --- a/lib/mcp23009e/mcp23009e/pin.py +++ b/lib/mcp23009e/mcp23009e/pin.py @@ -4,6 +4,7 @@ """ from machine import Pin as MachinePin + from mcp23009e.const import * diff --git a/lib/ssd1327/examples/bitmap.py b/lib/ssd1327/examples/bitmap.py index dc093cdb..d1d7ad87 100644 --- a/lib/ssd1327/examples/bitmap.py +++ b/lib/ssd1327/examples/bitmap.py @@ -17,7 +17,6 @@ # .....#####...... 00 00 0F FF FF 00 00 00 import ssd1327 - from machine import SPI, Pin # Setup display on SPI bus diff --git a/lib/ssd1327/examples/framebuf_lines.py b/lib/ssd1327/examples/framebuf_lines.py index c1d582ae..f4dce808 100644 --- a/lib/ssd1327/examples/framebuf_lines.py +++ b/lib/ssd1327/examples/framebuf_lines.py @@ -1,5 +1,6 @@ -import ssd1327 from time import sleep + +import ssd1327 from machine import SPI, Pin # Setup display on SPI bus diff --git a/lib/ssd1327/examples/framebuf_pixels.py b/lib/ssd1327/examples/framebuf_pixels.py index bb6afc0f..8f7858db 100644 --- a/lib/ssd1327/examples/framebuf_pixels.py +++ b/lib/ssd1327/examples/framebuf_pixels.py @@ -1,5 +1,6 @@ -import ssd1327 from time import sleep + +import ssd1327 from machine import SPI, Pin # Setup display on SPI bus diff --git a/lib/ssd1327/examples/framebuf_rects.py b/lib/ssd1327/examples/framebuf_rects.py index ef1286b1..8427fa81 100644 --- a/lib/ssd1327/examples/framebuf_rects.py +++ b/lib/ssd1327/examples/framebuf_rects.py @@ -1,5 +1,4 @@ import ssd1327 - from machine import SPI, Pin # Setup display on SPI bus diff --git a/lib/ssd1327/examples/framebuf_scroll.py b/lib/ssd1327/examples/framebuf_scroll.py index 382076b1..d5ba75c2 100644 --- a/lib/ssd1327/examples/framebuf_scroll.py +++ b/lib/ssd1327/examples/framebuf_scroll.py @@ -1,5 +1,6 @@ -import ssd1327 from time import sleep + +import ssd1327 from machine import SPI, Pin # Setup display on SPI bus diff --git a/lib/ssd1327/examples/framebuf_text.py b/lib/ssd1327/examples/framebuf_text.py index c7a0fc7e..f942dc3a 100644 --- a/lib/ssd1327/examples/framebuf_text.py +++ b/lib/ssd1327/examples/framebuf_text.py @@ -1,5 +1,4 @@ import ssd1327 - from machine import SPI, Pin # Setup display on SPI bus diff --git a/lib/ssd1327/examples/hello_world.py b/lib/ssd1327/examples/hello_world.py index e923be92..cc26cb49 100644 --- a/lib/ssd1327/examples/hello_world.py +++ b/lib/ssd1327/examples/hello_world.py @@ -1,5 +1,4 @@ import ssd1327 - from machine import SPI, Pin # Setup display on SPI bus diff --git a/lib/ssd1327/examples/illusion.py b/lib/ssd1327/examples/illusion.py index 92160239..9c70fbe7 100644 --- a/lib/ssd1327/examples/illusion.py +++ b/lib/ssd1327/examples/illusion.py @@ -1,5 +1,4 @@ import ssd1327 - from machine import SPI, Pin # Setup display on SPI bus diff --git a/lib/ssd1327/examples/invert.py b/lib/ssd1327/examples/invert.py index b386e700..4ee86d89 100644 --- a/lib/ssd1327/examples/invert.py +++ b/lib/ssd1327/examples/invert.py @@ -1,7 +1,7 @@ -import ssd1327 +from time import sleep +import ssd1327 from machine import SPI, Pin -from time import sleep # Setup display on SPI bus spi = SPI(1) diff --git a/lib/ssd1327/examples/lookup_table.py b/lib/ssd1327/examples/lookup_table.py index b09091dc..d571bd1a 100644 --- a/lib/ssd1327/examples/lookup_table.py +++ b/lib/ssd1327/examples/lookup_table.py @@ -1,7 +1,7 @@ -import ssd1327 +from time import sleep +import ssd1327 from machine import SPI, Pin -from time import sleep # Setup display on SPI bus spi = SPI(1) diff --git a/lib/ssd1327/examples/micropython_logo.py b/lib/ssd1327/examples/micropython_logo.py index b7f58089..f1b0a548 100644 --- a/lib/ssd1327/examples/micropython_logo.py +++ b/lib/ssd1327/examples/micropython_logo.py @@ -1,5 +1,4 @@ import ssd1327 - from machine import SPI, Pin # Setup display on SPI bus diff --git a/lib/ssd1327/examples/random_pixels.py b/lib/ssd1327/examples/random_pixels.py index 0eb845fb..c04eced0 100644 --- a/lib/ssd1327/examples/random_pixels.py +++ b/lib/ssd1327/examples/random_pixels.py @@ -1,6 +1,5 @@ import ssd1327 import uos - from machine import SPI, Pin # Setup display on SPI bus diff --git a/lib/ssd1327/examples/rotating_3d_cube.py b/lib/ssd1327/examples/rotating_3d_cube.py index 11199d32..bbfb625a 100644 --- a/lib/ssd1327/examples/rotating_3d_cube.py +++ b/lib/ssd1327/examples/rotating_3d_cube.py @@ -1,6 +1,6 @@ -import ssd1327 - import math + +import ssd1327 from machine import SPI, Pin # Setup display on SPI bus diff --git a/lib/ssd1327/examples/rotation.py b/lib/ssd1327/examples/rotation.py index 593d1433..8fd6984d 100644 --- a/lib/ssd1327/examples/rotation.py +++ b/lib/ssd1327/examples/rotation.py @@ -1,7 +1,7 @@ -import ssd1327 +from time import sleep +import ssd1327 from machine import SPI, Pin -from time import sleep # Setup display on SPI bus spi = SPI(1) diff --git a/lib/ssd1327/examples/shades.py b/lib/ssd1327/examples/shades.py index c68f00cd..194e078e 100644 --- a/lib/ssd1327/examples/shades.py +++ b/lib/ssd1327/examples/shades.py @@ -1,5 +1,4 @@ import ssd1327 - from machine import SPI, Pin # Setup display on SPI bus diff --git a/lib/ssd1327/ssd1327/device.py b/lib/ssd1327/ssd1327/device.py index 1ff4135e..8a60a80e 100644 --- a/lib/ssd1327/ssd1327/device.py +++ b/lib/ssd1327/ssd1327/device.py @@ -1,8 +1,9 @@ -from ssd1327.const import * from time import sleep_us import framebuf +from ssd1327.const import * + class SSD1327(object): def __init__(self, width=128, height=128): diff --git a/lib/steami_config/examples/calibrate_temperature.py b/lib/steami_config/examples/calibrate_temperature.py index 07e85bc4..89ef1471 100644 --- a/lib/steami_config/examples/calibrate_temperature.py +++ b/lib/steami_config/examples/calibrate_temperature.py @@ -7,10 +7,10 @@ import gc import sys -from machine import I2C from time import sleep_ms from daplink_flash.device import DaplinkFlash +from machine import I2C from steami_config.device import SteamiConfig from wsen_hids.device import WSEN_HIDS diff --git a/lib/steami_config/examples/show_config.py b/lib/steami_config/examples/show_config.py index 1cb023b3..e242ba35 100644 --- a/lib/steami_config/examples/show_config.py +++ b/lib/steami_config/examples/show_config.py @@ -1,8 +1,7 @@ """Display the current board configuration stored in the config zone.""" -from machine import I2C - from daplink_flash import DaplinkFlash +from machine import I2C from steami_config import SteamiConfig i2c = I2C(1) diff --git a/lib/steami_config/steami_config/device.py b/lib/steami_config/steami_config/device.py index 1a0508b0..f818c989 100644 --- a/lib/steami_config/steami_config/device.py +++ b/lib/steami_config/steami_config/device.py @@ -1,6 +1,5 @@ import json - # Map sensor class names to short JSON keys to save space. _SENSOR_KEYS = { "hts221": "hts", diff --git a/lib/vl53l1x/examples/distance.py b/lib/vl53l1x/examples/distance.py index b57d56ab..4a461bda 100644 --- a/lib/vl53l1x/examples/distance.py +++ b/lib/vl53l1x/examples/distance.py @@ -1,6 +1,7 @@ +import time + from machine import I2C from vl53l1x import VL53L1X -import time i2c = I2C(1) distance = VL53L1X(i2c) diff --git a/lib/wsen-hids/examples/continuous_mode.py b/lib/wsen-hids/examples/continuous_mode.py index a52f232f..341c9c2b 100644 --- a/lib/wsen-hids/examples/continuous_mode.py +++ b/lib/wsen-hids/examples/continuous_mode.py @@ -1,6 +1,6 @@ -from machine import I2C from time import sleep +from machine import I2C from wsen_hids import WSEN_HIDS i2c = I2C(1) diff --git a/lib/wsen-hids/examples/full_test.py b/lib/wsen-hids/examples/full_test.py index 750a0e41..6c0bb692 100644 --- a/lib/wsen-hids/examples/full_test.py +++ b/lib/wsen-hids/examples/full_test.py @@ -1,6 +1,6 @@ -from machine import I2C from time import sleep, sleep_ms +from machine import I2C from wsen_hids import WSEN_HIDS from wsen_hids.const import * diff --git a/lib/wsen-hids/examples/one_shot_mode.py b/lib/wsen-hids/examples/one_shot_mode.py index 3496868d..02d0aaab 100644 --- a/lib/wsen-hids/examples/one_shot_mode.py +++ b/lib/wsen-hids/examples/one_shot_mode.py @@ -1,6 +1,6 @@ -from machine import I2C from time import sleep +from machine import I2C from wsen_hids import WSEN_HIDS i2c = I2C(1) diff --git a/lib/wsen-hids/wsen_hids/device.py b/lib/wsen-hids/wsen_hids/device.py index 2a689acd..c221022e 100644 --- a/lib/wsen-hids/wsen_hids/device.py +++ b/lib/wsen-hids/wsen_hids/device.py @@ -1,10 +1,10 @@ -from time import sleep_ms, ticks_ms, ticks_diff +from time import sleep_ms, ticks_diff, ticks_ms from .const import * from .exceptions import ( - WSENHIDSError, WSENHIDSCommunicationError, WSENHIDSDeviceIDError, + WSENHIDSError, WSENHIDSTimeoutError, ) diff --git a/lib/wsen-pads/examples/altitude.py b/lib/wsen-pads/examples/altitude.py index 4a30962c..c60b72ea 100644 --- a/lib/wsen-pads/examples/altitude.py +++ b/lib/wsen-pads/examples/altitude.py @@ -1,5 +1,6 @@ -from machine import I2C, Pin from time import sleep + +from machine import I2C, Pin from wsen_pads import WSEN_PADS SEA_LEVEL_PRESSURE = 1013.25 # depends on your location, you can adjust it for better altitude estimation diff --git a/lib/wsen-pads/examples/basic_reader.py b/lib/wsen-pads/examples/basic_reader.py index c08d4f38..faef4864 100644 --- a/lib/wsen-pads/examples/basic_reader.py +++ b/lib/wsen-pads/examples/basic_reader.py @@ -1,7 +1,7 @@ -from machine import I2C, Pin from time import sleep -from wsen_pads import WSEN_PADS +from machine import I2C, Pin +from wsen_pads import WSEN_PADS # Update the I2C bus number and pins to match your board i2c = I2C(1) diff --git a/lib/wsen-pads/examples/continuous_reader.py b/lib/wsen-pads/examples/continuous_reader.py index 1b8cea63..b97285be 100644 --- a/lib/wsen-pads/examples/continuous_reader.py +++ b/lib/wsen-pads/examples/continuous_reader.py @@ -1,5 +1,6 @@ -from machine import I2C, Pin from time import sleep + +from machine import I2C, Pin from wsen_pads import WSEN_PADS from wsen_pads.const import ODR_10_HZ diff --git a/lib/wsen-pads/examples/one_shot_reader.py b/lib/wsen-pads/examples/one_shot_reader.py index a0c4afcf..63951c50 100644 --- a/lib/wsen-pads/examples/one_shot_reader.py +++ b/lib/wsen-pads/examples/one_shot_reader.py @@ -1,5 +1,6 @@ -from machine import I2C, Pin from time import sleep + +from machine import I2C, Pin from wsen_pads import WSEN_PADS i2c = I2C(1) diff --git a/lib/wsen-pads/examples/test.py b/lib/wsen-pads/examples/test.py index 3f1a17b2..be356bac 100644 --- a/lib/wsen-pads/examples/test.py +++ b/lib/wsen-pads/examples/test.py @@ -1,15 +1,17 @@ -from machine import I2C, Pin from time import sleep + +from machine import I2C, Pin from wsen_pads import WSEN_PADS from wsen_pads.const import ( ODR_1_HZ, ODR_10_HZ, REG_CTRL_1, REG_CTRL_2, - REG_STATUS, REG_INT_SOURCE, + REG_STATUS, ) + def print_header(title): print() print("=" * 60) diff --git a/lib/wsen-pads/wsen_pads/device.py b/lib/wsen-pads/wsen_pads/device.py index 67b65fd9..c1d2f0f9 100644 --- a/lib/wsen-pads/wsen_pads/device.py +++ b/lib/wsen-pads/wsen_pads/device.py @@ -1,4 +1,4 @@ -from time import sleep_ms, ticks_ms, ticks_diff +from time import sleep_ms, ticks_diff, ticks_ms from wsen_pads.const import * from wsen_pads.exceptions import * diff --git a/pyproject.toml b/pyproject.toml index 4989b76a..03ae4719 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,24 @@ -[tool.isort] -profile = "black" +[project] +name = "micropython-steami-lib" +version = "0.1.0" +description = "MicroPython driver library for the STeaMi board." +license = {text = "GPL-3.0-or-later"} +requires-python = ">=3.7" + +[project.urls] +Homepage = "https://www.steami.cc/" +Repository = "https://github.com/steamicc/micropython-steami-lib" +Documentation = "https://wiki.steami.cc/" +Issues = "https://github.com/steamicc/micropython-steami-lib/issues" + +[tool.pytest.ini_options] +testpaths = ["tests"] +markers = [ + "mock: tests using FakeI2C (no hardware needed)", + "hardware: tests requiring a real board (use --port)", + "manual: tests requiring human validation", + "board: board qualification tests (no driver, hardware only)", +] [tool.ruff] line-length = 99 @@ -7,7 +26,7 @@ target-version = "py37" [tool.ruff.lint] select = [ - "ASYNC", # flake8-comprehensions + "ASYNC", # flake8-async "C4", # flake8-comprehensions "C90", # McCabe cyclomatic complexity "DTZ", # flake8-datetimez @@ -15,9 +34,13 @@ select = [ "EXE", # flake8-executable "F", # Pyflakes "G", # flake8-logging-format + "I", # isort "ICN", # flake8-import-conventions "INT", # flake8-gettext "ISC", # flake8-implicit-str-concat + "N802", # pep8-naming: function name should be lowercase + "N803", # pep8-naming: argument name should be lowercase + "N806", # pep8-naming: variable in function should be lowercase "PGH", # pygrep-hooks "PIE", # flake8-pie "PL", # Pylint @@ -25,63 +48,37 @@ select = [ "RSE", # flake8-raise "RUF", # Ruff-specific rules "T10", # flake8-debugger + "T20", # flake8-print: no print() in production code "TCH", # flake8-type-checking "W", # pycodestyle "YTT", # flake8-2020 - # "A", # flake8-builtins - # "ANN", # flake8-annotations - # "ARG", # flake8-unused-arguments - # "B", # flake8-bugbear - # "BLE", # flake8-blind-except - # "COM", # flake8-commas - # "D", # pydocstyle - # "DJ", # flake8-django - # "EM", # flake8-errmsg - # "ERA", # eradicate - # "FBT", # flake8-boolean-trap - # "I", # isort - # "INP", # flake8-no-pep420 - "N802", # pep8-naming: function name should be lowercase - "N803", # pep8-naming: argument name should be lowercase - "N806", # pep8-naming: variable in function should be lowercase - "T20", # flake8-print: no print() in production code - # "NPY", # NumPy-specific rules - # "PD", # pandas-vet - # "PT", # flake8-pytest-style - # "PTH", # flake8-use-pathlib - # "Q", # flake8-quotes - # "RET", # flake8-return - # "S", # flake8-bandit - # "SIM", # flake8-simplify - # "SLF", # flake8-self - # "T20", # flake8-print - # "TID", # flake8-tidy-imports - # "TRY", # tryceratops - # "UP", # pyupgrade ] ignore = [ - "E722", - "E741", # 'l' is currently widely used - "F401", - "F403", - "F405", - "E501", # line length, recommended to disable - "ISC001", + "E501", # line length, recommended to disable + "E722", # bare except + "E741", # 'l' is currently widely used + "F401", # unused import (wildcard re-exports) + "F403", # wildcard import + "F405", # name from wildcard import + "ISC001", # conflicts with formatter "ISC003", # micropython does not support implicit concatenation of f-strings "PIE810", # micropython does not support passing tuples to .startswith or .endswith - "PLC1901", - "PLR1704", # sometimes desirable to redefine an argument to save code size - "PLR1714", - "PLR5501", - "PLW0602", - "PLW0603", - "PLW2901", - "RUF012", - "RUF100", - "SIM101", - "W191", # tab-indent, redundant when using formatter + "PLC1901", # compare to empty string + "PLR1704", # sometimes desirable to redefine an argument to save code size + "PLR1714", # consider merging multiple comparisons + "PLR5501", # use elif instead of else+if + "PLW0602", # global variable not assigned + "PLW0603", # global statement + "PLW2901", # overwriting loop variable + "RUF012", # mutable class variable + "RUF100", # unused noqa + "SIM101", # merge isinstance calls + "W191", # tab-indent, redundant when using formatter ] +[tool.ruff.lint.isort] +known-third-party = ["micropython"] + [tool.ruff.lint.mccabe] max-complexity = 61 @@ -99,14 +96,7 @@ max-statements = 166 "tests/**/*.py" = ["T20"] [tool.ruff.format] -# Like Black, use double quotes for strings. quote-style = "double" - -# Like Black, indent with spaces, rather than tabs. indent-style = "space" - -# Like Black, respect magic trailing commas. skip-magic-trailing-comma = false - -# Like Black, automatically detect the appropriate line ending. -line-ending = "auto" \ No newline at end of file +line-ending = "auto" diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 8f7efb7f..00000000 --- a/pytest.ini +++ /dev/null @@ -1,6 +0,0 @@ -[pytest] -testpaths = tests -markers = - mock: tests using FakeI2C (no hardware needed) - hardware: tests requiring a real board (use --port) - manual: tests requiring human validation diff --git a/tests/conftest.py b/tests/conftest.py index a4e2f40f..a2da1f13 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,9 +1,9 @@ """Pytest configuration and fixtures for driver testing.""" -import yaml from pathlib import Path import pytest +import yaml pytest_plugins = ["tests.report_plugin"] @@ -23,12 +23,6 @@ def pytest_addoption(parser): ) -def pytest_configure(config): - config.addinivalue_line("markers", "mock: tests that run with FakeI2C (no hardware)") - config.addinivalue_line("markers", "hardware: tests that require a real board") - config.addinivalue_line("markers", "manual: tests that require human validation") - config.addinivalue_line("markers", "board: board qualification tests (no driver, hardware only)") - def pytest_collection_modifyitems(config, items): port = config.getoption("--port") diff --git a/tests/runner/executor.py b/tests/runner/executor.py index bef935b3..887ea83d 100644 --- a/tests/runner/executor.py +++ b/tests/runner/executor.py @@ -12,8 +12,8 @@ def prompt_yes_no(prompt): """ print(f" [MANUAL] {prompt} [Entree=oui / Echap=non] ", end="", flush=True) try: - import tty import termios + import tty fd = sys.stdin.fileno() old = termios.tcgetattr(fd) try: @@ -43,13 +43,11 @@ def load_driver_mock(driver_name, fake_i2c, module_name=None): """ if module_name is None: module_name = driver_name - from tests.fake_machine import FakeI2C, FakePin - from tests.fake_machine import micropython_stub - from tests.fake_machine import framebuf_stub - # Patch modules before importing driver import types + from tests.fake_machine import FakeI2C, FakePin, framebuf_stub, micropython_stub + fake_machine = types.ModuleType("machine") fake_machine.I2C = FakeI2C fake_machine.Pin = FakePin diff --git a/tests/test_scenarios.py b/tests/test_scenarios.py index 07610423..d43ad3e3 100644 --- a/tests/test_scenarios.py +++ b/tests/test_scenarios.py @@ -1,9 +1,9 @@ """Generic pytest runner that loads YAML scenarios and executes them.""" -import yaml from pathlib import Path import pytest +import yaml from tests.fake_machine.i2c import FakeI2C from tests.fake_machine.pin import FakePin