From aac42199f6857f04a61314850aa7ccef0429f058 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Mon, 18 Jul 2022 22:54:56 +1000 Subject: [PATCH] getTipResistanceX10() --- source/Core/BSP/BSP_Power.h | 3 +++ source/Core/BSP/MHP30/Power.cpp | 2 ++ source/Core/BSP/Miniware/BSP.cpp | 2 ++ source/Core/BSP/Pine64/BSP.cpp | 2 ++ source/Core/Src/power.cpp | 2 +- 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/source/Core/BSP/BSP_Power.h b/source/Core/BSP/BSP_Power.h index a924a1ec..386ffc74 100644 --- a/source/Core/BSP/BSP_Power.h +++ b/source/Core/BSP/BSP_Power.h @@ -16,6 +16,9 @@ extern "C" { // Can be used to check any details for the power system void power_check(); +// Return the tip resistance in x10 ohms (8.5 -> 85) +uint8_t getTipResistanceX10(); + #ifdef __cplusplus } #endif diff --git a/source/Core/BSP/MHP30/Power.cpp b/source/Core/BSP/MHP30/Power.cpp index 661a4bb4..5b508ada 100644 --- a/source/Core/BSP/MHP30/Power.cpp +++ b/source/Core/BSP/MHP30/Power.cpp @@ -17,3 +17,5 @@ void power_check() { } bool getIsPoweredByDCIN() { return false; } + +uint8_t getTipResistanceX10() { return TIP_RESISTANCE; } \ No newline at end of file diff --git a/source/Core/BSP/Miniware/BSP.cpp b/source/Core/BSP/Miniware/BSP.cpp index 2e86af22..cb7d5248 100644 --- a/source/Core/BSP/Miniware/BSP.cpp +++ b/source/Core/BSP/Miniware/BSP.cpp @@ -288,3 +288,5 @@ uint64_t getDeviceID() { // return HAL_GetUIDw0() | ((uint64_t)HAL_GetUIDw1() << 32); } + +uint8_t getTipResistanceX10() { return TIP_RESISTANCE; } \ No newline at end of file diff --git a/source/Core/BSP/Pine64/BSP.cpp b/source/Core/BSP/Pine64/BSP.cpp index 3b8df2eb..0b84339e 100644 --- a/source/Core/BSP/Pine64/BSP.cpp +++ b/source/Core/BSP/Pine64/BSP.cpp @@ -93,3 +93,5 @@ void setStatusLED(const enum StatusLED state) {} uint8_t preStartChecks() { return 0; } uint64_t getDeviceID() { return dbg_id_get(); } + +uint8_t getTipResistanceX10() { return TIP_RESISTANCE; } \ No newline at end of file diff --git a/source/Core/Src/power.cpp b/source/Core/Src/power.cpp index 2fcc120b..593c4945 100644 --- a/source/Core/Src/power.cpp +++ b/source/Core/Src/power.cpp @@ -49,7 +49,7 @@ uint32_t availableW10(uint8_t sample) { // R = R*10 // P therefore is in V^2*100/R*10 = W*10. uint32_t v = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), sample); // 100 = 10v - uint32_t availableWattsX10 = (v * v) / TIP_RESISTANCE; + uint32_t availableWattsX10 = (v * v) / getTipResistanceX10(); // However, 100% duty cycle is not possible as there is a dead time while the ADC takes a reading // Therefore need to scale available milliwats by this