Skip to content

Commit c530b08

Browse files
authored
Merge pull request #3437 from TD-er/bugfix/Dallas_optional_pin_unset
[Dallas] Fix Dallas sensor not being read if optional pin unset
2 parents 92b71fd + 91853fd commit c530b08

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/_P004_Dallas.ino

+8-2
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,15 @@ boolean Plugin_004(byte function, struct EventStruct *event, String& string)
229229
uint8_t addr[8];
230230
Dallas_plugin_get_addr(addr, event->TaskIndex);
231231

232-
if ((addr[0] != 0) && (CONFIG_PIN1 != -1) && (CONFIG_PIN2 != -1)) {
232+
int8_t Plugin_004_DallasPin_RX = CONFIG_PIN1;
233+
int8_t Plugin_004_DallasPin_TX = CONFIG_PIN2;
234+
if(Plugin_004_DallasPin_TX == -1) {
235+
Plugin_004_DallasPin_TX = Plugin_004_DallasPin_RX;
236+
}
237+
238+
if ((addr[0] != 0) && (Plugin_004_DallasPin_RX != -1) && (Plugin_004_DallasPin_TX != -1)) {
233239
const uint8_t res = P004_RESOLUTION;
234-
initPluginTaskData(event->TaskIndex, new (std::nothrow) P004_data_struct(CONFIG_PIN1, CONFIG_PIN2, addr, res));
240+
initPluginTaskData(event->TaskIndex, new (std::nothrow) P004_data_struct(Plugin_004_DallasPin_RX, Plugin_004_DallasPin_TX, addr, res));
235241
P004_data_struct *P004_data =
236242
static_cast<P004_data_struct *>(getPluginTaskData(event->TaskIndex));
237243

0 commit comments

Comments
 (0)