@@ -118,6 +118,15 @@ Hal::~Hal()
118118 freeSimulatedPin ((void **)(&memory->in .isModeMdi ));
119119 freeSimulatedPin ((void **)(&memory->in .isModeTeleop ));
120120
121+ // If axis is not homed we need to ask Teleop mode but we need to bypass that if machine is homed
122+ // https://forum.linuxcnc.org/49-basic-configuration/40581-how-to-configure-a-xhc-whb04b-pendant
123+ freeSimulatedPin ((void **)(&memory->in .JointXisHomed ));
124+ freeSimulatedPin ((void **)(&memory->in .JointYisHomed ));
125+ freeSimulatedPin ((void **)(&memory->in .JointZisHomed ));
126+ freeSimulatedPin ((void **)(&memory->in .JointAisHomed ));
127+ freeSimulatedPin ((void **)(&memory->in .JointBisHomed ));
128+ freeSimulatedPin ((void **)(&memory->in .JointCisHomed ));
129+
121130 freeSimulatedPin ((void **)(&memory->in .isMachineOn ));
122131
123132 constexpr size_t pinsCount = sizeof (memory->out .button_pin ) / sizeof (hal_bit_t * );
@@ -543,6 +552,18 @@ void Hal::init(const MetaButtonCodes* metaButtons, const KeyCodes& keyCodes)
543552 newHalBit (HAL_IN, &(memory->in .isModeManual ), mHalCompId , " %s.halui.mode.is-manual" , mComponentPrefix );
544553 newHalBit (HAL_IN, &(memory->in .isModeMdi ), mHalCompId , " %s.halui.mode.is-mdi" , mComponentPrefix );
545554 newHalBit (HAL_IN, &(memory->in .isModeTeleop ), mHalCompId , " %s.halui.mode.is-teleop" , mComponentPrefix );
555+
556+
557+ // If axis is not homed we need to ask Teleop mode but we need to bypass that if machine is homed
558+ // https://forum.linuxcnc.org/49-basic-configuration/40581-how-to-configure-a-xhc-whb04b-pendant
559+ newHalBit (HAL_IN, &(memory->in .JointXisHomed ), mHalCompId , " %s.halui.joint.x.is-homed" , mComponentPrefix );
560+ newHalBit (HAL_IN, &(memory->in .JointYisHomed ), mHalCompId , " %s.halui.joint.y.is-homed" , mComponentPrefix );
561+ newHalBit (HAL_IN, &(memory->in .JointZisHomed ), mHalCompId , " %s.halui.joint.z.is-homed" , mComponentPrefix );
562+ newHalBit (HAL_IN, &(memory->in .JointAisHomed ), mHalCompId , " %s.halui.joint.a.is-homed" , mComponentPrefix );
563+ newHalBit (HAL_IN, &(memory->in .JointBisHomed ), mHalCompId , " %s.halui.joint.b.is-homed" , mComponentPrefix );
564+ newHalBit (HAL_IN, &(memory->in .JointCisHomed ), mHalCompId , " %s.halui.joint.c.is-homed" , mComponentPrefix );
565+
566+
546567 newHalBit (HAL_OUT, &(memory->out .doModeAuto ), mHalCompId , " %s.halui.mode.auto" , mComponentPrefix );
547568 newHalBit (HAL_OUT, &(memory->out .doModeJoint ), mHalCompId , " %s.halui.mode.joint" , mComponentPrefix );
548569 newHalBit (HAL_OUT, &(memory->out .doModeManual ), mHalCompId , " %s.halui.mode.manual" , mComponentPrefix );
@@ -986,7 +1007,7 @@ void Hal::toggleSpindleDirection(bool enabled)
9861007 }
9871008 else
9881009 {
989- *memory->out .spindleDoRunReverse = true ;
1010+ *memory->out .spindleDoRunReverse = true ;
9901011 *memory->out .spindleDoIncrease = true ;
9911012 }
9921013 }
@@ -1298,8 +1319,16 @@ void Hal::setPin(bool enabled, const char* pinName)
12981319// ----------------------------------------------------------------------
12991320void Hal::setJogCounts (const HandWheelCounters& counters)
13001321{
1301- requestManualMode (true );
1302- requestTeleopMode (true );
1322+ // If axis is not homed we need to ask Teleop mode but we need to bypass that if machine is homed
1323+ // https://forum.linuxcnc.org/49-basic-configuration/40581-how-to-configure-a-xhc-whb04b-pendant
1324+ if (*memory->out .axisXSelect && false == *memory->in .JointXisHomed ) {requestTeleopMode (true );}
1325+ else if (*memory->out .axisYSelect && false == *memory->in .JointYisHomed ) {requestTeleopMode (true );}
1326+ else if (*memory->out .axisZSelect && false == *memory->in .JointZisHomed ) {requestTeleopMode (true );}
1327+ else if (*memory->out .axisASelect && false == *memory->in .JointAisHomed ) {requestTeleopMode (true );}
1328+ else if (*memory->out .axisBSelect && false == *memory->in .JointBisHomed ) {requestTeleopMode (true );}
1329+ else if (*memory->out .axisCSelect && false == *memory->in .JointCisHomed ) {requestTeleopMode (true );}
1330+ {requestManualMode (true );}
1331+
13031332 *memory->out .axisXJogCounts = counters.counts (HandWheelCounters::CounterNameToIndex::AXIS_X);
13041333 *memory->out .axisYJogCounts = counters.counts (HandWheelCounters::CounterNameToIndex::AXIS_Y);
13051334 *memory->out .axisZJogCounts = counters.counts (HandWheelCounters::CounterNameToIndex::AXIS_Z);
0 commit comments