mirror of
https://github.com/kidoman/embd
synced 2025-07-03 03:47:33 +02:00
unified servo and analog output support for pwms
This commit is contained in:
parent
9ab49745bc
commit
fc887282bf
9 changed files with 181 additions and 40 deletions
|
@ -33,8 +33,22 @@ func (d *ServoBlaster) setup() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
type pwmChannel struct {
|
||||
d *ServoBlaster
|
||||
|
||||
channel int
|
||||
}
|
||||
|
||||
func (p *pwmChannel) SetMicroseconds(us int) error {
|
||||
return p.d.setMicroseconds(p.channel, us)
|
||||
}
|
||||
|
||||
func (d *ServoBlaster) Channel(channel int) *pwmChannel {
|
||||
return &pwmChannel{d: d, channel: channel}
|
||||
}
|
||||
|
||||
// SetMicroseconds sends a command to the PWM driver to generate a us wide pulse.
|
||||
func (d *ServoBlaster) SetMicroseconds(channel, us int) error {
|
||||
func (d *ServoBlaster) setMicroseconds(channel, us int) error {
|
||||
if err := d.setup(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue