util

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package util implements helpers to handle kernel battery data

Index

Constants

View Source
const BatteryPath = "/sys/class/power_supply/BAT0/"

Variables

This section is empty.

Functions

func ByteStringToInt

func ByteStringToInt(d []byte) int

func ByteStringToString

func ByteStringToString(d []byte) string

func CalculateDischarge

func CalculateDischarge(current, old int) int

func CalculateDischargeRatePerHour

func CalculateDischargeRatePerHour(d int, h time.Duration) float32

func Capacity

func Capacity() int

func Check

func Check(e error)

func CheckBattery

func CheckBattery()

func CycleCount

func CycleCount() int

func DischargeStats

func DischargeStats(timestamp time.Time, currentTimestamp time.Time, charge int) (d int, dt time.Duration, dr float32)

func EnergyFull

func EnergyFull() float32

func EnergyFullDesign

func EnergyFullDesign() float32

func EnergyNow

func EnergyNow() float32

func InputByteArrayToInt

func InputByteArrayToInt(s string) int

func Manufacturer

func Manufacturer() string

func MilliWattsToWatts

func MilliWattsToWatts(m int) float32

func ParameterPath

func ParameterPath(p string) string

func ParseTime

func ParseTime(timestamp time.Time) string

func PowerNow

func PowerNow() float32

func Status

func Status() string

Types

type BatteryPeriod

type BatteryPeriod struct {
	Timestamp        time.Time
	CurrentTimestamp time.Time
	Discharge        int
	DischargeTime    time.Duration
	DischargeRatio   float32
}

func NewPeriod

func NewPeriod(timestamp time.Time, currentTimestamp time.Time, charge int) BatteryPeriod

func (BatteryPeriod) Print

func (p BatteryPeriod) Print()

type BatteryStats

type BatteryStats struct {
	Manufacturer     string
	EnergyFullDesign float32
	EnergyFull       float32
	EnergyNow        float32
	Capacity         int
	Cycles           int
	PowerNow         float32
	Status           string
}

func Stats

func Stats() BatteryStats

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL