सीमा परिवर्तन#

परिचय#

limit क्लास का उपयोग लिमिट स्विच के साथ किया जाता है, जो एक छोटा डिजिटल सेंसर है जो किसी वस्तु के साथ भौतिक संपर्क का पता लगाता है।

VEX V5 लिमिट स्विच.

क्लास कंस्ट्रक्टर#

limit(
  triport::port &port);

क्लास डिस्ट्रक्टर#

limit ऑब्जेक्ट को नष्ट करता है और उससे जुड़े संसाधनों को मुक्त करता है।

virtual ~limit();

पैरामीटर#

पैरामीटर

प्रकार

विवरण

port

triport::port &

3-वायर पोर्ट जिससे लिमिट स्विच जुड़ा हुआ है, उसे Brain.ThreeWirePort.X या ExpanderName.Xके रूप में लिखा जाता है, जहाँ X पोर्ट अक्षर है (उदाहरण के लिए, Brain.ThreeWirePort.A या Expander1.A)।

उदाहरण#

// Create a limit instance in Port A
limit LimitSwitchA = limit(Brain.ThreeWirePort.A);

सदस्य कार्य#

limit क्लास में निम्नलिखित सदस्य फ़ंक्शन शामिल हैं:

  • pressing – लौटाता है कि क्या लिमिट स्विच दबाया जा रहा है।

  • pressed – लिमिट स्विच दबाए जाने पर कॉल किए जाने वाले फ़ंक्शन को रजिस्टर करता है।

  • released – लिमिट स्विच रिलीज़ होने पर कॉल किए जाने वाले फ़ंक्शन को रजिस्टर करता है।

किसी भी limit सदस्य फ़ंक्शन को कॉल करने से पहले, एक limit इंस्टेंस बनाना आवश्यक है, जैसा कि नीचे दिखाया गया है:

/* This constructor is required when using VS Code.
Limit Switch configuration is generated automatically
in VEXcode using the Device Menu. Replace the values
as needed. */

// Create a limit instance in Port A
limit LimitSwitchA = limit(Brain.ThreeWirePort.A);

pressing#

यह बताता है कि लिमिट स्विच वर्तमान में दबा हुआ है या नहीं। इसका उपयोग यह जांचने के लिए किया जा सकता है कि रोबोट किसी अन्य वस्तु से टकराता है या नहीं।

Available Functions
int32_t pressing();

Parameters

यह फ़ंक्शन कोई पैरामीटर स्वीकार नहीं करता है।

Return Values

यह int32_t लौटाता है जो दर्शाता है कि लिमिट स्विच दबाया जा रहा है या नहीं।

  • 1 — लिमिट स्विच दबाया जा रहा है।

  • 0 — लिमिट स्विच दबाया नहीं जा रहा है।

pressed#

लिमिट स्विच दबाए जाने पर कॉल किए जाने वाले फ़ंक्शन को पंजीकृत करता है।

Available Functions
void pressed(
  void (* callback)(void) );

Parameters

पैरामीटर

प्रकार

विवरण

callback

void (*)(void)

एक फ़ंक्शन का पॉइंटर जिसे लिमिट स्विच दबाए जाने पर कॉल किया जाएगा।

Return Values

इस कार्य पर कीमत के लिहाज से कुछ भी रिटर्न नहीं मिलता है।

Examples

कॉलबैक फ़ंक्शन को परिभाषित करें ( int main() के बाहर)

void switchPressed() {
  // The Brain will print that the Limit Switch was pressed
  // on the Brain's screen.
  Brain.Screen.print("switch pressed");
}

कॉलबैक को int main() के अंदर पंजीकृत करें

int main() {
  /* vexcodeInit() is only required when using VEXcode.
  Remove vexcodeInit() if compiling in VS Code. */
  vexcodeInit();

  // Run switchPressed when the Limit Switch is pressed.
  LimitSwitchA.pressed(switchPressed);
}

released#

लिमिट स्विच के रिलीज़ होने पर कॉल किए जाने वाले फ़ंक्शन को रजिस्टर करता है।

Available Functions
void released(
  void (* callback)(void) );

Parameters

पैरामीटर

प्रकार

विवरण

callback

void (*)(void)

एक फ़ंक्शन का पॉइंटर जिसे लिमिट स्विच रिलीज़ होने पर कॉल किया जाएगा।

Return Values

इस कार्य पर कीमत के लिहाज से कुछ भी रिटर्न नहीं मिलता है।

Examples

कॉलबैक फ़ंक्शन को परिभाषित करें ( int main() के बाहर)

void switchReleased() {
  // The Brain will print that the Limit Switch was released
  // on the Brain's screen.
  Brain.Screen.print("switch released");
}

कॉलबैक को int main() के अंदर पंजीकृत करें

int main() {
  /* vexcodeInit() is only required when using VEXcode.
  Remove vexcodeInit() if compiling in VS Code. */
  vexcodeInit();

  // Run switchReleased when the Limit Switch is released.
  LimitSwitchA.released(switchReleased);
}