Hi,
I’ve just started working on learning the C++ code for IQ and keep having the issue of ‘use of undeclared identifier ‘onevent_LDownPressed_0’ (616, 16)’ below is the main bits of code.
void onevent_LDownPressed_0() {
Brain.Screen.clearScreen();
Brain.Screen.setCursor(1,1);
Brain.Screen.print("DEBUG MENU");
Brain.Screen.newLine();
Brain.Screen.print("Battery: "+Brain.Battery.capacity(percent));
}
I also have this
int main() {
// initialize the random number system
srand(Brain.Timer.system());
// register event handlers
GetGridPos(onevent_GetGridPos_0);
TLED.pressed(onevent_TLED_pressed_0);
message1(onevent_message1_0);
ShutdownAuto(onevent_ShutdownAuto_0);
LDownPressed(onevent_LDownPressed_0);
wait(15, msec);
whenStarted1();
}
And this
#pragma region VEXcode Generated Robot Configuration
// Make sure all required headers are included.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <string.h>
#include "vex.h"
using namespace vex;
// Brain should be defined by default
brain Brain;
// START IQ MACROS
#define waitUntil(condition) \
do { \
wait(5, msec); \
} while (!(condition))
#define repeat(iterations) \
for (int iterator = 0; iterator < iterations; iterator++)
// END IQ MACROS
// Robot configuration code.
controller Controller = controller();
motor LeftDriveSmart = motor(PORT7, 1, false);
motor RightDriveSmart = motor(PORT6, 1, true);
drivetrain Drivetrain = drivetrain(LeftDriveSmart, RightDriveSmart, 200, 173, 76, mm, 1);
motor Lyft = motor(PORT1, true);
motor Spinner = motor(PORT10, true);
touchled TLED = touchled(PORT11);
gyro Gyroschopic = gyro(PORT12);
colorsensor GridPosSys = colorsensor(PORT9);
// define variable for remote controller enable/disable
bool RemoteControlCodeEnabled = true;
// define variables used for controlling motors based on controller inputs
bool eButtonsControlMotorsStopped = true;
bool fButtonsControlMotorsStopped = true;
bool DrivetrainLNeedsToBeStopped_Controller = true;
bool DrivetrainRNeedsToBeStopped_Controller = true;
// define a task that will handle monitoring inputs from Controller
int rc_auto_loop_function_Controller() {
// process the controller input every 20 milliseconds
// update the motors based on the input values
while(true) {
if(RemoteControlCodeEnabled) {
// calculate the drivetrain motor velocities from the controller joystick axies
// left = AxisA + AxisC
// right = AxisA - AxisC
int drivetrainLeftSideSpeed = Controller.AxisA.position() + Controller.AxisC.position();
int drivetrainRightSideSpeed = Controller.AxisA.position() - Controller.AxisC.position();
// check if the value is inside of the deadband range
if (drivetrainLeftSideSpeed < 5 && drivetrainLeftSideSpeed > -5) {
// check if the left motor has already been stopped
if (DrivetrainLNeedsToBeStopped_Controller) {
// stop the left drive motor
LeftDriveSmart.stop();
// tell the code that the left motor has been stopped
DrivetrainLNeedsToBeStopped_Controller = false;
}
} else {
// reset the toggle so that the deadband code knows to stop the left motor nexttime the input is in the deadband range
DrivetrainLNeedsToBeStopped_Controller = true;
}
// check if the value is inside of the deadband range
if (drivetrainRightSideSpeed < 5 && drivetrainRightSideSpeed > -5) {
// check if the right motor has already been stopped
if (DrivetrainRNeedsToBeStopped_Controller) {
// stop the right drive motor
RightDriveSmart.stop();
// tell the code that the right motor has been stopped
DrivetrainRNeedsToBeStopped_Controller = false;
}
} else {
// reset the toggle so that the deadband code knows to stop the right motor next time the input is in the deadband range
DrivetrainRNeedsToBeStopped_Controller = true;
}
// only tell the left drive motor to spin if the values are not in the deadband range
if (DrivetrainLNeedsToBeStopped_Controller) {
LeftDriveSmart.setVelocity(drivetrainLeftSideSpeed, percent);
LeftDriveSmart.spin(forward);
}
// only tell the right drive motor to spin if the values are not in the deadband range
if (DrivetrainRNeedsToBeStopped_Controller) {
RightDriveSmart.setVelocity(drivetrainRightSideSpeed, percent);
RightDriveSmart.spin(forward);
}
// check the ButtonEUp/ButtonEDown status to control Lyft
if (Controller.ButtonEUp.pressing()) {
Lyft.spin(forward);
eButtonsControlMotorsStopped = false;
} else if (Controller.ButtonEDown.pressing()) {
Lyft.spin(reverse);
eButtonsControlMotorsStopped = false;
} else if (!eButtonsControlMotorsStopped) {
Lyft.stop();
// set the toggle so that we don't constantly tell the motor to stop when the buttons are released
eButtonsControlMotorsStopped = true;
}
// check the ButtonFUp/ButtonFDown status to control Spinner
if (Controller.ButtonFUp.pressing()) {
Spinner.spin(forward);
fButtonsControlMotorsStopped = false;
} else if (Controller.ButtonFDown.pressing()) {
Spinner.spin(reverse);
fButtonsControlMotorsStopped = false;
} else if (!fButtonsControlMotorsStopped) {
Spinner.stop();
// set the toggle so that we don't constantly tell the motor to stop when the buttons are released
fButtonsControlMotorsStopped = true;
}
}
// wait before repeating the process
wait(20, msec);
}
return 0;
}
task rc_auto_loop_task_Controller(rc_auto_loop_function_Controller);
#pragma endregion VEXcode Generated Robot Configuration