From 9a37907945df4c4b3a9379524e0f378512bc731d Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Wed, 11 May 2022 20:07:49 -0600 Subject: [PATCH] Iambic B! --- static/keyer.mjs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/static/keyer.mjs b/static/keyer.mjs index 5d625e4..986b87e 100644 --- a/static/keyer.mjs +++ b/static/keyer.mjs @@ -472,6 +472,33 @@ class IambicAKeyer extends IambicKeyer { } } +class IambicBKeyer extends IambicKeyer { + Reset() { + super.Reset() + this.queue = new QSet() + } + + Key(key, pressed) { + if (pressed) { + this.queue.add(key) + } + super.Key(key, pressed) + } + + nextTx() { + for (let key of [0,1]) { + if (this.keyPressed[key]) { + this.queue.add(key) + } + } + let next = this.queue.shift() + if (next == null) { + return -1 + } + return next + } +} + /** * Keyer class. This handles iambic and straight key input. * @@ -748,5 +775,5 @@ export { StraightKeyer, CootieKeyer, BugKeyer, ElBugKeyer, SingleDotKeyer, UltimaticKeyer, - IambicKeyer, IambicAKeyer, + IambicKeyer, IambicAKeyer, IambicBKeyer, }