/*
 * Charger.cpp
 *
 *  Created on: 19.11.2018
 *      Author: Hendrik Schutter
 */

#include "openChargeMicro.h"

charger::charger(const struct s_charger pCharger) {
	charger_settings = pCharger;
	active = false;
}

charger::~charger() {
}

/* returns current charge-current in mA */
double charger::getCurrent() {
	mux.setChannel(charger_settings.chI);
	int tmp = (int) io.readAdc(0);
	double ret = ((double) tmp) * 1.00; //TODO calibration and testing
	return ret;
}

/* returns current battery voltage in V */
double charger::getVoltage() {
	mux.setChannel(charger_settings.chU);
	int tmp = (int) io.readAdc(0);
	double ret = ((double) tmp) * 1.00; //TODO calibration and testing
	return ret;
}

/* returns summed up charged capacity since charge start in mAh */
double charger::getCapacity() {
	//TODO
	return 1.1;
}


void charger::getInfo() {
	char buffer[50];
	sprintf(buffer, "Nr: %i - Uch %i - Ich %i\r\n", charger_settings.nr,
			charger_settings.chU, charger_settings.chI);
	serialSend(buffer);
}
void charger::setStatus(bool pBool) {
	active = pBool;
}
bool charger::getStatus() {
	return active;
}

