Skip to content

Commit

Permalink
Standardise on GPIOn pin labels.
Browse files Browse the repository at this point in the history
As of raspberrypi/linux@bd9542b
all downstream GPIO line names use the form GPIOn, and PIN_n is deprecated.

Simplify code and examples to reflect this.
  • Loading branch information
Gadgetoid committed Apr 17, 2024
1 parent 97c824a commit efb9168
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 28 deletions.
8 changes: 2 additions & 6 deletions enviroplus/gas.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@
MICS6814_GAIN = 6.144

OUTH = gpiod.LineSettings(direction=Direction.OUTPUT, output_value=Value.ACTIVE)
PLATFORMS = {
"Radxa ROCK 5B": {"heater": ("PIN_18", OUTH)},
"Raspberry Pi 5": {"heater": ("PIN18", OUTH)},
"Raspberry Pi 4": {"heater": ("GPIO24", OUTH)}
}


ads1015.I2C_ADDRESS_DEFAULT = ads1015.I2C_ADDRESS_ALTERNATE
_is_setup = False
Expand Down Expand Up @@ -68,7 +64,7 @@ def setup():
else:
adc.set_sample_rate(1600)

_heater = gpiodevice.get_pins_for_platform(PLATFORMS)[0]
_heater = gpiodevice.get_pin("GPIO24")

atexit.register(cleanup)

Expand Down
4 changes: 2 additions & 2 deletions examples/all-in-one-enviro-mini.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
st7735 = st7735.ST7735(
port=0,
cs=1,
dc="PIN21", # "GPIO9" on a Raspberry Pi 4
backlight="PIN32", # "GPIO12" on a Raspberry Pi 4
dc="GPIO9",
backlight="GPIO12",
rotation=270,
spi_speed_hz=10000000
)
Expand Down
4 changes: 2 additions & 2 deletions examples/all-in-one-no-pm.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
st7735 = st7735.ST7735(
port=0,
cs=1,
dc="PIN21", # "GPIO9" on a Raspberry Pi 4
backlight="PIN32", # "GPIO12" on a Raspberry Pi 4
dc="GPIO9",
backlight="GPIO12",
rotation=270,
spi_speed_hz=10000000
)
Expand Down
4 changes: 2 additions & 2 deletions examples/all-in-one.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
st7735 = st7735.ST7735(
port=0,
cs=1,
dc="PIN21", # "GPIO9" on a Raspberry Pi 4
backlight="PIN32", # "GPIO12" on a Raspberry Pi 4
dc="GPIO9",
backlight="GPIO12",
rotation=270,
spi_speed_hz=10000000
)
Expand Down
4 changes: 2 additions & 2 deletions examples/combined.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
st7735 = st7735.ST7735(
port=0,
cs=1,
dc="PIN21", # "GPIO9" on a Raspberry Pi 4
backlight="PIN32", # "GPIO12" on a Raspberry Pi 4
dc="GPIO9",
backlight="GPIO12",
rotation=270,
spi_speed_hz=10000000
)
Expand Down
4 changes: 2 additions & 2 deletions examples/lcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
disp = st7735.ST7735(
port=0,
cs=1,
dc="PIN21", # "GPIO9" on a Raspberry Pi 4
backlight="PIN32", # "GPIO12" on a Raspberry Pi 4
dc="GPIO9",
backlight="GPIO12",
rotation=270,
spi_speed_hz=10000000
)
Expand Down
4 changes: 2 additions & 2 deletions examples/mqtt-all.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ def main():
disp = st7735.ST7735(
port=0,
cs=1,
dc="PIN21", # "GPIO9" on a Raspberry Pi 4
backlight="PIN32", # "GPIO12" on a Raspberry Pi 4
dc="GPIO9",
backlight="GPIO12",
rotation=270,
spi_speed_hz=10000000
)
Expand Down
4 changes: 2 additions & 2 deletions examples/noise-amps-at-freqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
disp = st7735.ST7735(
port=0,
cs=1,
dc="PIN21", # "GPIO9" on a Raspberry Pi 4
backlight="PIN32", # "GPIO12" on a Raspberry Pi 4
dc="GPIO9",
backlight="GPIO12",
rotation=270,
spi_speed_hz=10000000
)
Expand Down
4 changes: 2 additions & 2 deletions examples/noise-profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
disp = st7735.ST7735(
port=0,
cs=1,
dc="PIN21", # "GPIO9" on a Raspberry Pi 4
backlight="PIN32", # "GPIO12" on a Raspberry Pi 4
dc="GPIO9",
backlight="GPIO12",
rotation=270,
spi_speed_hz=10000000
)
Expand Down
4 changes: 2 additions & 2 deletions examples/sensorcommunity.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
disp = st7735.ST7735(
port=0,
cs=1,
dc="PIN21", # "GPIO9" on a Raspberry Pi 4
backlight="PIN32", # "GPIO12" on a Raspberry Pi 4
dc="GPIO9",
backlight="GPIO12",
rotation=270,
spi_speed_hz=10000000
)
Expand Down
4 changes: 2 additions & 2 deletions examples/sensorcommunity_combined.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ def check_wifi():
st7735 = st7735.ST7735(
port=0,
cs=1,
dc="PIN21", # "GPIO9" on a Raspberry Pi 4
backlight="PIN32", # "GPIO12" on a Raspberry Pi 4
dc="GPIO9",
backlight="GPIO12",
rotation=270,
spi_speed_hz=10000000
)
Expand Down
4 changes: 2 additions & 2 deletions examples/weather-and-light.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ def describe_light(light):
disp = st7735.ST7735(
port=0,
cs=1,
dc="PIN21", # "GPIO9" on a Raspberry Pi 4
backlight="PIN32", # "GPIO12" on a Raspberry Pi 4
dc="GPIO9",
backlight="GPIO12",
rotation=270,
spi_speed_hz=10000000
)
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def gpiod():
def gpiodevice():
gpiodevice = mock.Mock()
gpiodevice.get_pins_for_platform.return_value = [(mock.Mock(), 0)]
gpiodevice.get_pin.return_value = [(mock.Mock(), 0)]

sys.modules["gpiodevice"] = gpiodevice
yield gpiodevice
Expand Down

0 comments on commit efb9168

Please sign in to comment.