Skip to content

Commit d333824

Browse files
committed
Change default pins in examples to use named pins
1 parent 240cd11 commit d333824

File tree

4 files changed

+28
-21
lines changed

4 files changed

+28
-21
lines changed

red_vision_examples/ex08_high_fps_camera.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
# Import machine and rp2 for I2C and PIO.
3232
import machine
33+
from machine import Pin
3334
import rp2
3435
i2c = machine.I2C()
3536
rp2.PIO(1).gpio_base(16)
@@ -61,8 +62,8 @@
6162
spi = machine.SPI(
6263
baudrate = 24_000_000,
6364
),
64-
pin_dc = 20,
65-
pin_cs = 21,
65+
pin_dc = Pin.board.DISPLAY_DC,
66+
pin_cs = Pin.board.DISPLAY_CS,
6667
)
6768
driver_display = rv.displays.ST7789(
6869
interface = interface_display,
@@ -78,11 +79,11 @@
7879
# color format.
7980
interface_camera = rv.cameras.DVP_RP2_PIO(
8081
sm_id = 5,
81-
pin_d0 = 28,
82-
pin_vsync = 42,
83-
pin_hsync = 41,
84-
pin_pclk = 40,
85-
pin_xclk = 44, # Specify the XCLK pin if needed by your camera.
82+
pin_d0 = Pin.board.CAMERA_D0,
83+
pin_vsync = Pin.board.CAMERA_VSYNC,
84+
pin_hsync = Pin.board.CAMERA_HSYNC,
85+
pin_pclk = Pin.board.CAMERA_PCLK,
86+
pin_xclk = Pin.board.CAMERA_XCLK, # Specify the XCLK pin if needed.
8687
)
8788
driver_camera = rv.cameras.OV5640(
8889
interface = interface_camera,

red_vision_examples/rv_init/camera.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
# Import the Red Vision package.
1616
import red_vision as rv
1717

18+
# Import the Pin class for the board's default pins.
19+
from machine import Pin
20+
1821
################################################################################
1922
# DVP Camera
2023
################################################################################
@@ -29,13 +32,13 @@
2932
# PIO interface, only available on Raspberry Pi RP2 processors.
3033
interface = rv.cameras.DVP_RP2_PIO(
3134
sm_id = 5,
32-
pin_d0 = 28,
33-
pin_vsync = 42,
34-
pin_hsync = 41,
35-
pin_pclk = 40,
35+
pin_d0 = Pin.board.CAMERA_D0,
36+
pin_vsync = Pin.board.CAMERA_VSYNC,
37+
pin_hsync = Pin.board.CAMERA_HSYNC,
38+
pin_pclk = Pin.board.CAMERA_PCLK,
3639

3740
# Optionally specify the XCLK pin if needed by your camera.
38-
pin_xclk = 44,
41+
# pin_xclk = Pin.board.CAMERA_XCLK,
3942
)
4043

4144
##########

red_vision_examples/rv_init/display.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
# Import the Red Vision package.
1616
import red_vision as rv
1717

18+
# Import the Pin class for the board's default pins.
19+
from machine import Pin
20+
1821
################################################################################
1922
# SPI Display
2023
################################################################################
@@ -30,18 +33,18 @@
3033
# the fastest option (24Mbps on RP2350).
3134
interface = rv.displays.SPI_Generic(
3235
spi = spi,
33-
pin_dc = 20,
34-
pin_cs = 21,
36+
pin_dc = Pin.board.DISPLAY_DC,
37+
pin_cs = Pin.board.DISPLAY_CS,
3538
)
3639

3740
# PIO interface. This is only available on Raspberry Pi RP2 processors,
3841
# but is much faster than the SPI interface (75Mbps on RP2350).
3942
# interface = rv.displays.SPI_RP2_PIO(
4043
# sm_id = 4,
41-
# pin_clk = 22,
42-
# pin_tx = 23,
43-
# pin_dc = 20,
44-
# pin_cs = 21,
44+
# pin_clk = Pin.board.DISPLAY_CLK,
45+
# pin_tx = Pin.board.DISPLAY_TX,
46+
# pin_dc = Pin.board.DISPLAY_DC,
47+
# pin_cs = Pin.board.DISPLAY_CS,
4548
# )
4649

4750
##########

red_vision_examples/rv_init/sd_card.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# specific board and configuration.
1212
#-------------------------------------------------------------------------------
1313

14-
# Import the Pin class for the chip select pin
14+
# Import the Pin class for the board's default pins.
1515
from machine import Pin
1616

1717
# Import the SPI bus
@@ -25,8 +25,8 @@
2525
spi_str = str(spi)
2626
baudrate = int(spi_str[spi_str.index("baudrate=") + 9:].partition(",")[0])
2727

28-
# Set the chip select pin for the SD card
29-
sd_cs = Pin(7, Pin.OUT)
28+
# Set the chip select pin for the SD card.
29+
sd_cs = Pin(Pin.board.SD_CS, Pin.OUT)
3030

3131
try:
3232
# Import the SD card module. This is often not installed by default in

0 commit comments

Comments
 (0)