RC_Channel: move gripper up to AP_Vehicle

also make the singleton return a reference rather than a pointer
This commit is contained in:
Peter Barker 2024-02-21 17:40:35 +11:00 committed by Peter Barker
parent 362867415f
commit f3b9304d80
1 changed files with 3 additions and 6 deletions

View File

@ -1129,20 +1129,17 @@ void RC_Channel::do_aux_function_sprayer(const AuxSwitchPos ch_flag)
#if AP_GRIPPER_ENABLED #if AP_GRIPPER_ENABLED
void RC_Channel::do_aux_function_gripper(const AuxSwitchPos ch_flag) void RC_Channel::do_aux_function_gripper(const AuxSwitchPos ch_flag)
{ {
AP_Gripper *gripper = AP::gripper(); AP_Gripper &gripper = AP::gripper();
if (gripper == nullptr) {
return;
}
switch (ch_flag) { switch (ch_flag) {
case AuxSwitchPos::LOW: case AuxSwitchPos::LOW:
gripper->release(); gripper.release();
break; break;
case AuxSwitchPos::MIDDLE: case AuxSwitchPos::MIDDLE:
// nothing // nothing
break; break;
case AuxSwitchPos::HIGH: case AuxSwitchPos::HIGH:
gripper->grab(); gripper.grab();
break; break;
} }
} }