sysfs: small reordering to file

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram 2017-04-21 12:55:00 +02:00
parent 84dfbc9f89
commit 79288f837b
1 changed files with 15 additions and 15 deletions

View File

@ -7,11 +7,11 @@ import (
// PWMPin is the interface for sysfs PWM interactions
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() 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)
// Period returns the current PWM period for pin
Period() (period string, err error)
@ -33,6 +33,18 @@ func NewPwmPin(pin int) *pwmPin {
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
func (p *pwmPin) Enable(val string) (err error) {
_, err = p.write(pwmEnablePath(p.pin), []byte(val))
@ -54,18 +66,6 @@ func (p *pwmPin) WriteDuty(duty string) (err error) {
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
func pwmPath() string {
return "/sys/class/pwm/pwmchip0"