@@ -45,7 +45,7 @@ void Animation::run(unsigned long currentMicros) {
4545 this ->handlePlayMode (currentMicros);
4646 break ;
4747 case MODE_STOP:
48- this ->handleStopMode ();
48+ this ->handleStopMode (currentMicros );
4949 break ;
5050 case MODE_LIVE:
5151 this ->handleLiveMode ();
@@ -88,9 +88,15 @@ void Animation::handlePlayMode(unsigned long currentMicros) {
8888 }
8989}
9090
91- void Animation::handleStopMode () {
91+ void Animation::handleStopMode (unsigned long currentMicros ) {
9292 bool allNeutral = true ;
9393
94+ if (currentMicros - this ->lastMicros < 10000 ) {
95+ return ;
96+ }
97+
98+ this ->lastMicros = currentMicros;
99+
94100 for (int i = 0 ; i < MAX_SERVO_COUNT; i++) {
95101 Servo *servo = this ->servos [i];
96102
@@ -100,14 +106,11 @@ void Animation::handleStopMode() {
100106 }
101107 }
102108
103- if (allNeutral) {
104- this ->changeMode (MODE_DEFAULT);
109+ if (!allNeutral) {
105110 return ;
106111 }
107112
108- if (this ->stopStepDelay > 0 ) {
109- delay (this ->stopStepDelay );
110- }
113+ this ->changeMode (MODE_DEFAULT);
111114}
112115
113116void Animation::handleLiveMode () {
@@ -158,13 +161,13 @@ void Animation::loop(unsigned long currentMicros) {
158161 this ->changeMode (MODE_LOOP);
159162}
160163
161- void Animation::stop (byte stepDelay ) {
164+ void Animation::stop (unsigned long currentMicros ) {
162165 if (this ->modeIsIn (2 , MODE_DEFAULT, MODE_STOP)) {
163166 return ;
164167 }
165168
166- this ->stopStepDelay = stepDelay;
167169 this ->frame = 0 ;
170+ this ->lastMicros = currentMicros;
168171 this ->changeMode (MODE_STOP);
169172}
170173
0 commit comments