ടൈമർ#
ആമുഖം#
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 Functionsvoid reset();
ഈ ഫംഗ്ഷൻ ഒരു പാരാമീറ്ററുകളും സ്വീകരിക്കുന്നില്ല.
Return Valuesഈ ഫംഗ്ഷൻ ഒരു മൂല്യം തിരികെ നൽകുന്നില്ല.
Exampleswhile (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 Functionsdouble value();
ഈ ഫംഗ്ഷൻ ഒരു പാരാമീറ്ററുകളും സ്വീകരിക്കുന്നില്ല.
Return Valuesസെക്കൻഡുകളിൽ കടന്നുപോകുന്ന സമയത്തെ പ്രതിനിധീകരിക്കുന്ന ഇരട്ടി.
Notesടൈമർ നിർമ്മിക്കപ്പെടുമ്പോൾ ടൈമർ എണ്ണാൻ തുടങ്ങും.
Calling
resetresets the timer value to zero.
// 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 Functions1 — ഒരു നിശ്ചിത കാലതാമസത്തിനുശേഷം റൺ ചെയ്യുന്നതിനായി ഒരു കോൾബാക്ക് രജിസ്റ്റർ ചെയ്യുകയും കോൾബാക്കിലേക്ക് ഉപയോക്തൃ നിർവചിച്ച മൂല്യം കൈമാറുകയും ചെയ്യുന്നു.
static void event( void (*callback)(void *), uint32_t value );
Parameters2 — ഒരു നിശ്ചിത കാലതാമസത്തിനുശേഷം പ്രവർത്തിപ്പിക്കുന്നതിനായി ഒരു കോൾബാക്ക് രജിസ്റ്റർ ചെയ്യുന്നു.
static void event( void (*callback)(void), uint32_t value );
പാരാമീറ്റർ |
ടൈപ്പ് ചെയ്യുക |
വിവരണം |
|---|---|---|
|
|
നിർദ്ദിഷ്ട കാലതാമസത്തിന് ശേഷം വിളിക്കപ്പെടുന്ന ഒരു ഫംഗ്ഷൻ, ഉപയോക്തൃ നിർവചിച്ച ആർഗ്യുമെന്റ് സ്വീകരിക്കുന്നു. |
|
|
നിർദ്ദിഷ്ട കാലതാമസത്തിന് ശേഷം വിളിക്കപ്പെടുന്ന ഒരു ഫംഗ്ഷൻ. |
|
|
കോൾബാക്ക് ഫംഗ്ഷൻ നടപ്പിലാക്കുന്നതിന് മുമ്പുള്ള കാലതാമസം, മില്ലിസെക്കൻഡുകളിൽ. |
ഈ ഫംഗ്ഷൻ ഒരു മൂല്യം തിരികെ നൽകുന്നില്ല.
Notesഈ ഫംഗ്ഷൻ ഒരു തവണ മാത്രം കോൾബാക്ക് ഷെഡ്യൂൾ ചെയ്യുന്നു; ഇത് യാന്ത്രികമായി ആവർത്തിക്കുന്നില്ല.
കോൾബാക്ക് ഫംഗ്ഷൻ
voidനൽകണം.ഒന്നിലധികം പരിപാടികൾ ഒരേ സമയം ഷെഡ്യൂൾ ചെയ്തേക്കാം.
ഫംഗ്ഷൻ നിർവചിക്കുക (
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); }