From 0c6e2700707a575bfb2d98a315456353c298d6c1 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Wed, 21 Feb 2024 23:03:20 +0100 Subject: [PATCH] M913 report rescaled currents --- Firmware/tmc2130.cpp | 8 ++++---- Firmware/tmc2130.h | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Firmware/tmc2130.cpp b/Firmware/tmc2130.cpp index bf920de4ed..2987921ae4 100755 --- a/Firmware/tmc2130.cpp +++ b/Firmware/tmc2130.cpp @@ -578,10 +578,10 @@ void tmc2130_setup_chopper(uint8_t axis, uint8_t mres, const MotorCurrents *curr void tmc2130_print_currents() { printf_P(_n("tmc2130_print_currents()\n\tH\tR\nX\t%d\t%d\nY\t%d\t%d\nZ\t%d\t%d\nE\t%d\t%d\n"), - currents[0].getiHold(), currents[0].getiRun(), - currents[1].getiHold(), currents[1].getiRun(), - currents[2].getiHold(), currents[2].getiRun(), - currents[3].getiHold(), currents[3].getiRun() + currents[0].getOriginaliHold(), currents[0].getOriginaliRun(), + currents[1].getOriginaliHold(), currents[1].getOriginaliRun(), + currents[2].getOriginaliHold(), currents[2].getOriginaliRun(), + currents[3].getOriginaliHold(), currents[3].getOriginaliRun() ); } diff --git a/Firmware/tmc2130.h b/Firmware/tmc2130.h index 6cf48f04eb..6c13081134 100644 --- a/Firmware/tmc2130.h +++ b/Firmware/tmc2130.h @@ -105,6 +105,8 @@ struct MotorCurrents { inline uint8_t getiRun() const { return iRun; } inline uint8_t getiHold() const { return min(iHold, iRun); } + inline uint8_t getOriginaliRun() const { return vSense ? iRun : iRun << 1; } + inline uint8_t getOriginaliHold() const { return min(vSense ? iHold : iHold << 1, getOriginaliRun()); } inline bool iHoldIsClamped() const { return iHold > iRun; } inline uint8_t getvSense() const { return vSense; }