niobe/base/powermgr/battery_lite
houpengfei bf36baa0e3 update OpenHarmony 3.0 LTS 2021-10-22 13:59:18 +08:00
..
figures update OpenHarmony 3.0 LTS 2021-10-22 13:59:18 +08:00
frameworks update OpenHarmony 3.0 LTS 2021-10-22 13:59:18 +08:00
interfaces/kits update OpenHarmony 3.0 LTS 2021-10-22 13:59:18 +08:00
services update OpenHarmony 3.0 LTS 2021-10-22 13:59:18 +08:00
BUILD.gn update OpenHarmony 3.0 LTS 2021-10-22 13:59:18 +08:00
LICENSE update OpenHarmony 3.0 LTS 2021-10-22 13:59:18 +08:00
OAT.xml update OpenHarmony 3.0 LTS 2021-10-22 13:59:18 +08:00
README.md update OpenHarmony 3.0 LTS 2021-10-22 13:59:18 +08:00
README_zh.md update OpenHarmony 3.0 LTS 2021-10-22 13:59:18 +08:00
batterymgr.gni update OpenHarmony 3.0 LTS 2021-10-22 13:59:18 +08:00
config.gni update OpenHarmony 3.0 LTS 2021-10-22 13:59:18 +08:00

README.md

Lite Battery Manager

Introduction

The lite battery manager provides the following functionalities:

  1. Obtaining battery information
  2. Obtaining the battery charging status and the battery state of charge SoC
  3. Monitoring the battery state of health SoH
  4. Controlling the battery charging indicator

Figure 1 Lite battery manager architecture

Directory Structure

base/powermgr/battery_lite
├── frameworks        # Frameworks
│   ├── include       # Header files
│   └── src           # Source files
├── interfaces        # APIs
│   ├── innerkits     # Internal APIs
│   └── kits          # External APIs
├── services          # Services
│   ├── include       # Header files
│   └── src           # Source files

Usage

Available APIs

The following table lists the JavaScript APIs provided by the lite battery manager.

API

Description

int32_t GetBatSoc()

Obtains the battery SoC.

BatteryChargeState GetChargingStatus()

Obtains the current battery charging status.

BatteryHealthState GetHealthStatus()

Obtains the battery SoH.

BatteryPluggedType GetPluggedType()

Obtains the charger type.

int32_t GetBatVoltage()

Obtains the battery voltage.

bool IsBatPresent()

Checks whether the battery is present.

char* GetBatTechnology()

Obtains the battery model.

int32_t GetBatTemperature()

Obtains the battery temperature.

Usage Guidelines

The lite battery manager provides APIs for obtaining the battery SoC, battery charging status, and battery SoH.

The sample code is as follows:

int32_t capacity = GetBatSoc();
BatteryChargeState chargState = GetChargingStatus();

Repositories Involved

Power management subsystem

powermgr_powermgr_lite