示例#1
0
文件: servo.go 项目: bgentry/embd
// 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))
}
示例#2
0
文件: pwmpin.go 项目: bgentry/embd
func (p *pwmPin) SetAnalog(value byte) error {
	duty := util.Map(int64(value), 0, 255, 0, int64(p.period))
	return p.SetDuty(int(duty))
}