제어 장치#
소개#
controller 클래스는 V5 브레인에 연결된 VEX V5 컨트롤러를 나타냅니다. controller 객체를 사용하여 조이스틱 축 값에 접근하고, 버튼 상태를 읽고, 버튼 또는 조이스틱 콜백을 등록하고, 컨트롤러를 진동시키고, 컨트롤러 화면에 쓰고, 컨트롤러가 연결되었는지 확인할 수 있습니다.
VEX V5는 EXP 컨트롤러와 호환됩니다. 자세한 내용은 EXP 컨트롤러 API를 참조하세요.
장치 창에서 하나 이상의 컨트롤러가 구성된 경우 VEXcode V5는 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 V5 controller instance
controller Controller = controller();
회원 기능#
controller 클래스는 다음과 같은 멤버 함수를 포함합니다.
끓다#
rumble 진동 버튼을 누르면 컨트롤러가 특정 패턴으로 진동합니다. 패턴 문자열에서 점은 짧은 진동, 대시는 긴 진동, 공백은 일시 정지를 나타냅니다.
사용 가능한 기능
void rumble(const char *str);
매개변수 |
유형 |
설명 |
|---|---|---|
|
|
진동 패턴을 나타내는 점, 대시, 공백으로 이루어진 문자열. |
반환 값
이 함수는 값을 반환하지 않습니다.
예
// Rumble with a short-short-long pattern
Controller1.rumble("..-");
얻는 사람#
설치됨#
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.Axis3.position() > 0) {
Drivetrain.drive(forward);
}
else if (Controller1.Axis3.position() < 0) {
Drivetrain.drive(reverse);
}
// Press A to use Controller configured actions again
else if (Controller1.ButtonA.pressing()) {
break;
}
else {
Drivetrain.stop();
}
wait(20, msec);
}
RemoteControlCodeEnabled = true;