Skip to content

Commit

Permalink
Warp2: refactor ChargerEx implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Aug 13, 2023
1 parent bc4c24f commit 8b4bc84
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions charger/warp2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8b4bc84

Please sign in to comment.