mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-07-12 20:15:37 +02:00
More work on MacOS and the scheduler
This commit is contained in:
@ -11,12 +11,18 @@ namespace sched_action {
|
||||
|
||||
}
|
||||
|
||||
void showEditMenu() {
|
||||
|
||||
void prepareEditMenu() {
|
||||
|
||||
}
|
||||
|
||||
bool showEditMenu(bool& valid) {
|
||||
valid = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
void loadFromConfig(json config) {
|
||||
if (config.contains("recorder")) { recorderName = config["recorder"]; }
|
||||
name = "Start \"" + recorderName + "\"";
|
||||
}
|
||||
|
||||
json saveToConfig() {
|
||||
@ -27,16 +33,13 @@ namespace sched_action {
|
||||
|
||||
|
||||
std::string getName() {
|
||||
return "Start \"" + recorderName + "\"";
|
||||
}
|
||||
|
||||
bool isValid() {
|
||||
return valid;
|
||||
return name;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string recorderName;
|
||||
bool valid = false;
|
||||
|
||||
std::string name = "Start \"\"";
|
||||
|
||||
};
|
||||
|
||||
|
@ -1,49 +1,143 @@
|
||||
#pragma once
|
||||
#include <sched_action.h>
|
||||
#include <utils/freq_formatting.h>
|
||||
#include <gui/tuner.h>
|
||||
#include <signal_path/signal_path.h>
|
||||
|
||||
namespace sched_action {
|
||||
|
||||
const int tuningModes[] = {
|
||||
tuner::TUNER_MODE_NORMAL,
|
||||
tuner::TUNER_MODE_CENTER
|
||||
};
|
||||
|
||||
const int tuningModeCount = sizeof(tuningModes) / sizeof(int);
|
||||
|
||||
const char* tuningModesStr[] = {
|
||||
"Normal",
|
||||
"Center"
|
||||
};
|
||||
|
||||
class TuneVFOClass : public ActionClass {
|
||||
public:
|
||||
TuneVFOClass() {}
|
||||
TuneVFOClass() {
|
||||
for (auto& mode : tuningModesStr) {
|
||||
tuningModesTxt += mode;
|
||||
tuningModesTxt += '\0';
|
||||
}
|
||||
}
|
||||
|
||||
~TuneVFOClass() {}
|
||||
|
||||
void trigger() {
|
||||
|
||||
if (vfoName.empty()) { return; }
|
||||
tuner::tune(tuningMode, vfoName, frequency);
|
||||
}
|
||||
|
||||
void prepareEditMenu() {}
|
||||
void prepareEditMenu() {
|
||||
tmpFrequency = frequency;
|
||||
|
||||
void validateEditMenu() {}
|
||||
// TODO: Find tuning mode
|
||||
tuningModeId = 0;
|
||||
|
||||
void showEditMenu() {
|
||||
|
||||
// Generate text list
|
||||
vfoNameId = -1;
|
||||
vfoNames.clear();
|
||||
vfoNamesTxt.clear();
|
||||
int id = 0;
|
||||
for (auto& [name, vfo] : gui::waterfall.vfos) {
|
||||
vfoNames.push_back(name);
|
||||
vfoNamesTxt += name;
|
||||
vfoNamesTxt += '\0';
|
||||
if (name == vfoName) {
|
||||
vfoNameId = id;
|
||||
}
|
||||
id++;
|
||||
}
|
||||
|
||||
// If VFO not found, reset the name
|
||||
if (id < 0 && !vfoNames.empty()) {
|
||||
vfoNameId = 0;
|
||||
}
|
||||
|
||||
// Search ID of the tuning mode
|
||||
tuningModeId = -1;
|
||||
for (int i = 0; i < tuningModeCount; i++) {
|
||||
if (tuningModes[i] == tuningMode) {
|
||||
tuningModeId = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tuningModeId < 0) {
|
||||
tuningModeId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool showEditMenu(bool& valid) {
|
||||
ImGui::LeftLabel("VFO");
|
||||
ImGui::SetNextItemWidth(250 - ImGui::GetCursorPosX());
|
||||
ImGui::Combo("##scheduler_action_tunevfo_edit_vfo", &vfoNameId, vfoNamesTxt.c_str());
|
||||
|
||||
ImGui::LeftLabel("Frequency");
|
||||
ImGui::SetNextItemWidth(250 - ImGui::GetCursorPosX());
|
||||
ImGui::InputDouble("Hz##scheduler_action_tunevfo_edit_freq", &tmpFrequency);
|
||||
|
||||
ImGui::LeftLabel("Tuning Mode");
|
||||
ImGui::SetNextItemWidth(250 - ImGui::GetCursorPosX());
|
||||
ImGui::Combo("##scheduler_action_tunevfo_edit_tmode", &tuningModeId, tuningModesTxt.c_str());
|
||||
|
||||
if (ImGui::Button("Apply")) {
|
||||
vfoName = vfoNames[vfoNameId];
|
||||
frequency = tmpFrequency;
|
||||
tuningMode = tuningModes[tuningModeId];
|
||||
valid = true;
|
||||
return false;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Cancel")) {
|
||||
valid = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void loadFromConfig(json config) {
|
||||
if (config.contains("vfo")) { vfoName = config["vfo"]; }
|
||||
if (config.contains("frequency")) { frequency = config["frequency"]; }
|
||||
if (config.contains("tuningMode")) { tuningMode = config["tuningMode"]; }
|
||||
|
||||
name = "Tune \"" + vfoName + "\" to " + utils::formatFreq(frequency);
|
||||
}
|
||||
|
||||
json saveToConfig() {
|
||||
json config;
|
||||
config["vfo"] = vfoName;
|
||||
config["frequency"] = frequency;
|
||||
config["tuningMode"] = tuningMode;
|
||||
return config;
|
||||
}
|
||||
|
||||
std::string getName() {
|
||||
return "Tune \"" + vfoName + "\" to " + utils::formatFreq(frequency);
|
||||
}
|
||||
|
||||
bool isValid() {
|
||||
return valid;
|
||||
return name;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string vfoName;
|
||||
double frequency;
|
||||
bool valid = false;
|
||||
std::string tuningModesTxt;
|
||||
std::vector<std::string> vfoNames;
|
||||
std::string vfoNamesTxt;
|
||||
|
||||
std::string vfoName = "";
|
||||
double frequency = 0;
|
||||
int tuningMode = 0;
|
||||
|
||||
double tmpFrequency;
|
||||
int tuningModeId;
|
||||
|
||||
int vfoNameId = -1;
|
||||
|
||||
std::string name;
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user