Warp2: refactor ChargerEx implementation
This commit is contained in:
parent
bc4c24f0a9
commit
8b4bc840e7
1 changed files with 7 additions and 11 deletions
|
|
@ -198,25 +198,21 @@ func (wb *Warp2) Status() (api.ChargeStatus, error) {
|
|||
return res, err
|
||||
}
|
||||
|
||||
// setCurrentMA sets the current in mA
|
||||
func (wb *Warp2) setCurrentMA(current int64) error {
|
||||
err := wb.maxcurrentS(current)
|
||||
if err == nil {
|
||||
wb.current = current
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// MaxCurrent implements the api.Charger interface
|
||||
func (wb *Warp2) MaxCurrent(current int64) error {
|
||||
return wb.setCurrentMA(1000 * current)
|
||||
return wb.MaxCurrentMillis(float64(current))
|
||||
}
|
||||
|
||||
var _ api.ChargerEx = (*Warp2)(nil)
|
||||
|
||||
// MaxCurrentMillis implements the api.ChargerEx interface
|
||||
func (wb *Warp2) MaxCurrentMillis(current float64) error {
|
||||
return wb.setCurrentMA(int64(1000 * current))
|
||||
curr := int64(current * 1e3)
|
||||
err := wb.maxcurrentS(curr)
|
||||
if err == nil {
|
||||
wb.current = curr
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// CurrentPower implements the api.Meter interface
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue