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
Issue status: Mostly a note-to-self; if you like the proposed resolution I can put it into a PR at some later point.
The way the active-low and active-high semantics are packed into the blinq constructor is convenient for typical cases, but falls short when a board already provides the active-high/active-low abstraction through switch-hal. (In particular, for RIOT I currently provide fake pins with fake active-high logic, but I'd rather deprecate that in favor of exposing things at the right semantic level).
Concrete suggestion for blinq:
Add switch_hal as a dependency
Implement blinq in terms of switches, moving the constructor to build a switch from the arguments.
This is a bit harder than it seems, because in a switch the level logic is in type state whereas here it's in runtime state. (This could need an own implementation of OutputSwitch that uses runtime polarity, but that's just a few lines).
This would be a breaking change as Blinq's G type changes (from pin to switch) -- one of these "yes it's a breaking release, but unless you fixed that type somewhere you're good to upgrade" changes.
Provide a new_from_switch constructor that takes an OutputSwitch (with its on/off semantics), rather than an OutputPin (with its high-low semantics) and a boolean
Alternative: HALs keep providing switches with extra GPIO versions, "It's not really a GPIO, but if some API needs it, use it as OutputPin where it simulates active-high logic". (Which may well be viable).
The text was updated successfully, but these errors were encountered:
400: Add switch-hal r=eldruin a=chrysn
The switch-hal crate just extends embedded-hal by a bit (hah!) -- but I find it very useful, for it provides clean "on"/"off" semantics for what is otherwise merely "high"/"low", and thus dependent on the actual wiring (both LEDs and buttons are just as easy to wire either way).
It's not used a lot ([crates assume active-low](jamesmunns/blinq#4) instead), but I hope that this changes once it is more visible through here.
Co-authored-by: chrysn <chrysn@fsfe.org>
Issue status: Mostly a note-to-self; if you like the proposed resolution I can put it into a PR at some later point.
The way the active-low and active-high semantics are packed into the blinq constructor is convenient for typical cases, but falls short when a board already provides the active-high/active-low abstraction through switch-hal. (In particular, for RIOT I currently provide fake pins with fake active-high logic, but I'd rather deprecate that in favor of exposing things at the right semantic level).
Concrete suggestion for blinq:
new_from_switch
constructor that takes an OutputSwitch (with its on/off semantics), rather than an OutputPin (with its high-low semantics) and a booleanAlternative: HALs keep providing switches with extra GPIO versions, "It's not really a GPIO, but if some API needs it, use it as OutputPin where it simulates active-high logic". (Which may well be viable).
The text was updated successfully, but these errors were encountered: