Lasc Teorann#

Réamhrá#

Úsáidtear an rang teorainn limit leis an Lasc Teorann, braiteoir beag digiteach a bhraiteann teagmháil fhisiciúil le réad.

An Lasc Teorann VEX V5.

Tógálaí Ranga#

limit(
  triport::port &port);

Scriostóir Ranga#

Scriosann sé an réad limit agus scaoileann sé acmhainní gaolmhara.

virtual ~limit();

Paraiméadair#

Paraiméadar

Cineál

Cur síos

port

triport::port &

An Port 3-Sreang a bhfuil an Lasc Teorann ceangailte leis, scríofa mar Brain.ThreeWirePort.X nó ExpanderName.X, áit a seasann X do litir an phoirt (mar shampla, Brain.ThreeWirePort.A nó Expander1.A).

Sampla#

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

Feidhmeanna na mBall#

Áirítear leis an rang limit na feidhmeanna ball seo a leanas:

  • pressing – Tugann sé seo ar ais an bhfuil an Lasc Teorann á bhrú.

  • pressed – Cláraíonn sé feidhm le glaoch uirthi aon uair a bhrúitear an Lasc Teorann.

  • released – Cláraíonn sé feidhm le glaoch uirthi aon uair a scaoiltear an Lasc Teorann.

Sula nglaotar ar aon fheidhmeanna ball limit , ní mór sampla limit a chruthú, mar a thaispeántar thíos:

/* 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#

Tugann sé seo ar ais an bhfuil an Lasc Teorann á bhrú faoi láthair. Is féidir é seo a úsáid chun a sheiceáil an bhfuil an róbat ag bualadh le rudaí eile.

Available Functions
int32_t pressing();

Parameters

Ní ghlacann an fheidhm seo le haon pharaiméadair.

Return Values

Tugann sé int32_t a léiríonn an bhfuil an Lasc Teorann á bhrú.

  • 1 — Tá an Lasc Teorann á bhrú.

  • 0 — Níl an Lasc Teorann á bhrú.

pressed#

Cláraíonn sé feidhm le glaoch uirthi nuair a bhrúitear an Lasc Teorann.

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

Parameters

Paraiméadar

Cineál

Cur síos

callback

void (*)(void)

Pointeoir chuig feidhm a ghlaofar nuair a bhrúnn tú an Lasc Teorann.

Return Values

Ní thugann an fheidhm seo luach ar ais.

Examples

Sainmhínigh an fheidhm athghlaoite (lasmuigh de int main())

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

Cláraigh an glao ar ais taobh istigh de 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#

Cláraíonn sé feidhm le glaoch uirthi nuair a scaoiltear an Lasc Teorann.

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

Parameters

Paraiméadar

Cineál

Cur síos

callback

void (*)(void)

Pointeoir chuig feidhm a ghlaofar nuair a scaoiltear an Lasc Teorann.

Return Values

Ní thugann an fheidhm seo luach ar ais.

Examples

Sainmhínigh an fheidhm athghlaoite (lasmuigh de int main())

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

Cláraigh an glao ar ais taobh istigh de 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);
}