Exemple #1
0
// SetAngle sets the servo angle.
func (s *Servo) SetAngle(angle int) error {
	us := util.Map(int64(angle), 0, 180, int64(s.Minus), int64(s.Maxus))

	glog.V(1).Infof("servo: given angle %v calculated %v us", angle, us)

	return s.PWM.SetMicroseconds(int(us))
}
Exemple #2
0
func (p *pwmPin) SetAnalog(value byte) error {
	duty := util.Map(int64(value), 0, 255, 0, int64(p.period))
	return p.SetDuty(int(duty))
}