mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 12:25:20 +03:00
Add current sensor debug option. (#5260)
Allows for easy calculation of required scale and offset. 0 - miliVolts 1 - centiAmps 2 - amperageLatest 3 - mahDrawn
This commit is contained in:
parent
88dcaa95ef
commit
742cb5f93b
3 changed files with 9 additions and 0 deletions
|
@ -61,4 +61,5 @@ const char * const debugModeNames[DEBUG_COUNT] = {
|
||||||
"LIDAR_TF",
|
"LIDAR_TF",
|
||||||
"CORE_TEMP",
|
"CORE_TEMP",
|
||||||
"RUNAWAY_TAKEOFF",
|
"RUNAWAY_TAKEOFF",
|
||||||
|
"CURRENT_SENSOR",
|
||||||
};
|
};
|
||||||
|
|
|
@ -79,6 +79,7 @@ typedef enum {
|
||||||
DEBUG_LIDAR_TF,
|
DEBUG_LIDAR_TF,
|
||||||
DEBUG_CORE_TEMP,
|
DEBUG_CORE_TEMP,
|
||||||
DEBUG_RUNAWAY_TAKEOFF,
|
DEBUG_RUNAWAY_TAKEOFF,
|
||||||
|
DEBUG_CURRENT,
|
||||||
DEBUG_COUNT
|
DEBUG_COUNT
|
||||||
} debugType_e;
|
} debugType_e;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
|
#include "build/debug.h"
|
||||||
|
|
||||||
#include "common/maths.h"
|
#include "common/maths.h"
|
||||||
#include "common/utils.h"
|
#include "common/utils.h"
|
||||||
|
@ -113,6 +114,9 @@ static int32_t currentMeterADCToCentiamps(const uint16_t src)
|
||||||
// y=x/m+b m is scale in (mV/10A) and b is offset in (mA)
|
// y=x/m+b m is scale in (mV/10A) and b is offset in (mA)
|
||||||
int32_t centiAmps = (millivolts * 10000 / (int32_t)config->scale + (int32_t)config->offset) / 10;
|
int32_t centiAmps = (millivolts * 10000 / (int32_t)config->scale + (int32_t)config->offset) / 10;
|
||||||
|
|
||||||
|
DEBUG_SET(DEBUG_CURRENT, 0, millivolts);
|
||||||
|
DEBUG_SET(DEBUG_CURRENT, 1, centiAmps);
|
||||||
|
|
||||||
return centiAmps; // Returns Centiamps to maintain compatability with the rest of the code
|
return centiAmps; // Returns Centiamps to maintain compatability with the rest of the code
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,6 +162,9 @@ void currentMeterADCRead(currentMeter_t *meter)
|
||||||
meter->amperageLatest = currentMeterADCState.amperageLatest;
|
meter->amperageLatest = currentMeterADCState.amperageLatest;
|
||||||
meter->amperage = currentMeterADCState.amperage;
|
meter->amperage = currentMeterADCState.amperage;
|
||||||
meter->mAhDrawn = currentMeterADCState.mahDrawnState.mAhDrawn;
|
meter->mAhDrawn = currentMeterADCState.mahDrawnState.mAhDrawn;
|
||||||
|
|
||||||
|
DEBUG_SET(DEBUG_CURRENT, 2, meter->amperageLatest);
|
||||||
|
DEBUG_SET(DEBUG_CURRENT, 3, meter->mAhDrawn);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue