제어 장치#
소개#
controller 클래스는 IQ 브레인에 연결된 VEX IQ 컨트롤러를 나타냅니다. controller 객체를 사용하여 조이스틱 축 값에 접근하고, 버튼 상태를 읽고, 버튼 또는 조이스틱 콜백을 등록하고, 컨트롤러가 연결되었는지 확인할 수 있습니다.
IQ(2세대) 브레인은 IQ(2세대) 또는 IQ(1세대) 컨트롤러에 연결할 수 있습니다. IQ(1세대) 컨트롤러에는 파란색 스마트 라디오가 설치되어 있어야 합니다.
장치 창에서 하나 이상의 컨트롤러가 구성되면 VEXcode IQ는 RemoteControlCodeEnabled도 제공합니다. 이 전역 변수는 장치 메뉴에서 구성된 컨트롤러 동작을 활성화 또는 비활성화합니다.
파생 클래스#
controller 클래스는 다음과 같은 파생 클래스를 제공합니다.
건설업자#
1 - 기본 컨트롤러 유형을 사용하여 컨트롤러를 생성합니다. 일반적으로 단일 컨트롤러가 연결된 경우에 사용됩니다.
controller();
2 - 지정된 컨트롤러 유형에 대한 컨트롤러를 생성합니다. 두 개의 컨트롤러가 연결될 때 사용됩니다.
controller( controllerType id );
사용 가능한 기능
controller();
controller(controllerType id);
매개변수 |
유형 |
설명 |
|---|---|---|
|
|
선택 사항입니다. 생성할 컨트롤러 유형은 다음과 같습니다. |
참고 사항
Only one primary controller and one partner controller can be created in a single project.
예
// Create the primary controller
controller Controller1 = controller();
// Create a partner controller
controller Controller2 = controller(partner);
오물 소각로#
컨트롤러#
~controller controller 객체를 파괴하고 관련 리소스를 해제합니다.
사용 가능한 기능
~controller();
매개변수#
매개변수 |
유형 |
설명 |
|---|---|---|
|
|
생성되는 컨트롤러 유형:
|
메모#
Only one
primaryand onepartnercontroller may exist in a single project.
예#
// Create a controller instance
controller Controller = controller();
회원 기능#
controller 클래스에는 다음과 같은 멤버 함수가 포함되어 있습니다.
installed- 컨트롤러가 브레인에 연결되어 있는지 확인합니다.
설치됨#
installed 컨트롤러가 브레인에 연결되었는지 여부를 반환합니다.
사용 가능한 기능
bool installed();
매개변수
이 함수는 매개변수를 받지 않습니다.
반환 값
불리언 값을 반환합니다.
true- The controller is installed/connected.false- The controller is not installed/connected.
전역 변수#
원격 제어 코드 활성화됨#
RemoteControlCodeEnabled 장치 메뉴에서 구성된 컨트롤러 동작을 활성화 또는 비활성화합니다. 컨트롤러에서 구성된 동작은 기본적으로 활성화되어 있습니다.
Usage:
RemoteControlCodeEnabled = state;
값 |
설명 |
|---|---|
|
컨트롤러에서 구성한 동작을 활성화합니다. |
|
컨트롤러에 설정된 동작을 비활성화합니다. |
true- Controller-configured actions are enabled.false- Controller-configured actions are disabled.
컨트롤러에서 구성된 액션은 기본적으로 활성화되어 있습니다.
// Drive forward or backward using the left joystick
RemoteControlCodeEnabled = false;
while (true) {
if (Controller1.AxisA.position() > 0) {
Drivetrain.drive(forward);
}
else if (Controller1.AxisA.position() < 0) {
Drivetrain.drive(reverse);
}
// Press E Up to use controller configured actions again
else if (Controller1.ButtonEUp.pressing()) {
break;
}
else {
Drivetrain.stop();
}
wait(20, msec);
}
RemoteControlCodeEnabled = true;