Skip to content

Commit

Permalink
Work around spurious 0-length signals in idf5 (#9)
Browse files Browse the repository at this point in the history
* Work around spurious 0-length signals in idf5

* Update src/driver_.toit

Co-authored-by: Kasper Lund <[email protected]>

---------

Co-authored-by: Kasper Lund <[email protected]>
  • Loading branch information
floitsch and kasperl authored Sep 12, 2023
1 parent 007ac2a commit bf69ad9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/dht11.toit
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import dhtxx
import gpio

GPIO_PIN_NUM ::= 14
GPIO_PIN_NUM ::= 14

main:
pin := gpio.Pin GPIO_PIN_NUM
Expand Down
2 changes: 1 addition & 1 deletion examples/dht22.toit
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import dhtxx
import gpio

GPIO_PIN_NUM ::= 14
GPIO_PIN_NUM ::= 14

main:
pin := gpio.Pin GPIO_PIN_NUM
Expand Down
4 changes: 4 additions & 0 deletions src/driver_.toit
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ abstract class Driver:
channel_in_.start_reading
channel_out_.write start_signal
response := channel_in_.read
if response.size == 2 and (response.period 0) == 0 and (response.period 1) == 0:
// We are getting some spurious signals from the start signal,
// which we just ignore.
response = channel_in_.read
channel_in_.stop_reading

// We expect to see:
Expand Down

0 comments on commit bf69ad9

Please sign in to comment.