cli/charger: support mA currents (#15341)
This commit is contained in:
parent
260c13e6d4
commit
061beab082
1 changed files with 10 additions and 4 deletions
|
|
@ -19,7 +19,7 @@ var chargerCmd = &cobra.Command{
|
|||
|
||||
func init() {
|
||||
rootCmd.AddCommand(chargerCmd)
|
||||
chargerCmd.Flags().IntP(flagCurrent, "i", 0, flagCurrentDescription)
|
||||
chargerCmd.Flags().Float64P(flagCurrent, "i", 0, flagCurrentDescription)
|
||||
//lint:ignore SA1019 as Title is safe on ascii
|
||||
chargerCmd.Flags().BoolP(flagEnable, "e", false, strings.Title(flagEnable))
|
||||
//lint:ignore SA1019 as Title is safe on ascii
|
||||
|
|
@ -60,13 +60,19 @@ func runCharger(cmd *cobra.Command, args []string) {
|
|||
if flag := cmd.Flags().Lookup(flagCurrent); flag.Changed {
|
||||
flagUsed = true
|
||||
|
||||
current, err := strconv.ParseInt(flag.Value.String(), 10, 64)
|
||||
current, err := strconv.ParseFloat(flag.Value.String(), 64)
|
||||
if err != nil {
|
||||
log.ERROR.Fatalln(err)
|
||||
}
|
||||
|
||||
if err := v.MaxCurrent(current); err != nil {
|
||||
log.ERROR.Println("set current:", err)
|
||||
if vv, ok := v.(api.ChargerEx); ok {
|
||||
if err := vv.MaxCurrentMillis(current); err != nil {
|
||||
log.ERROR.Println("set current:", err)
|
||||
}
|
||||
} else {
|
||||
if err := v.MaxCurrent(int64(current)); err != nil {
|
||||
log.ERROR.Println("set current:", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue