You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The topic of discussion centers around what type should a New driver constructor receive for pin HAL.
Two main candidates are:
An interface type
A function type
// function typetypePinOutputfunc(levelbool)
// interface typetypePinOutputinterface {
Set(levelbool)
}
// driver constructor. TinyGo user facing API.funcNewDriver(csPin drivers.PinOutput) *Driver {
return&Driver{cs: csPin}
}
// When using with interface typed:=NewDriver(machine.GPIO1)
// When using with function typed:=NewDriver(machine.GPIO1.Set)
Main data points:
Interface types are more familiar to Go developers than function types
Interface types can be at least 25 times slower than function types on some microcontrollers. See Add PinInput and PinOutput HAL drivers#753 (comment). Slowdown depends on number of interface implementations compiled.
Other arguments:
Functions are easier to define than interfaces
Functions are conceptually simpler than interface types
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is meant to be a long running discussion. I've created it to link in an upcoming PR so future users can find it.
As a result of the following listed PRs I've chosen to create a discussion to focus a dialogue in a single place.
The topic of discussion centers around what type should a
New
driver constructor receive for pin HAL.Two main candidates are:
Main data points:
Other arguments:
Beta Was this translation helpful? Give feedback.
All reactions