Skip to content

Commit

Permalink
Finally a fully working and accurate delay system
Browse files Browse the repository at this point in the history
  • Loading branch information
Snesnopic committed May 23, 2024
1 parent 9a8e604 commit de1a7db
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Morser/Model/VibrationEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class VibrationEngine: ObservableObject {
return morseCodeString.charAt(morseCodeIndex + 1)
}
}
// print("Word: \(morseCodeString) current index: \(morseCodeIndex) current char: \(character) next char: \(nextCharacter)")
let interCharDelay = (character == nextCharacter ? sameCharacterSeparatorDelay : characterSeparatorDelay)
morseCodeIndex += 1

switch character {
Expand All @@ -99,7 +99,7 @@ class VibrationEngine: ObservableObject {
dotPlayer?.playSound()
}
vibrationTimer = Timer.scheduledTimer(withTimeInterval: dotDuration +
(character == nextCharacter ? sameCharacterSeparatorDelay : characterSeparatorDelay), repeats: false) { _ in
interCharDelay, repeats: false) { _ in
self.triggerNextVibration()
}
case "-":
Expand All @@ -111,7 +111,7 @@ class VibrationEngine: ObservableObject {
// playHapticsFile(named: "dash")
// usleep(UInt32(dashDuration * 10000.0 * VibrationEngine.timeUnit))
// }
vibrationTimer = Timer.scheduledTimer(withTimeInterval: dashDuration + (character == nextCharacter ? sameCharacterSeparatorDelay : characterSeparatorDelay), repeats: false) { _ in
vibrationTimer = Timer.scheduledTimer(withTimeInterval: dashDuration + interCharDelay, repeats: false) { _ in
self.triggerNextVibration()
}
case "/":
Expand Down

0 comments on commit de1a7db

Please sign in to comment.