Fix Iambic B bug

This commit is contained in:
Neale Pickett 2024-09-18 10:33:43 -06:00
parent 92b109b933
commit 455e6fcd49
2 changed files with 13 additions and 1 deletions

BIN
docs/DJ5IL_rt007.pdf Normal file

Binary file not shown.

View File

@ -391,6 +391,17 @@ class IambicAKeyer extends IambicKeyer {
} }
} }
/**
* "Iambic B"
*
* I have gotten a lot of helpful feedback on this one!
*
* Quoting DJ5IL:
*
* > if anytime during generation of an element the
* > opposite lever was pressed, generate one extra
* > alternate element.
*/
class IambicBKeyer extends IambicKeyer { class IambicBKeyer extends IambicKeyer {
Reset() { Reset() {
super.Reset() super.Reset()
@ -398,7 +409,7 @@ class IambicBKeyer extends IambicKeyer {
} }
Key(key, pressed) { Key(key, pressed) {
if (pressed) { if (pressed && (this.sending != key)) {
this.queue.add(key) this.queue.add(key)
} }
super.Key(key, pressed) super.Key(key, pressed)
@ -411,6 +422,7 @@ class IambicBKeyer extends IambicKeyer {
} }
} }
let next = this.queue.shift() let next = this.queue.shift()
this.sending = next
if (next == null) { if (next == null) {
return -1 return -1
} }