|
@@ -202,8 +202,11 @@ static void getADCValues(void) {
|
|
|
|
|
|
avgVal = ADC_GetValues();
|
|
|
|
|
|
- slowBuf.Voltage[slowBuf.idx] = *avgVal;
|
|
|
- slowBuf.Current[slowBuf.idx] = *(avgVal + 1);
|
|
|
+ Voltage = *avgVal;
|
|
|
+ Current = *(avgVal + 1);
|
|
|
+
|
|
|
+ slowBuf.Voltage[slowBuf.idx] = Voltage;
|
|
|
+ slowBuf.Current[slowBuf.idx] = Current;
|
|
|
|
|
|
slowBuf.idx ++;
|
|
|
if (slowBuf.idx >= VALUES_BUFFER_SIZE) {
|
|
@@ -225,12 +228,13 @@ static void calculateValues(void) {
|
|
|
c += slowBuf.Current[i];
|
|
|
}
|
|
|
|
|
|
- Current = (c + (VALUES_BUFFER_SIZE/2)) / VALUES_BUFFER_SIZE;
|
|
|
- Voltage = (v + (VALUES_BUFFER_SIZE/2)) / VALUES_BUFFER_SIZE;
|
|
|
+ v = (v + (VALUES_BUFFER_SIZE/2)) / VALUES_BUFFER_SIZE;
|
|
|
+ c = (c + (VALUES_BUFFER_SIZE/2)) / VALUES_BUFFER_SIZE;
|
|
|
|
|
|
if (Current > 0) {
|
|
|
|
|
|
- Power = ((Voltage * Current) + 500) / 1000;
|
|
|
+ // millivolt * milliamper = microwatt, convert to milliwatt
|
|
|
+ Power = ((v * c) + 500) / 1000;
|
|
|
|
|
|
CapacityAH += Current;
|
|
|
CapacityWH += Power;
|
|
@@ -240,6 +244,7 @@ static void calculateValues(void) {
|
|
|
Timer.ss = 0;
|
|
|
Timer.mm ++;
|
|
|
if (Timer.mm > 59) {
|
|
|
+ Timer.mm = 0;
|
|
|
Timer.hh ++;
|
|
|
}
|
|
|
}
|
|
@@ -412,7 +417,8 @@ void blankLine(uint8_t pos) {
|
|
|
* any other for bottom.
|
|
|
*/
|
|
|
static void showU(uint8_t pos) {
|
|
|
- showValue(slowBuf.Voltage[slowBuf.idx], pos);
|
|
|
+ //showValue(slowBuf.Voltage[slowBuf.idx], pos);
|
|
|
+ showValue(Voltage, pos);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -421,7 +427,8 @@ static void showU(uint8_t pos) {
|
|
|
* any other for bottom.
|
|
|
*/
|
|
|
static void showI(uint8_t pos) {
|
|
|
- showValue(slowBuf.Current[slowBuf.idx], pos);
|
|
|
+ //showValue(slowBuf.Current[slowBuf.idx], pos);
|
|
|
+ showValue(Current, pos);
|
|
|
}
|
|
|
|
|
|
/**
|