@@ -53,7 +53,7 @@ Axis::Axis(char axis,volatile Control_t* control) :CommandHandler("axis", CLSID_
5353 restoreFlash (); // Load parameters
5454 CommandHandler::registerCommands (); // Internal commands
5555 registerCommands ();
56-
56+ updateTorqueScaler (); // In case no flash setting has been loaded yet
5757}
5858
5959Axis::~Axis ()
@@ -79,7 +79,7 @@ void Axis::registerCommands(){
7979 registerCommand (" pos" , Axis_commands::pos, " Encoder position" ,CMDFLAG_GET);
8080 registerCommand (" maxspeed" , Axis_commands::maxspeed, " Speed limit in deg/s" ,CMDFLAG_GET | CMDFLAG_SET);
8181 registerCommand (" maxtorquerate" , Axis_commands::maxtorquerate, " Torque rate limit in counts/ms" ,CMDFLAG_GET | CMDFLAG_SET);
82- registerCommand (" fxratio" , Axis_commands::fxratio, " Effect ratio. Reduces effects excluding endstop. 255=100%" ,CMDFLAG_GET | CMDFLAG_SET);
82+ registerCommand (" fxratio" , Axis_commands::fxratio, " Effect ratio. Reduces game effects excluding endstop. 255=100%" ,CMDFLAG_GET | CMDFLAG_SET);
8383 registerCommand (" curtorque" , Axis_commands::curtorque, " Axis torque" ,CMDFLAG_GET);
8484 registerCommand (" curpos" , Axis_commands::curpos, " Axis position" ,CMDFLAG_GET);
8585 registerCommand (" curspd" , Axis_commands::curspd, " Axis speed" ,CMDFLAG_GET);
@@ -452,7 +452,7 @@ void Axis::setIdleSpringStrength(uint8_t spring){
452452 }else {
453453 idle_center = true ;
454454 }
455- idlespringclip = clip<int32_t ,int32_t >((int32_t )spring*50 ,0 ,10000 );
455+ idlespringclip = clip<int32_t ,int32_t >((int32_t )spring*35 ,0 ,10000 );
456456 idlespringscale = 0 .5f + ((float )spring * 0 .01f );
457457}
458458
@@ -523,8 +523,8 @@ uint16_t Axis::getPower(){
523523}
524524
525525void Axis::updateTorqueScaler () {
526- float effect_margin_scaler = ((float )fx_ratio_i/255.0 );
527- torqueScaler = ((float )power / (float )0x7fff ) * effect_margin_scaler ;
526+ effect_margin_scaler = ((float )fx_ratio_i/255.0 );
527+ torqueScaler = ((float )power / (float )0x7fff );
528528}
529529
530530float Axis::getTorqueScaler (){
@@ -547,7 +547,7 @@ int16_t Axis::updateEndstop(){
547547 return 0 ;
548548 }
549549 float addtorque = clipdir*metric.current .posDegrees - (float )this ->degreesOfRotation /2.0 ; // degress of rotation counts total range so multiply by 2
550- addtorque *= (float )endstopStrength * endstopGain * torqueScaler ; // Apply endstop gain for stiffness.
550+ addtorque *= (float )endstopStrength * endstopGain; // Apply endstop gain for stiffness.
551551 addtorque *= -clipdir;
552552
553553 return clip<int32_t ,int32_t >(addtorque,-0x7fff ,0x7fff );
@@ -566,10 +566,11 @@ bool Axis::updateTorque(int32_t* totalTorque) {
566566 }
567567
568568 // Scale effect torque
569- effectTorque *= torqueScaler;
570-
571- int32_t torque = effectTorque + updateEndstop ();
572- torque += axisEffectTorque * torqueScaler; // Updated from effect calculator
569+ int32_t torque = effectTorque; // Game effects
570+ torque *= effect_margin_scaler;
571+ torque += axisEffectTorque; // Independent effects
572+ torque += updateEndstop ();
573+ torque *= torqueScaler; // Scale to power
573574
574575 // TODO speed and accel limiters
575576 if (maxSpeedDegS > 0 ){
0 commit comments