File tree Expand file tree Collapse file tree 1 file changed +62
-0
lines changed
core/src/main/java/org/teamtators/rotator/commands Expand file tree Collapse file tree 1 file changed +62
-0
lines changed Original file line number Diff line number Diff line change 1+ package org .teamtators .rotator .commands ;
2+
3+ import org .teamtators .rotator .CommandBase ;
4+ import org .teamtators .rotator .CoreRobot ;
5+ import org .teamtators .rotator .config .Configurable ;
6+ import org .teamtators .rotator .control .Timer ;
7+ import org .teamtators .rotator .subsystems .AbstractVision ;
8+
9+ public class AutonFlashyFlash extends CommandBase implements Configurable <AutonFlashyFlash .Config > {
10+
11+ private Config config ;
12+ private int times ;
13+ private Timer timer ;
14+ private AbstractVision vision ;
15+
16+ public AutonFlashyFlash (CoreRobot robot ) {
17+ super ("AutonFlashyFlash" );
18+ vision = robot .vision ();
19+ requires (vision );
20+
21+ }
22+
23+ @ Override
24+ public void configure (AutonFlashyFlash .Config config ) {
25+ this .config = config ;
26+ }
27+
28+ @ Override
29+ protected void initialize () {
30+ logger .info ("Flashing light {} times" , config .maxTimes );
31+ times = 0 ;
32+ vision .setLedState (true );
33+ timer .reset ();
34+ timer .start ();
35+ }
36+
37+ @ Override
38+ protected boolean step () {
39+ boolean blinding = vision .getLedState ();
40+ if (blinding && timer .hasPeriodElapsed (config .onTime )) {
41+ vision .setLedState (false );
42+ timer .reset ();
43+ timer .start ();
44+ times ++;
45+ } else if (!blinding && timer .hasPeriodElapsed (config .offTime )) {
46+ vision .setLedState (true );
47+ timer .reset ();
48+ timer .start ();
49+ }
50+ return times >= config .maxTimes ;
51+ }
52+
53+ protected void finish () {
54+ vision .setLedState (false );
55+ }
56+
57+ static class Config {
58+ public int maxTimes ;
59+ public float onTime ;
60+ public float offTime ;
61+ }
62+ }
You can’t perform that action at this time.
0 commit comments