mirror of
https://github.com/hybridgroup/gobot.git
synced 2025-04-29 13:49:14 +08:00
sysfs: small reordering to file
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
parent
84dfbc9f89
commit
79288f837b
@ -7,11 +7,11 @@ import (
|
|||||||
|
|
||||||
// PWMPin is the interface for sysfs PWM interactions
|
// PWMPin is the interface for sysfs PWM interactions
|
||||||
type PWMPin interface {
|
type PWMPin interface {
|
||||||
// Unexport unexports the pin and releases the pin from the operating system
|
|
||||||
Unexport() error
|
|
||||||
// Export exports the pin for use by the operating system
|
// Export exports the pin for use by the operating system
|
||||||
Export() error
|
Export() error
|
||||||
// Enable enables the PWM pin
|
// Unexport unexports the pin and releases the pin from the operating system
|
||||||
|
Unexport() error
|
||||||
|
// Enable enables/disables the PWM pin
|
||||||
Enable(val string) (err error)
|
Enable(val string) (err error)
|
||||||
// Period returns the current PWM period for pin
|
// Period returns the current PWM period for pin
|
||||||
Period() (period string, err error)
|
Period() (period string, err error)
|
||||||
@ -33,6 +33,18 @@ func NewPwmPin(pin int) *pwmPin {
|
|||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Export writes pin to pwm export path
|
||||||
|
func (p *pwmPin) Export() (err error) {
|
||||||
|
_, err = p.write(pwmExportPath(), []byte(p.pin))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unexport writes pin to pwm unexport path
|
||||||
|
func (p *pwmPin) Unexport() (err error) {
|
||||||
|
_, err = p.write(pwmUnexportPath(), []byte(p.pin))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Enable writes value to pwm enable path
|
// Enable writes value to pwm enable path
|
||||||
func (p *pwmPin) Enable(val string) (err error) {
|
func (p *pwmPin) Enable(val string) (err error) {
|
||||||
_, err = p.write(pwmEnablePath(p.pin), []byte(val))
|
_, err = p.write(pwmEnablePath(p.pin), []byte(val))
|
||||||
@ -54,18 +66,6 @@ func (p *pwmPin) WriteDuty(duty string) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Export writes pin to pwm export path
|
|
||||||
func (p *pwmPin) Export() (err error) {
|
|
||||||
_, err = p.write(pwmExportPath(), []byte(p.pin))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unexport writes pin to pwm unexport path
|
|
||||||
func (p *pwmPin) Unexport() (err error) {
|
|
||||||
_, err = p.write(pwmUnexportPath(), []byte(p.pin))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// pwmPath returns pwm base path
|
// pwmPath returns pwm base path
|
||||||
func pwmPath() string {
|
func pwmPath() string {
|
||||||
return "/sys/class/pwm/pwmchip0"
|
return "/sys/class/pwm/pwmchip0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user