Skip to content

Commit ab3494a

Browse files
authored
Update pattern.h
Fix erratic behavior
1 parent f1ee184 commit ab3494a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/pattern.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ class JackHammer : public Pattern {
712712
d_out = d_in * (v_vib - v_stroke) / (v_vib + v_stroke)
713713
Formula neglects acceleration. Real timing will be slower due to finite acceleration & deceleration
714714
*/
715-
_outVibrationDistance = _inVibrationDistance * (_maxSpeed - _strokeInSpeed) / (_maxSpeed + _strokeInSpeed);
715+
_outVibrationDistance = _inVibrationDistance * max((_maxSpeed - _strokeInSpeed) / (_maxSpeed + _strokeInSpeed), 0);
716716

717717
#ifdef DEBUG_PATTERN
718718
Serial.println("_maxSpeed: " + String(_maxSpeed) + " _strokeInSpeed: " + String(_strokeInSpeed) + " _strokeOutSpeed: " + String(int(1.5 * _stroke/_timeOfStroke)));
@@ -824,7 +824,7 @@ class StrokeNibbler : public Pattern {
824824
d_out = d_in * (v_vib - v_stroke) / (v_vib + v_stroke)
825825
Formula neglects acceleration. Real timing will be slower due to finite acceleration & deceleration
826826
*/
827-
_outVibrationDistance = _inVibrationDistance * (_maxSpeed - _strokeSpeed) / (_maxSpeed + _strokeSpeed);
827+
_outVibrationDistance = _inVibrationDistance * max((_maxSpeed - _strokeSpeed) / (_maxSpeed + _strokeSpeed), 0);
828828

829829
#ifdef DEBUG_PATTERN
830830
Serial.println("_maxSpeed: " + String(_maxSpeed) + " _strokeSpeed: " + String(_strokeSpeed));

0 commit comments

Comments
 (0)