implemented capacity
This commit is contained in:
parent
bc5f43a2e5
commit
a7f8d563bd
|
@ -20,7 +20,7 @@ charger::~charger() {
|
|||
int charger::getCurrent() {
|
||||
mux.setChannel(charger_settings.chI);
|
||||
int tmp = (int) io.readAdc(0);
|
||||
int ret = (int) (tmp * 1.0); //TODO calibration and testing
|
||||
int ret = (int) ((tmp * 1.4286) + 34.857); //TODO calibration and testing
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ double charger::getVoltage() {
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* returns summed up charged capacity since charge start in mAh */
|
||||
/* returns summed up charged capacity since charge start in µAh */
|
||||
unsigned int charger::getCapacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
@ -59,20 +59,14 @@ bool charger::getStatus() {
|
|||
|
||||
/* resets the capacity */
|
||||
void charger::reset() {
|
||||
|
||||
capacity = 0;
|
||||
}
|
||||
|
||||
/* updates the capacity */
|
||||
void charger::update() {
|
||||
// 1sec / 3600
|
||||
const double div = 0.000277778;
|
||||
capacity = capacity + ((unsigned int) (div * getCurrent()));
|
||||
capacity = capacity + ((unsigned long int) (div * getCurrent() * 1000));
|
||||
//serialSend("update\r\n");
|
||||
/*
|
||||
char charVal[10];
|
||||
dtostrf(getCurrent(), 4, 0, charVal);
|
||||
serialSend(charVal);
|
||||
serialSend(" mA\r\n");
|
||||
*/
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ private:
|
|||
ioController io;
|
||||
multiplexer mux;
|
||||
struct time_t startTime;
|
||||
unsigned int capacity;
|
||||
unsigned long int capacity; //in µAh
|
||||
bool active;
|
||||
|
||||
public:
|
||||
|
|
|
@ -132,9 +132,13 @@ void printStatus() {
|
|||
if (chargers[i].getStatus()) {
|
||||
//chargers[i].getInfo(); //print values
|
||||
char charVal[10];
|
||||
dtostrf(chargers[i].getCurrent(), 4, 0, charVal);
|
||||
|
||||
//dtostrf(chargers[i].getCurrent(), 4, 0, charVal);
|
||||
|
||||
sprintf(charVal, "%i µAh\r\n", chargers[i].getCapacity());
|
||||
|
||||
serialSend(charVal);
|
||||
serialSend(" mA\r\n");
|
||||
//serialSend(" mA\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue