new feature: stopping keyer

This commit is contained in:
Martin Brodbeck 2024-02-14 11:32:09 +01:00
parent be9ac6b074
commit 251c365095
3 changed files with 23 additions and 2 deletions

View file

@ -149,8 +149,21 @@ void Keyer::run()
} }
break; break;
case State::Abort:
gpio_put(LED_PIN, 0);
m_Sidetone.off();
m_keyNextIambicB = false;
m_currentlyPausing = false;
m_currentlyKeying = false;
m_previousState = State::Abort;
state = State::Wait;
break;
default: default:
break; break;
} }
}
void Keyer::stop()
{
state = State::Abort;
} }

View file

@ -15,6 +15,7 @@ public:
Dit, Dit,
Dah, Dah,
InterCharSpace, InterCharSpace,
Abort,
}; };
Keyer() = delete; Keyer() = delete;
Keyer(uint8_t wpm, Mode mode); Keyer(uint8_t wpm, Mode mode);
@ -23,6 +24,7 @@ public:
void setSpeed(uint8_t wpm); void setSpeed(uint8_t wpm);
void run(); void run();
void stop();
private: private:
State state{State::Wait}; State state{State::Wait};

View file

@ -23,6 +23,7 @@ enum class KeyerQueueCommand
Run, Run,
Stop, Stop,
Config, Config,
Wait,
}; };
struct KeyerQueueData struct KeyerQueueData
{ {
@ -69,11 +70,16 @@ void core1_main()
keyer.run(); keyer.run();
break; break;
case KeyerQueueCommand::Stop: case KeyerQueueCommand::Stop:
keyer.stop();
data.cmd = KeyerQueueCommand::Wait;
break; break;
case KeyerQueueCommand::Config: case KeyerQueueCommand::Config:
// set speed and wpm keyer.setSpeed(data.wpm);
keyer.setMode(data.mode);
data.cmd = KeyerQueueCommand::Run; data.cmd = KeyerQueueCommand::Run;
break; break;
case KeyerQueueCommand::Wait:
break;
default: default:
break; break;
} }