Skip to content

Commit d81eeb1

Browse files
ozgurkaraaslanOzgur
andauthored
Refactor: remove i2c init (sixfab#95)
* chore: add macos files to .gitignore * refactor: Remove I2C initilization * refactor: remove I2C functions from tests --------- Co-authored-by: Ozgur <ozgur@Ozgur-Air.mshome.net>
1 parent 1c4a5be commit d81eeb1

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

pico_lte/modules/peripherals.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Module for incuding periheral hardware functions of PicoLTE module.
33
"""
44

5-
from machine import Pin, I2C
5+
from machine import Pin
66
from neopixel import NeoPixel
77

88

@@ -16,8 +16,6 @@ class Periph:
1616
pico_led = Pin("LED", Pin.OUT)
1717
neopixel = Pin(15, Pin.OUT)
1818

19-
qwiic = I2C(0, scl=Pin(13), sda=Pin(12), freq=400_000)
20-
2119
def __init__(self):
2220
"""
2321
Constructor for Periph class
@@ -50,9 +48,3 @@ def adjust_neopixel(self, red, green, blue):
5048
neopixel = NeoPixel(self.neopixel, 8)
5149
neopixel[0] = (red, green, blue)
5250
neopixel.write()
53-
54-
def qwiic_scan(self):
55-
"""
56-
Function for scanning QWIIC devices
57-
"""
58-
return self.qwiic.scan()

tests/test_modules_peripherals.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Test module for the modules.peripheral module.
33
"""
44
import pytest
5-
from machine import Pin, I2C
5+
from machine import Pin
66

77
from pico_lte.modules.peripherals import Periph
88

@@ -33,8 +33,6 @@ def test_pin_set_up(self, periph):
3333
assert isinstance(periph.neopixel, Pin)
3434
assert periph.neopixel.pin_num == 15
3535
assert periph.neopixel.pin_dir == Pin.OUT
36-
# Test the Qwiic protocol.
37-
assert isinstance(periph.qwiic, I2C)
3836

3937
@pytest.mark.parametrize("pin_value", [0, 1])
4038
def test_read_user_button(self, mocker, periph, pin_value):
@@ -45,9 +43,3 @@ def test_read_user_button(self, mocker, periph, pin_value):
4543
def test_adjust_neopixel(self):
4644
"""No need since its a third-party library."""
4745
assert True
48-
49-
@pytest.mark.parametrize("mocked_response", [[104, 105], []])
50-
def test_qwiic_scan(self, mocker, periph, mocked_response):
51-
"""This method tests the qwiic_scan() with mocked responses."""
52-
mocker.patch("pico_lte.modules.peripherals.I2C.scan", return_value=mocked_response)
53-
assert periph.qwiic_scan() == mocked_response

0 commit comments

Comments
 (0)