-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- RobotOpMode to simplify robot use - Robot has more useful fields and methods - GamepadEx now listens to analog sticks for changes - Removed debug code from GUI
- Loading branch information
1 parent
81a7314
commit fc4da2b
Showing
9 changed files
with
91 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
command/src/main/kotlin/com/amarcolini/joos/command/RobotOpMode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.amarcolini.joos.command | ||
|
||
import com.qualcomm.robotcore.eventloop.opmode.* | ||
import kotlin.reflect.full.hasAnnotation | ||
|
||
/** | ||
* An OpMode made for [Robot]s. | ||
*/ | ||
abstract class RobotOpMode : OpMode() { | ||
/** | ||
* Whether this OpMode is a teleop OpMode. | ||
*/ | ||
@JvmField | ||
protected val isTeleOp = this::class.hasAnnotation<TeleOp>() | ||
|
||
/** | ||
* Whether this OpMode is an autonomous OpMode. | ||
*/ | ||
@JvmField | ||
protected val isAutonomous = this::class.hasAnnotation<Autonomous>() | ||
|
||
private lateinit var robot: Robot | ||
final override fun init_loop() = robot.update() | ||
final override fun start() = robot.start() | ||
final override fun loop() = robot.update() | ||
override fun stop() = robot.reset() | ||
|
||
/** | ||
* Initializes the given robot with this OpMode. This method **must** be called | ||
* in order for this OpMode to work correctly. | ||
*/ | ||
protected fun initialize(robot: Robot) { | ||
this.robot = robot | ||
robot.init() | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
command/src/main/kotlin/com/amarcolini/joos/gamepad/Button.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters