Added start/stop commands to the rigctl server

This commit is contained in:
AlexandreRouma 2021-11-05 19:42:49 +01:00
parent a938324886
commit 927115b50b
3 changed files with 26 additions and 9 deletions

View File

@ -362,21 +362,14 @@ void MainWindow::draw() {
if (playing) {
ImGui::PushID(ImGui::GetID("sdrpp_stop_btn"));
if (ImGui::ImageButton(icons::STOP, ImVec2(30, 30), ImVec2(0, 0), ImVec2(1, 1), 5) || ImGui::IsKeyPressed(GLFW_KEY_END, false)) {
playing = false;
onPlayStateChange.emit(false);
sigpath::sourceManager.stop();
sigpath::signalPath.inputBuffer.flush();
setPlayState(false);
}
ImGui::PopID();
}
else { // TODO: Might need to check if there even is a device
ImGui::PushID(ImGui::GetID("sdrpp_play_btn"));
if (ImGui::ImageButton(icons::PLAY, ImVec2(30, 30), ImVec2(0, 0), ImVec2(1, 1), 5) || ImGui::IsKeyPressed(GLFW_KEY_END, false)) {
sigpath::signalPath.inputBuffer.flush();
sigpath::sourceManager.start();
sigpath::sourceManager.tune(gui::waterfall.getCenterFrequency());
playing = true;
onPlayStateChange.emit(true);
setPlayState(true);
}
ImGui::PopID();
}
@ -659,6 +652,23 @@ void MainWindow::draw() {
}
}
void MainWindow::setPlayState(bool _playing) {
if (_playing == playing) { return; }
if (_playing) {
sigpath::signalPath.inputBuffer.flush();
sigpath::sourceManager.start();
sigpath::sourceManager.tune(gui::waterfall.getCenterFrequency());
playing = true;
onPlayStateChange.emit(true);
}
else {
playing = false;
onPlayStateChange.emit(false);
sigpath::sourceManager.stop();
sigpath::signalPath.inputBuffer.flush();
}
}
void MainWindow::setViewBandwidthSlider(float bandwidth) {
bw = bandwidth;
}

View File

@ -23,6 +23,7 @@ public:
// TODO: Replace with it's own class
void setVFO(double freq);
void setPlayState(bool _playing);
bool isPlaying();
bool lockWaterfallControls = false;

View File

@ -613,6 +613,12 @@ private:
else if (parts[0] == "q" || parts[0] == "\\quit") {
// Will close automatically
}
else if (parts[0] == "\\start") {
gui::mainWindow.setPlayState(true);
}
else if (parts[0] == "\\stop") {
gui::mainWindow.setPlayState(false);
}
else if (parts[0] == "\\dump_state") {
std::lock_guard lck(vfoMtx);
resp =