Open adrianbn opened 3 years ago
It's not a good idea to use machine.UART1 in dht/thermometer.go. It is better to pass it from dht.New(), for example, so that it does not depend on a specific UART.
Not sure I follow. Do you mean pass the UART from the device into dht.New()
and then trickle it down to receiveSignals
? Even then, it doesn't seem like the arduino UART in the machine package supports Interrupt()
, right?
To the boards without UART, it causes a problem to build. This is issue.
The correct fix would be to use the runtime/interrupt
package:
mask := interrupt.Disable()
// do something with interrupts disabled
interrupt.Restore(mask)
That seems reasonable for the DHTXX driver as it depends on precise timings.
When trying to build the example for the dht driver (https://github.com/tinygo-org/drivers/blob/release/examples/dht/main.go) on Windows I get the following error:
Taking a quick look at the code for the driver, it tries to access UART1 https://github.com/tinygo-org/drivers/blob/release/dht/thermometer.go#L160, which according to the
machine
package for arduino is not defined (https://tinygo.org/microcontrollers/machine/arduino/).I tried the dirty hack of using UART or UART0 as defined in the machine package for arduino, but they don't have a method
Interrupt
as used by the driver.Cheers!