línea#
Inicializando la línea Clase#
Un rastreador de línea se crea utilizando el siguiente constructor:
The line constructor uses one parameter:
Parámetro |
Descripción |
|---|---|
|
The 3-Wire Port that the Line Tracker is connected to, whether it’s a port on the |
A Brain or 3-Wire Expander must be created first before they can be used to create an object with the line Class constructor.
// Create the Brain.
brain Brain;
// Construct a Line Tracker "Line" with the line class.
line Line = line(Brain.ThreeWirePort.A);
This Line object will be used in all subsequent examples throughout this API documentation when referring to line class methods.
Métodos de clase#
reflectivity()#
The reflectivity(percentUnits units) command returns the reflectivity measured by the Line Tracker. The reflectivity of the Line Tracker is an estimation based on the raw value of the sensor. A reflectivity of 0% is a raw value of 3000 or greater. A reflectivity of 100% is a raw value of 0.
Parámetros |
Descripción |
|---|---|
|
The only valid unit for reflectivity is |
Devuelve: Un doble que representa la reflectividad medida por el rastreador de línea como un valor en el rango de 0 a 100%.
// Get Line Tracker reflectivity in range of 0 - 100%.
double value = Line.reflectivity();
// Print the reflectivity of the Line Tracker to the
// Brain's screen.
Brain.Screen.print(value);
changed()#
The changed(callback) command registers a callback function for when the value of the Line Tracker changes.
Parámetros |
Descripción |
|---|---|
|
La función de devolución de llamada que se llamará cuando cambie el valor del Rastreador de línea. |
Devoluciones: Ninguna.
// Define the lineChanged function with a void return type,
// showing it doesn't return a value.
void lineChanged() {
// The Brain will print that the value of the Line Tracker
// changed on the brain screen.
Brain.Screen.print("Line Tracker value changed");
}
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// Run lineChanged when the value of the Line Tracker changes.
Line.changed(lineChanged);
}