c_cpp 不使用LiPo时禁用电子红色充电LED

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp 不使用LiPo时禁用电子红色充电LED相关的知识,希望对你有一定的参考价值。

void setCharging(bool enable) {

	PMIC pmic;

	// DisableCharging turns of charging. DisableBATFET completely disconnects the battery.
	if (enable) {
		pmic.enableCharging();
		pmic.enableBATFET();
	}
	else {
		pmic.disableCharging();
		pmic.disableBATFET();
	}

	// Disabling the watchdog is necessary, otherwise it will kick in and turn
	// charing at random times, even when sleeping.

	// This disables both the watchdog and the charge safety timer in
	// Charge Termination/Timer Control Register REG05
	// pmic.disableWatchdog() disables the watchdog, but doesn't disable the
	// charge safety timer, so the red LED will start blinking slowly after
	// 1 hour if you don't do both.
	byte DATA = pmic.readChargeTermRegister();

	if (enable) {
		DATA |= 0b00111000;
	}
	else {
		// 0b11001110 = disable watchdog
		// 0b11000110 = disable watchdog and charge safety timer
		DATA &= 0b11000110;
	}

	// This would be easier if pmic.writeRegister wasn't private (or disable
	// charge safety timer had an exposed method
	Wire3.beginTransmission(PMIC_ADDRESS);
	Wire3.write(CHARGE_TIMER_CONTROL_REGISTER);
	Wire3.write(DATA);
	Wire3.endTransmission(true);

}

以上是关于c_cpp 不使用LiPo时禁用电子红色充电LED的主要内容,如果未能解决你的问题,请参考以下文章

Android在充电时禁用显示

一款充电宝和LED灯内部电路设计

关闭树莓派的 LED

使用Arduino和LED光柱显示器件轻松制作电池电压指示器

Banana Pi无法启动(红色LED亮)

c_cpp 运动激活LED灯条