diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/DemoGoBildaIndicatorLight.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/DemoGoBildaIndicatorLight.java new file mode 100644 index 0000000..43a88a0 --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/DemoGoBildaIndicatorLight.java @@ -0,0 +1,92 @@ +/* + Copyright (c) 2024 Alan Smith + All rights reserved. + Redistribution and use in source and binary forms, with or without modification, + are permitted (subject to the limitations in the disclaimer below) provided that + the following conditions are met: + Redistributions of source code must retain the above copyright notice, this list + of conditions and the following disclaimer. + Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + Neither the name of Alan Smith nor the names of its contributors may be used to + endorse or promote products derived from this software without specific prior + written permission. + NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS + LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESSFOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +package org.firstinspires.ftc.teamcode; + +/* + * This OpMode illustrates how to use the goBILDA Indicator Light + * + * To make this work, this Light uses a Servo motor and setPositions. + * Valid values are from .277 to .722. + * + * If it's less than .277 then no light + * If it's greater than .722 then white light + * + * Spec Sheet is here: https://cdn11.bigcommerce.com/s-x56mtydx1w/images/stencil/original/products/2275/13464/3118-0808-0002-Product-Insight-4__03940__01348.1728056113.png?c=1 + */ + +import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; +import com.qualcomm.robotcore.eventloop.opmode.TeleOp; +import com.qualcomm.robotcore.hardware.Servo; + +@TeleOp(name = "Demo: goBILDA Indicator Light", group = "Concept") +public class DemoGoBildaIndicatorLight extends LinearOpMode { + Servo front_led; + private final double buffer = .277; + @Override + public void runOpMode() { + front_led = hardwareMap.get(Servo.class, "test_servo"); + + waitForStart(); + + while (opModeIsActive()) { + double left_x = Math.abs(gamepad1.left_stick_x) / 4; + double left_y = Math.abs(gamepad1.left_stick_y) / 4; + double right_x = Math.abs(gamepad1.right_stick_x) / 4; + double right_y = Math.abs(gamepad1.right_stick_y) / 4; + double total_position = Math.min(left_x + left_y + right_x + right_y + buffer, 1.0); + + telemetry.addData("left_x", left_x); + telemetry.addData("left_y", left_y); + telemetry.addData("right_x", right_x); + telemetry.addData("right_y", right_y); + telemetry.addData("total (plus buffer)", total_position); + telemetry.update(); + + front_led.setPosition(total_position); + + if (gamepad1.cross) { + front_led.setPosition(.611); + sleep(2000); + } + if (gamepad1.triangle) { + front_led.setPosition(.444); + sleep(2000); + } + if (gamepad1.square) { + front_led.setPosition(.7); + sleep(2000); + } + if (gamepad1.circle) { + front_led.setPosition(.3); + sleep(2000); + } + + + } + } + +}