Esempio n. 1
0
static void show_charging_progress(void)
{
	int rv, minutes, to_full;

	if (!curr.batt_is_charging) {
		rv = battery_time_to_empty(&minutes);
		to_full = 0;
	} else {
		rv = battery_time_to_full(&minutes);
		to_full = 1;
	}

	if (rv)
		CPRINTS("Battery %d%% / ??h:?? %s%s",
			curr.batt.state_of_charge,
			to_full ? "to full" : "to empty",
			is_full ? ", not accepting current" : "");
	else
		CPRINTS("Battery %d%% / %dh:%d %s%s",
			curr.batt.state_of_charge,
			minutes / 60, minutes % 60,
			to_full ? "to full" : "to empty",
			is_full ? ", not accepting current" : "");

	if (debugging) {
		ccprintf("battery:\n");
		print_battery_debug();
		ccprintf("charger:\n");
		print_charger_debug();
		ccprintf("chg:\n");
		dump_charge_state();
	}
}
Esempio n. 2
0
/**
 * Print charging progress
 */
static void charging_progress(struct charge_state_context *ctx)
{
	int seconds, minutes;

	if (ctx->curr.batt.state_of_charge != ctx->prev.batt.state_of_charge) {
		if (ctx->curr.ac)
			battery_time_to_full(&minutes);
		else
			battery_time_to_empty(&minutes);

		CPRINTS("Battery %3d%% / %dh:%d",
			ctx->curr.batt.state_of_charge,
			minutes / 60, minutes % 60);
		return;
	}

	if (ctx->curr.charging_voltage != ctx->prev.charging_voltage &&
	    ctx->trickle_charging_time.val) {
		/* Calculate minutes by dividing usec by 60 million.  GNU
		 * toolchain generates architecture dependent calls instead of
		 * machine code when the divisor is large, so break the
		 * calculation into 2 lines.
		 */
		seconds = (int)(get_time().val -
				ctx->trickle_charging_time.val) / (int)SECOND;
		minutes = seconds / 60;
		CPRINTS("Precharge CHG(%dmV) BATT(%dmV %dmA) "
			"%dh:%d", ctx->curr.charging_voltage,
			ctx->curr.batt.voltage, ctx->curr.batt.current,
			minutes / 60, minutes % 60);
	}
}