ടൈമർ#

ആമുഖം#

The timer class is used to keep time and interact with a timer independent of the Brain’s timer.

ക്ലാസ് കൺസ്ട്രക്റ്റർ#

timer();

ക്ലാസ് ഡിസ്ട്രക്റ്റർ#

timer ഒബ്‌ജക്റ്റ് നശിപ്പിക്കുകയും അനുബന്ധ ഉറവിടങ്ങൾ പുറത്തുവിടുകയും ചെയ്യുന്നു.

~timer();

പാരാമീറ്ററുകൾ#

ഈ കൺസ്ട്രക്റ്റർ ഒരു പാരാമീറ്ററുകളും സ്വീകരിക്കുന്നില്ല.

ഉദാഹരണങ്ങൾ#

// Create a timer instance
timer myTimer = timer();

അംഗ പ്രവർത്തനങ്ങൾ#

timer ക്ലാസിൽ ഇനിപ്പറയുന്ന അംഗ ഫംഗ്‌ഷനുകൾ ഉൾപ്പെടുന്നു:

  • reset — Resets the timer to zero.

  • value — Returns the elapsed time since the timer started.

  • event — ഓപ്ഷണൽ ആർഗ്യുമെന്റുകൾ ഉപയോഗിച്ച്, ഒരു നിശ്ചിത എണ്ണം മില്ലിസെക്കൻഡുകൾക്ക് ശേഷം ഒരു ഫംഗ്ഷൻ വിളിക്കുന്നു.

ഏതെങ്കിലും timer അംഗ ഫംഗ്‌ഷനുകൾ വിളിക്കുന്നതിന് മുമ്പ്, താഴെ കാണിച്ചിരിക്കുന്നതുപോലെ ഒരു timer ഇൻസ്റ്റൻസ് സൃഷ്ടിക്കണം:

/* This constructor is required to use a 
custom timer. Replace the values
as needed. */

// Create a timer instance
timer myTimer = timer();

/* This constructor is required when using VS Code.
A Brain is generated automatically at the start of
VEXcode projects. */

// Create the Brain to use Brain.Timer
brain Brain = brain();

reset#

ടൈമർ പൂജ്യമായി സജ്ജമാക്കുന്നു.

Available Functions
void reset();

Parameters

ഈ ഫംഗ്ഷൻ ഒരു പാരാമീറ്ററുകളും സ്വീകരിക്കുന്നില്ല.

Return Values

ഈ ഫംഗ്ഷൻ ഒരു മൂല്യം തിരികെ നൽകുന്നില്ല.

Examples
while (true) {
  // Clear the timer every time the screen is pressed
  if (Brain.Screen.pressing()) {
    myTimer.reset();
  }
  Brain.Screen.clearScreen();
  Brain.Screen.setCursor(1, 1);
  Brain.Screen.print("Time: %.2f", myTimer.value());
  wait(50, msec);
}

value#

ടൈമറിന്റെ നിലവിലെ മൂല്യം നൽകുന്നു.

Available Functions
double value();

Parameters

ഈ ഫംഗ്ഷൻ ഒരു പാരാമീറ്ററുകളും സ്വീകരിക്കുന്നില്ല.

Return Values

സെക്കൻഡുകളിൽ കടന്നുപോകുന്ന സമയത്തെ പ്രതിനിധീകരിക്കുന്ന ഇരട്ടി.

Notes
  • ടൈമർ നിർമ്മിക്കപ്പെടുമ്പോൾ ടൈമർ എണ്ണാൻ തുടങ്ങും.

  • Calling reset resets the timer value to zero.

Examples
// Display the timer as it ticks up
while (true) {
  Brain.Screen.clearScreen();
  Brain.Screen.setCursor(1, 1);
  Brain.Screen.print("Time: %.2f", myTimer.value());

  wait(50, msec);
}

event#

ഒരു നിശ്ചിത കാലതാമസത്തിനുശേഷം നടപ്പിലാക്കേണ്ട ഒരു കോൾബാക്ക് ഫംഗ്‌ഷൻ രജിസ്റ്റർ ചെയ്യുന്നു.

Available Functions

1 — ഒരു നിശ്ചിത കാലതാമസത്തിനുശേഷം റൺ ചെയ്യുന്നതിനായി ഒരു കോൾബാക്ക് രജിസ്റ്റർ ചെയ്യുകയും കോൾബാക്കിലേക്ക് ഉപയോക്തൃ നിർവചിച്ച മൂല്യം കൈമാറുകയും ചെയ്യുന്നു.

static void event(
    void (*callback)(void *),
    uint32_t value );

2 — ഒരു നിശ്ചിത കാലതാമസത്തിനുശേഷം പ്രവർത്തിപ്പിക്കുന്നതിനായി ഒരു കോൾബാക്ക് രജിസ്റ്റർ ചെയ്യുന്നു.

static void event(
    void (*callback)(void),
    uint32_t value );

Parameters

പാരാമീറ്റർ

ടൈപ്പ് ചെയ്യുക

വിവരണം

callback

void (*)(void *)

നിർദ്ദിഷ്ട കാലതാമസത്തിന് ശേഷം വിളിക്കപ്പെടുന്ന ഒരു ഫംഗ്ഷൻ, ഉപയോക്തൃ നിർവചിച്ച ആർഗ്യുമെന്റ് സ്വീകരിക്കുന്നു.

callback

void (*)(void)

നിർദ്ദിഷ്ട കാലതാമസത്തിന് ശേഷം വിളിക്കപ്പെടുന്ന ഒരു ഫംഗ്ഷൻ.

value

uint32_t

കോൾബാക്ക് ഫംഗ്ഷൻ നടപ്പിലാക്കുന്നതിന് മുമ്പുള്ള കാലതാമസം, മില്ലിസെക്കൻഡുകളിൽ.

Return Values

ഈ ഫംഗ്ഷൻ ഒരു മൂല്യം തിരികെ നൽകുന്നില്ല.

Notes
  • ഈ ഫംഗ്ഷൻ ഒരു തവണ മാത്രം കോൾബാക്ക് ഷെഡ്യൂൾ ചെയ്യുന്നു; ഇത് യാന്ത്രികമായി ആവർത്തിക്കുന്നില്ല.

  • കോൾബാക്ക് ഫംഗ്ഷൻ void നൽകണം.

  • ഒന്നിലധികം പരിപാടികൾ ഒരേ സമയം ഷെഡ്യൂൾ ചെയ്തേക്കാം.

Examples

ഫംഗ്ഷൻ നിർവചിക്കുക ( int main() ന് പുറത്ത്)

// Create a function to turn the screen orange
void turnOrange() {
  Brain.Screen.clearScreen(orange);
}

int main() നുള്ളിൽ ഫംഗ്ഷൻ രജിസ്റ്റർ ചെയ്യുക.

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

  timer myTimer = timer();
  // Call turnOrange after 2 seconds
  myTimer.event(turnOrange, 2000);
}