লিমিট সুইচ#

ভূমিকা#

limit ক্লাসটি লিমিট সুইচের সাথে ব্যবহৃত হয়, যা একটি ছোট ডিজিটাল সেন্সর এবং এটি কোনো বস্তুর সাথে ভৌত সংস্পর্শ শনাক্ত করে।

VEX EXP লিমিট সুইচ।

ক্লাস কনস্ট্রাক্টর#

limit(
  triport::port &port);

ক্লাস ডেস্ট্রাক্টর#

limit অবজেক্টটি ধ্বংস করে এবং সংশ্লিষ্ট রিসোর্সসমূহ মুক্ত করে।

virtual ~limit();

প্যারামিটার#

প্যারামিটার

প্রকার

বর্ণনা

port

triport::port &

লিমিট সুইচটি যে ৩-ওয়্যার পোর্টের সাথে সংযুক্ত থাকে, তা 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);
}