Skip to content

OpModes

OpModes in NextFTC extend the NextFTCOpMode base class, which is a subtype of OpMode. NextFTCOpModes have five functions, similar to OpMode's five functions.

OpMode functionNextFTCOpMode functionCalled
initonInitOnce, when the init button is pressed
init_looponWaitForStartEvery loop between initialization and when the start/stop button is pressed
startonStartButtonPressedOnce, when the start button is pressed
looponUpdateEvery loop, between start and when the stop button is pressed
stoponStopOnce, when the stop button is pressed

Additionally, OpModes can have components that are registered with the addComponents function.

An empty OpMode is as follows.

kotlin
class MyOpMode : NextFTCOpMode() {
    init {
        addComponents(/* vararg components */)
    }
    
    override fun onInit() { }
    override fun onWaitForStart() { }
    override fun onStartButtonPressed() { }
    override fun onUpdate() { }
    override fun onStop() { }
}