Skip to content

Commit

Permalink
max 7
Browse files Browse the repository at this point in the history
  • Loading branch information
brentru committed Mar 6, 2025
1 parent b05e6a4 commit 3a9214c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/components/ds18x20/hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,19 @@ bool DS18X20Hardware::GetSensor() {
// RP2040 is special - it uses the PIO's rather than the standard bitbang
// implementation In this implementation, we select the PIO instance based on
// driver identifier

// NOTE: We are only going to allow *up to* 7 DS18x20 sensors on RP2040
// because the status pixel requires a PIO SM to be allocated prior.
int pio_num;
if (_sensor_num < 4) {
// drivers 0 thru 4 are handled by PIO0/SM0..4
if (_sensor_num <= 4) {
// drivers 0 thru 3 are handled by PIO0/SM0..4
new (&_ow) OneWireNg_CurrentPlatform(_onewire_pin, false, 0);
} else if (_sensor_num >= 5) {
} else if (_sensor_num <= 7) {
// drivers 5 thru 8 are handled by PIO1/SM1..4
new (&_ow) OneWireNg_CurrentPlatform(_onewire_pin, false, 1);
} else {
WS_DEBUG_PRINTLN(
"[ds18x20] ERROR: You may only add up to 8 sensors on RP2040!");
"[ds18x20] ERROR: You may only add up to 7 sensors on RP2040!");
return false;
}
#else
Expand Down

0 comments on commit 3a9214c

Please sign in to comment.