// HandleArm // * Manage solenoids for arm up-down // ----> ASSUMES kForward on DoubleSolenoid is the down position. // * Handle intake motors void HandleArm() { if (gamepad.GetEvent(BUTTON_ARM) == kEventClosed && armDown) { arm.Set(DoubleSolenoid::kReverse); armDown = false; } else if (gamepad.GetEvent(BUTTON_ARM) == kEventClosed) { arm.Set(DoubleSolenoid::kForward); armDown = true; } if (gamepad.GetDPadEvent(BUTTON_INTAKE_COLLECT) == kEventClosed) { intake.Set(INTAKE_COLLECT); } else if (gamepad.GetDPadEvent(BUTTON_INTAKE_COLLECT) == kEventOpened) { intake.Set(0.0); } if(gamepad.GetDPadEvent(BUTTON_INTAKE_EJECT) == kEventClosed) { intake.Set(INTAKE_EJECT); } if (gamepad.GetDPadEvent(BUTTON_INTAKE_EJECT) == kEventOpened) { intake.Set(0.0); } }
void HandleArmInputs(void) { if (!m_jogTimerRunning) { if (gamepad.GetLeftY() < -0.1) { if (potentiometer.GetVoltage() < 4.5) { armMotor.Set(ARM_FWD); } else { armMotor.Set(0.0); } } else if (gamepad.GetLeftY() > 0.1) { if (potentiometer.GetVoltage() > .5) { armMotor.Set(ARM_REV); } else { armMotor.Set(0.0); } } else if (kEventClosed == gamepad.GetDPadEvent(Gamepad::kUp)) { armMotor.Set(ARM_FWD); jogTimer.Start(); jogTimer.Reset(); m_jogTimerRunning = true; } else if (kEventClosed == gamepad.GetDPadEvent(Gamepad::kDown)) { armMotor.Set(ARM_REV); jogTimer.Start(); jogTimer.Reset(); m_jogTimerRunning = true; } else { armMotor.Set(0.0); } } else if (jogTimer.HasPeriodPassed(JOG_TIME)) { armMotor.Set(0); jogTimer.Stop(); jogTimer.Reset(); m_jogTimerRunning = false; } if (gamepad.GetEvent(BUTTON_CLAW_1_LOCKED) == kEventClosed) { greenClaw.Set(DoubleSolenoid::kForward); } else if (gamepad.GetEvent(BUTTON_CLAW_1_UNLOCKED) == kEventClosed) { greenClaw.Set(DoubleSolenoid::kReverse); } else if (gamepad.GetEvent(BUTTON_CLAW_2_LOCKED) == kEventClosed) { yellowClaw.Set(DoubleSolenoid::kForward); } else if (gamepad.GetEvent(BUTTON_CLAW_2_UNLOCKED) == kEventClosed) { yellowClaw.Set(DoubleSolenoid::kReverse); } }
void Test() { menuType currentMenu = TOP; menuType newMenu = TOP; BaseMenu * menus[NUM_MENU_TYPE]; menus[TOP] = new TopMenu; menus[ANALOG] = new AnalogMenu; menus[DIGITAL_TOP] = new DigitalMenu; menus[SOLENOID] = new SolenoidMenu; menus[DIGITAL_PWM] = new PWMMenu; menus[DIGITAL_IO] = new DigitalIOMenu; menus[DIGITAL_RELAY] = new RelayMenu; menus[DIGITAL_IO_STATE] = new DigitalIOStateMenu; menus[DIGITAL_IO_CLOCK] = new DigitalIOClockMenu; menus[DIGITAL_IO_ENCODER] = new DigitalIOEncoderMenu; // Write out the TOP menu for the first time menus[currentMenu]->UpdateDisplay(); // Initialize the button states on the gamepad gamepad.Update(); // Loop counter to ensure that the program us running (debug helper // that can be removed when things get more stable) int sanity = 0; while (IsTest()) { // The dpad "up" button is used to move the menu pointer up one line // on the LCD display if (kEventClosed == gamepad.GetDPadEvent(Gamepad::kUp)) { menus[currentMenu]->HandleIndexUp(); } // The dpad "down" button is used to move the menu pointer down one line // on the LCD display if (kEventClosed == gamepad.GetDPadEvent(Gamepad::kDown)) { menus[currentMenu]->HandleIndexDown(); } // The dpad left button is used to exit a submenu when the menu pointer // points to the "back" menu item and to decrease a value (where // appropriate) on any other menu item. if (kEventClosed == gamepad.GetDPadEvent(Gamepad::kLeft)) { newMenu = menus[currentMenu]->HandleSelectLeft(); } // Theoretically, both the select buttons could be pressed in the // same 10 msec window. However, if using the dpad on the game // game controller this is physically impossible so we don't // need to worry about a previous value of newMenu being // overwritten in the next bit of code. // The dpad right button is used to enter a submenu when the menu pointer // points to a submenu item and to increase a value (where appropriate) // on any other menu item. if (kEventClosed == gamepad.GetDPadEvent(Gamepad::kRight)) { newMenu = menus[currentMenu]->HandleSelectRight(); // Handle change from one menu to a sub menu if (newMenu != currentMenu) { // When we enter a menu we need to set the record the // menu to return to. We do *not* want to do this when // returning from a menu to its calling menu. menus[newMenu]->SetCallingMenu(currentMenu); } } // Handle change from one menu to another if (newMenu != currentMenu) { menus[newMenu]->UpdateDisplay(); currentMenu = newMenu; } // Set the motor speed(s) (if any have been enabled via the Digital PWM menu) menus[DIGITAL_PWM]->SetSpeed(-1.0 * gamepad.GetRightY()); // Update gamepad button states gamepad.Update(); // Update the display (we do this on every loop pass because some menus // (analog, for example) need to have values updated even when there are // no dpad events to handle) menus[currentMenu]->UpdateDisplay(); // Dump the sanity time value to the LCD dsLCD->PrintfLine(DriverStationLCD::kUser_Line6, "Sanity: %d", sanity); dsLCD->UpdateLCD(); sanity++; // Run the loop every 50 msec (20 times per second) Wait(0.050); } }