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

port

El puerto de 3 cables al que está conectado el rastreador de línea, ya sea un puerto en el Cerebro o un Expandedor de 3 cables.

Primero se debe crear un Brain o un 3-Wire Expander antes de poder usarlos para crear un objeto con el constructor de clase de línea.

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

unidades

The only valid unit for reflectivity is percent.

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

llamar de vuelta

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);
}