mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-25 20:07:51 +02:00
Formatted the entire codebase and added a CI check for formatting
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
#include <module.h>
|
||||
#include <gui/gui.h>
|
||||
|
||||
SDRPP_MOD_INFO {
|
||||
SDRPP_MOD_INFO{
|
||||
/* Name: */ "demo",
|
||||
/* Description: */ "My fancy new module",
|
||||
/* Author: */ "author1;author2,author3,etc...",
|
||||
@ -43,7 +43,6 @@ private:
|
||||
|
||||
std::string name;
|
||||
bool enabled = true;
|
||||
|
||||
};
|
||||
|
||||
MOD_EXPORT void _INIT_() {
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <thread>
|
||||
#include <radio_interface.h>
|
||||
|
||||
SDRPP_MOD_INFO {
|
||||
SDRPP_MOD_INFO{
|
||||
/* Name: */ "discord_integration",
|
||||
/* Description: */ "Discord Rich Presence module for SDR++",
|
||||
/* Author: */ "Cam K.;Ryzerth",
|
||||
@ -16,7 +16,7 @@ SDRPP_MOD_INFO {
|
||||
/* Max instances */ 1
|
||||
};
|
||||
|
||||
#define DISCORD_APP_ID "834590435708108860"
|
||||
#define DISCORD_APP_ID "834590435708108860"
|
||||
|
||||
class DiscordIntegrationModule : public ModuleManager::Instance {
|
||||
public:
|
||||
@ -61,14 +61,13 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// Main thread
|
||||
void worker() {
|
||||
// TODO: Switch out for condition variable to terminate thread instantly
|
||||
// OR even better, the new timer class that I still need to add
|
||||
while (workerRunning) {
|
||||
workerCounter++;
|
||||
if(workerCounter >= 1000) {
|
||||
if (workerCounter >= 1000) {
|
||||
workerCounter = 0;
|
||||
updatePresence();
|
||||
}
|
||||
@ -87,15 +86,27 @@ private:
|
||||
int modeNum;
|
||||
core::modComManager.callInterface(selectedName, RADIO_IFACE_CMD_GET_MODE, NULL, &modeNum);
|
||||
if (modeNum == RADIO_IFACE_MODE_NFM) { strcpy(mode, "NFM"); }
|
||||
else if (modeNum == RADIO_IFACE_MODE_WFM) { strcpy(mode, "FM"); }
|
||||
else if (modeNum == RADIO_IFACE_MODE_AM) { strcpy(mode, "AM"); }
|
||||
else if (modeNum == RADIO_IFACE_MODE_DSB) { strcpy(mode, "DSB"); }
|
||||
else if (modeNum == RADIO_IFACE_MODE_USB) { strcpy(mode, "USB"); }
|
||||
else if (modeNum == RADIO_IFACE_MODE_CW) { strcpy(mode, "CW"); }
|
||||
else if (modeNum == RADIO_IFACE_MODE_LSB) { strcpy(mode, "LSB"); }
|
||||
else if (modeNum == RADIO_IFACE_MODE_WFM) {
|
||||
strcpy(mode, "FM");
|
||||
}
|
||||
else if (modeNum == RADIO_IFACE_MODE_AM) {
|
||||
strcpy(mode, "AM");
|
||||
}
|
||||
else if (modeNum == RADIO_IFACE_MODE_DSB) {
|
||||
strcpy(mode, "DSB");
|
||||
}
|
||||
else if (modeNum == RADIO_IFACE_MODE_USB) {
|
||||
strcpy(mode, "USB");
|
||||
}
|
||||
else if (modeNum == RADIO_IFACE_MODE_CW) {
|
||||
strcpy(mode, "CW");
|
||||
}
|
||||
else if (modeNum == RADIO_IFACE_MODE_LSB) {
|
||||
strcpy(mode, "LSB");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (selectedFreq != lastFreq || mode != lastMode) {
|
||||
lastFreq = selectedFreq;
|
||||
lastMode = mode;
|
||||
@ -146,7 +157,6 @@ private:
|
||||
int workerCounter = 0;
|
||||
std::thread workerThread;
|
||||
bool workerRunning;
|
||||
|
||||
};
|
||||
|
||||
MOD_EXPORT void _INIT_() {
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include <utils/freq_formatting.h>
|
||||
#include <gui/dialogs/dialog_box.h>
|
||||
|
||||
SDRPP_MOD_INFO {
|
||||
SDRPP_MOD_INFO{
|
||||
/* Name: */ "frequency_manager",
|
||||
/* Description: */ "Frequency manager module for SDR++",
|
||||
/* Author: */ "Ryzerth;Zimm",
|
||||
@ -104,7 +104,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
static void applyBookmark(FrequencyBookmark bm, std::string vfoName) {
|
||||
if (vfoName == "") {
|
||||
// TODO: Replace with proper tune call
|
||||
@ -135,14 +134,14 @@ private:
|
||||
strcpy(nameBuf, editedBookmarkName.c_str());
|
||||
|
||||
if (ImGui::BeginPopup(id.c_str(), ImGuiWindowFlags_NoResize)) {
|
||||
ImGui::BeginTable(("freq_manager_edit_table"+name).c_str(), 2);
|
||||
|
||||
ImGui::BeginTable(("freq_manager_edit_table" + name).c_str(), 2);
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::LeftLabel("Name");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::SetNextItemWidth(200);
|
||||
if (ImGui::InputText(("##freq_manager_edit_name"+name).c_str(), nameBuf, 1023)) {
|
||||
if (ImGui::InputText(("##freq_manager_edit_name" + name).c_str(), nameBuf, 1023)) {
|
||||
editedBookmarkName = nameBuf;
|
||||
}
|
||||
|
||||
@ -151,14 +150,14 @@ private:
|
||||
ImGui::LeftLabel("Frequency");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::SetNextItemWidth(200);
|
||||
ImGui::InputDouble(("##freq_manager_edit_freq"+name).c_str(), &editedBookmark.frequency);
|
||||
ImGui::InputDouble(("##freq_manager_edit_freq" + name).c_str(), &editedBookmark.frequency);
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::LeftLabel("Bandwidth");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::SetNextItemWidth(200);
|
||||
ImGui::InputDouble(("##freq_manager_edit_bw"+name).c_str(), &editedBookmark.bandwidth);
|
||||
ImGui::InputDouble(("##freq_manager_edit_bw" + name).c_str(), &editedBookmark.bandwidth);
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
@ -166,7 +165,7 @@ private:
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::SetNextItemWidth(200);
|
||||
|
||||
ImGui::Combo(("##freq_manager_edit_mode"+name).c_str(), &editedBookmark.mode, demodModeListTxt);
|
||||
ImGui::Combo(("##freq_manager_edit_mode" + name).c_str(), &editedBookmark.mode, demodModeListTxt);
|
||||
|
||||
ImGui::EndTable();
|
||||
|
||||
@ -174,7 +173,7 @@ private:
|
||||
if (applyDisabled) { style::beginDisabled(); }
|
||||
if (ImGui::Button("Apply")) {
|
||||
open = false;
|
||||
|
||||
|
||||
// If editing, delete the original one
|
||||
if (editOpen) {
|
||||
bookmarks.erase(firstEditedBookmarkName);
|
||||
@ -208,7 +207,7 @@ private:
|
||||
if (ImGui::BeginPopup(id.c_str(), ImGuiWindowFlags_NoResize)) {
|
||||
ImGui::LeftLabel("Name");
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::InputText(("##freq_manager_edit_name"+name).c_str(), nameBuf, 1023)) {
|
||||
if (ImGui::InputText(("##freq_manager_edit_name" + name).c_str(), nameBuf, 1023)) {
|
||||
editedListName = nameBuf;
|
||||
}
|
||||
|
||||
@ -256,7 +255,7 @@ private:
|
||||
// No need to lock config since we're not modifying anything and there's only one instance
|
||||
for (auto [listName, list] : config.conf["lists"].items()) {
|
||||
bool shown = list["showOnWaterfall"];
|
||||
if (ImGui::Checkbox((listName+"##freq_manager_sel_list_").c_str(), &shown)) {
|
||||
if (ImGui::Checkbox((listName + "##freq_manager_sel_list_").c_str(), &shown)) {
|
||||
config.acquire();
|
||||
config.conf["lists"][listName]["showOnWaterfall"] = shown;
|
||||
refreshWaterfallBookmarks(false);
|
||||
@ -353,13 +352,15 @@ private:
|
||||
|
||||
// TODO: Replace with something that won't iterate every frame
|
||||
std::vector<std::string> selectedNames;
|
||||
for (auto& [name, bm] : _this->bookmarks) { if (bm.selected) { selectedNames.push_back(name); } }
|
||||
for (auto& [name, bm] : _this->bookmarks) {
|
||||
if (bm.selected) { selectedNames.push_back(name); }
|
||||
}
|
||||
|
||||
float lineHeight = ImGui::GetTextLineHeightWithSpacing();
|
||||
|
||||
float btnSize = ImGui::CalcTextSize("Rename").x + 8;
|
||||
ImGui::SetNextItemWidth(menuWidth - 24 - (2*lineHeight) - btnSize);
|
||||
if (ImGui::Combo(("##freq_manager_list_sel"+_this->name).c_str(), &_this->selectedListId, _this->listNamesTxt.c_str())) {
|
||||
ImGui::SetNextItemWidth(menuWidth - 24 - (2 * lineHeight) - btnSize);
|
||||
if (ImGui::Combo(("##freq_manager_list_sel" + _this->name).c_str(), &_this->selectedListId, _this->listNamesTxt.c_str())) {
|
||||
_this->loadByName(_this->listNames[_this->selectedListId]);
|
||||
config.acquire();
|
||||
config.conf["selectedList"] = _this->selectedListName;
|
||||
@ -397,9 +398,9 @@ private:
|
||||
if (_this->selectedListName == "") { style::endDisabled(); }
|
||||
|
||||
// List delete confirmation
|
||||
if (ImGui::GenericDialog(("freq_manager_del_list_confirm"+_this->name).c_str(), _this->deleteListOpen, GENERIC_DIALOG_BUTTONS_YES_NO, [_this](){
|
||||
ImGui::Text("Deleting list named \"%s\". Are you sure?", _this->selectedListName.c_str());
|
||||
}) == GENERIC_DIALOG_BUTTON_YES) {
|
||||
if (ImGui::GenericDialog(("freq_manager_del_list_confirm" + _this->name).c_str(), _this->deleteListOpen, GENERIC_DIALOG_BUTTONS_YES_NO, [_this]() {
|
||||
ImGui::Text("Deleting list named \"%s\". Are you sure?", _this->selectedListName.c_str());
|
||||
}) == GENERIC_DIALOG_BUTTON_YES) {
|
||||
config.acquire();
|
||||
config.conf["lists"].erase(_this->selectedListName);
|
||||
_this->refreshWaterfallBookmarks(false);
|
||||
@ -413,10 +414,10 @@ private:
|
||||
_this->selectedListName = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (_this->selectedListName == "") { style::beginDisabled(); }
|
||||
//Draw buttons on top of the list
|
||||
ImGui::BeginTable(("freq_manager_btn_table"+_this->name).c_str(), 3);
|
||||
ImGui::BeginTable(("freq_manager_btn_table" + _this->name).c_str(), 3);
|
||||
ImGui::TableNextRow();
|
||||
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
@ -471,20 +472,20 @@ private:
|
||||
_this->firstEditedBookmarkName = selectedNames[0];
|
||||
}
|
||||
if (selectedNames.size() != 1 && _this->selectedListName != "") { style::endDisabled(); }
|
||||
|
||||
|
||||
ImGui::EndTable();
|
||||
|
||||
// Bookmark delete confirm dialog
|
||||
// List delete confirmation
|
||||
if (ImGui::GenericDialog(("freq_manager_del_list_confirm"+_this->name).c_str(), _this->deleteBookmarksOpen, GENERIC_DIALOG_BUTTONS_YES_NO, [_this](){
|
||||
ImGui::Text("Deleting selected bookmaks. Are you sure?");
|
||||
}) == GENERIC_DIALOG_BUTTON_YES) {
|
||||
if (ImGui::GenericDialog(("freq_manager_del_list_confirm" + _this->name).c_str(), _this->deleteBookmarksOpen, GENERIC_DIALOG_BUTTONS_YES_NO, [_this]() {
|
||||
ImGui::Text("Deleting selected bookmaks. Are you sure?");
|
||||
}) == GENERIC_DIALOG_BUTTON_YES) {
|
||||
for (auto& _name : selectedNames) { _this->bookmarks.erase(_name); }
|
||||
_this->saveByName(_this->selectedListName);
|
||||
}
|
||||
|
||||
// Bookmark list
|
||||
if (ImGui::BeginTable(("freq_manager_bkm_table"+_this->name).c_str(), 2, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY, ImVec2(0, 200))) {
|
||||
if (ImGui::BeginTable(("freq_manager_bkm_table" + _this->name).c_str(), 2, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY, ImVec2(0, 200))) {
|
||||
ImGui::TableSetupColumn("Name");
|
||||
ImGui::TableSetupColumn("Bookmark");
|
||||
ImGui::TableSetupScrollFreeze(2, 1);
|
||||
@ -514,7 +515,7 @@ private:
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (selectedNames.size() != 1 && _this->selectedListName != "") { style::beginDisabled(); }
|
||||
if (ImGui::Button(("Apply##_freq_mgr_apply_" + _this->name).c_str(), ImVec2(menuWidth, 0))) {
|
||||
@ -525,13 +526,13 @@ private:
|
||||
if (selectedNames.size() != 1 && _this->selectedListName != "") { style::endDisabled(); }
|
||||
|
||||
//Draw import and export buttons
|
||||
ImGui::BeginTable(("freq_manager_bottom_btn_table"+_this->name).c_str(), 2);
|
||||
ImGui::BeginTable(("freq_manager_bottom_btn_table" + _this->name).c_str(), 2);
|
||||
ImGui::TableNextRow();
|
||||
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
if (ImGui::Button(("Import##_freq_mgr_imp_" + _this->name).c_str(), ImVec2(ImGui::GetContentRegionAvailWidth(), 0)) && !_this->importOpen) {
|
||||
_this->importOpen = true;
|
||||
_this->importDialog = new pfd::open_file("Import bookmarks", "", {"JSON Files (*.json)", "*.json", "All Files", "*"}, true);
|
||||
_this->importDialog = new pfd::open_file("Import bookmarks", "", { "JSON Files (*.json)", "*.json", "All Files", "*" }, true);
|
||||
}
|
||||
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
@ -544,7 +545,7 @@ private:
|
||||
}
|
||||
config.release();
|
||||
_this->exportOpen = true;
|
||||
_this->exportDialog = new pfd::save_file("Export bookmarks", "", {"JSON Files (*.json)", "*.json", "All Files", "*"}, true);
|
||||
_this->exportDialog = new pfd::save_file("Export bookmarks", "", { "JSON Files (*.json)", "*.json", "All Files", "*" }, true);
|
||||
}
|
||||
if (selectedNames.size() == 0 && _this->selectedListName != "") { style::endDisabled(); }
|
||||
ImGui::EndTable();
|
||||
@ -606,17 +607,17 @@ private:
|
||||
FrequencyManagerModule* _this = (FrequencyManagerModule*)ctx;
|
||||
if (_this->bookmarkDisplayMode == BOOKMARK_DISP_MODE_OFF) { return; }
|
||||
|
||||
if (_this->bookmarkDisplayMode == BOOKMARK_DISP_MODE_TOP) {
|
||||
if (_this->bookmarkDisplayMode == BOOKMARK_DISP_MODE_TOP) {
|
||||
for (auto const bm : _this->waterfallBookmarks) {
|
||||
double centerXpos = args.min.x + std::round((bm.bookmark.frequency - args.lowFreq) * args.freqToPixelRatio);
|
||||
|
||||
|
||||
if (bm.bookmark.frequency >= args.lowFreq && bm.bookmark.frequency <= args.highFreq) {
|
||||
args.window->DrawList->AddLine(ImVec2(centerXpos, args.min.y), ImVec2(centerXpos, args.max.y), IM_COL32(255, 255, 0, 255));
|
||||
}
|
||||
|
||||
ImVec2 nameSize = ImGui::CalcTextSize(bm.bookmarkName.c_str());
|
||||
ImVec2 rectMin = ImVec2(centerXpos-(nameSize.x/2)-5, args.min.y);
|
||||
ImVec2 rectMax = ImVec2(centerXpos+(nameSize.x/2)+5, args.min.y+nameSize.y);
|
||||
ImVec2 rectMin = ImVec2(centerXpos - (nameSize.x / 2) - 5, args.min.y);
|
||||
ImVec2 rectMax = ImVec2(centerXpos + (nameSize.x / 2) + 5, args.min.y + nameSize.y);
|
||||
ImVec2 clampedRectMin = ImVec2(std::clamp<double>(rectMin.x, args.min.x, args.max.x), rectMin.y);
|
||||
ImVec2 clampedRectMax = ImVec2(std::clamp<double>(rectMax.x, args.min.x, args.max.x), rectMax.y);
|
||||
|
||||
@ -624,21 +625,21 @@ private:
|
||||
args.window->DrawList->AddRectFilled(clampedRectMin, clampedRectMax, IM_COL32(255, 255, 0, 255));
|
||||
}
|
||||
if (rectMin.x >= args.min.x && rectMax.x <= args.max.x) {
|
||||
args.window->DrawList->AddText(ImVec2(centerXpos-(nameSize.x/2), args.min.y), IM_COL32(0, 0, 0, 255), bm.bookmarkName.c_str());
|
||||
args.window->DrawList->AddText(ImVec2(centerXpos - (nameSize.x / 2), args.min.y), IM_COL32(0, 0, 0, 255), bm.bookmarkName.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_this->bookmarkDisplayMode == BOOKMARK_DISP_MODE_BOTTOM) {
|
||||
for (auto const bm : _this->waterfallBookmarks) {
|
||||
double centerXpos = args.min.x + std::round((bm.bookmark.frequency - args.lowFreq) * args.freqToPixelRatio);
|
||||
|
||||
|
||||
if (bm.bookmark.frequency >= args.lowFreq && bm.bookmark.frequency <= args.highFreq) {
|
||||
args.window->DrawList->AddLine(ImVec2(centerXpos, args.min.y), ImVec2(centerXpos, args.max.y), IM_COL32(255, 255, 0, 255));
|
||||
}
|
||||
|
||||
ImVec2 nameSize = ImGui::CalcTextSize(bm.bookmarkName.c_str());
|
||||
ImVec2 rectMin = ImVec2(centerXpos-(nameSize.x/2)-5, args.max.y - nameSize.y);
|
||||
ImVec2 rectMax = ImVec2(centerXpos+(nameSize.x/2)+5, args.max.y);
|
||||
ImVec2 rectMin = ImVec2(centerXpos - (nameSize.x / 2) - 5, args.max.y - nameSize.y);
|
||||
ImVec2 rectMax = ImVec2(centerXpos + (nameSize.x / 2) + 5, args.max.y);
|
||||
ImVec2 clampedRectMin = ImVec2(std::clamp<double>(rectMin.x, args.min.x, args.max.x), rectMin.y);
|
||||
ImVec2 clampedRectMax = ImVec2(std::clamp<double>(rectMax.x, args.min.x, args.max.x), rectMax.y);
|
||||
|
||||
@ -646,10 +647,10 @@ private:
|
||||
args.window->DrawList->AddRectFilled(clampedRectMin, clampedRectMax, IM_COL32(255, 255, 0, 255));
|
||||
}
|
||||
if (rectMin.x >= args.min.x && rectMax.x <= args.max.x) {
|
||||
args.window->DrawList->AddText(ImVec2(centerXpos-(nameSize.x/2), args.max.y - nameSize.y), IM_COL32(0, 0, 0, 255), bm.bookmarkName.c_str());
|
||||
args.window->DrawList->AddText(ImVec2(centerXpos - (nameSize.x / 2), args.max.y - nameSize.y), IM_COL32(0, 0, 0, 255), bm.bookmarkName.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool mouseAlreadyDown = false;
|
||||
@ -673,12 +674,12 @@ private:
|
||||
|
||||
if (_this->bookmarkDisplayMode == BOOKMARK_DISP_MODE_TOP) {
|
||||
int count = _this->waterfallBookmarks.size();
|
||||
for (int i = count-1; i >= 0; i--) {
|
||||
for (int i = count - 1; i >= 0; i--) {
|
||||
auto& bm = _this->waterfallBookmarks[i];
|
||||
double centerXpos = args.fftRectMin.x + std::round((bm.bookmark.frequency - args.lowFreq) * args.freqToPixelRatio);
|
||||
ImVec2 nameSize = ImGui::CalcTextSize(bm.bookmarkName.c_str());
|
||||
ImVec2 rectMin = ImVec2(centerXpos-(nameSize.x/2)-5, args.fftRectMin.y);
|
||||
ImVec2 rectMax = ImVec2(centerXpos+(nameSize.x/2)+5, args.fftRectMin.y+nameSize.y);
|
||||
ImVec2 rectMin = ImVec2(centerXpos - (nameSize.x / 2) - 5, args.fftRectMin.y);
|
||||
ImVec2 rectMax = ImVec2(centerXpos + (nameSize.x / 2) + 5, args.fftRectMin.y + nameSize.y);
|
||||
ImVec2 clampedRectMin = ImVec2(std::clamp<double>(rectMin.x, args.fftRectMin.x, args.fftRectMax.x), rectMin.y);
|
||||
ImVec2 clampedRectMax = ImVec2(std::clamp<double>(rectMax.x, args.fftRectMin.x, args.fftRectMax.x), rectMax.y);
|
||||
|
||||
@ -692,12 +693,12 @@ private:
|
||||
}
|
||||
else if (_this->bookmarkDisplayMode == BOOKMARK_DISP_MODE_BOTTOM) {
|
||||
int count = _this->waterfallBookmarks.size();
|
||||
for (int i = count-1; i >= 0; i--) {
|
||||
for (int i = count - 1; i >= 0; i--) {
|
||||
auto& bm = _this->waterfallBookmarks[i];
|
||||
double centerXpos = args.fftRectMin.x + std::round((bm.bookmark.frequency - args.lowFreq) * args.freqToPixelRatio);
|
||||
ImVec2 nameSize = ImGui::CalcTextSize(bm.bookmarkName.c_str());
|
||||
ImVec2 rectMin = ImVec2(centerXpos-(nameSize.x/2)-5, args.fftRectMax.y-nameSize.y);
|
||||
ImVec2 rectMax = ImVec2(centerXpos+(nameSize.x/2)+5, args.fftRectMax.y);
|
||||
ImVec2 rectMin = ImVec2(centerXpos - (nameSize.x / 2) - 5, args.fftRectMax.y - nameSize.y);
|
||||
ImVec2 rectMax = ImVec2(centerXpos + (nameSize.x / 2) + 5, args.fftRectMax.y);
|
||||
ImVec2 clampedRectMin = ImVec2(std::clamp<double>(rectMin.x, args.fftRectMin.x, args.fftRectMax.x), rectMin.y);
|
||||
ImVec2 clampedRectMax = ImVec2(std::clamp<double>(rectMax.x, args.fftRectMin.x, args.fftRectMax.x), rectMax.y);
|
||||
|
||||
@ -726,8 +727,8 @@ private:
|
||||
|
||||
double centerXpos = args.fftRectMin.x + std::round((hoveredBookmark.bookmark.frequency - args.lowFreq) * args.freqToPixelRatio);
|
||||
ImVec2 nameSize = ImGui::CalcTextSize(hoveredBookmarkName.c_str());
|
||||
ImVec2 rectMin = ImVec2(centerXpos-(nameSize.x/2)-5, (_this->bookmarkDisplayMode == BOOKMARK_DISP_MODE_BOTTOM) ? (args.fftRectMax.y - nameSize.y) : args.fftRectMin.y);
|
||||
ImVec2 rectMax = ImVec2(centerXpos+(nameSize.x/2)+5, (_this->bookmarkDisplayMode == BOOKMARK_DISP_MODE_BOTTOM) ? args.fftRectMax.y : args.fftRectMin.y+nameSize.y);
|
||||
ImVec2 rectMin = ImVec2(centerXpos - (nameSize.x / 2) - 5, (_this->bookmarkDisplayMode == BOOKMARK_DISP_MODE_BOTTOM) ? (args.fftRectMax.y - nameSize.y) : args.fftRectMin.y);
|
||||
ImVec2 rectMax = ImVec2(centerXpos + (nameSize.x / 2) + 5, (_this->bookmarkDisplayMode == BOOKMARK_DISP_MODE_BOTTOM) ? args.fftRectMax.y : args.fftRectMin.y + nameSize.y);
|
||||
ImVec2 clampedRectMin = ImVec2(std::clamp<double>(rectMin.x, args.fftRectMin.x, args.fftRectMax.x), rectMin.y);
|
||||
ImVec2 clampedRectMax = ImVec2(std::clamp<double>(rectMax.x, args.fftRectMin.x, args.fftRectMax.x), rectMax.y);
|
||||
|
||||
@ -822,7 +823,6 @@ private:
|
||||
std::vector<WaterfallBookmark> waterfallBookmarks;
|
||||
|
||||
int bookmarkDisplayMode = 0;
|
||||
|
||||
};
|
||||
|
||||
MOD_EXPORT void _INIT_() {
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <core.h>
|
||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
||||
|
||||
SDRPP_MOD_INFO {
|
||||
SDRPP_MOD_INFO{
|
||||
/* Name: */ "recorder",
|
||||
/* Description: */ "Recorder module for SDR++",
|
||||
/* Author: */ "Ryzerth",
|
||||
@ -36,9 +36,10 @@ std::string expandString(std::string input) {
|
||||
|
||||
std::string genFileName(std::string prefix, bool isVfo, std::string name = "") {
|
||||
time_t now = time(0);
|
||||
tm *ltm = localtime(&now);
|
||||
tm* ltm = localtime(&now);
|
||||
char buf[1024];
|
||||
double freq = gui::waterfall.getCenterFrequency();;
|
||||
double freq = gui::waterfall.getCenterFrequency();
|
||||
;
|
||||
if (isVfo && gui::waterfall.vfos.find(name) != gui::waterfall.vfos.end()) {
|
||||
freq += gui::waterfall.vfos[name]->generalOffset;
|
||||
}
|
||||
@ -49,12 +50,12 @@ std::string genFileName(std::string prefix, bool isVfo, std::string name = "") {
|
||||
class RecorderModule : public ModuleManager::Instance {
|
||||
public:
|
||||
RecorderModule(std::string name) : folderSelect("%ROOT%/recordings") {
|
||||
this->name = name;
|
||||
this->name = name;
|
||||
|
||||
// Load config
|
||||
config.acquire();
|
||||
bool created = false;
|
||||
|
||||
|
||||
// Create config if it doesn't exist
|
||||
if (!config.conf.contains(name)) {
|
||||
config.conf[name]["mode"] = RECORDER_MODE_AUDIO;
|
||||
@ -108,7 +109,7 @@ public:
|
||||
std::lock_guard lck(recMtx);
|
||||
gui::menu.removeEntry(name);
|
||||
core::modComManager.unregisterInterface(name);
|
||||
|
||||
|
||||
// Stop recording
|
||||
if (recording) { stopRecording(); }
|
||||
|
||||
@ -156,7 +157,7 @@ private:
|
||||
streamNamesTxt = "";
|
||||
|
||||
// If there are no stream, cancel
|
||||
if (names.size() == 0) {return; }
|
||||
if (names.size() == 0) { return; }
|
||||
|
||||
// List streams
|
||||
for (auto const& name : names) {
|
||||
@ -249,7 +250,7 @@ private:
|
||||
}
|
||||
uint64_t seconds = samplesWritten / (uint64_t)sampleRate;
|
||||
time_t diff = seconds;
|
||||
tm *dtm = gmtime(&diff);
|
||||
tm* dtm = gmtime(&diff);
|
||||
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "Recording %02d:%02d:%02d", dtm->tm_hour, dtm->tm_min, dtm->tm_sec);
|
||||
}
|
||||
if (!folderSelect.pathIsValid()) { style::endDisabled(); }
|
||||
@ -305,22 +306,22 @@ private:
|
||||
}
|
||||
uint64_t seconds = samplesWritten / (uint64_t)sampleRate;
|
||||
time_t diff = seconds;
|
||||
tm *dtm = gmtime(&diff);
|
||||
tm* dtm = gmtime(&diff);
|
||||
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "Recording %02d:%02d:%02d", dtm->tm_hour, dtm->tm_min, dtm->tm_sec);
|
||||
}
|
||||
if (!folderSelect.pathIsValid() || selectedStreamName == "") { style::endDisabled(); }
|
||||
}
|
||||
|
||||
static void _audioHandler(dsp::stereo_t *data, int count, void *ctx) {
|
||||
static void _audioHandler(dsp::stereo_t* data, int count, void* ctx) {
|
||||
RecorderModule* _this = (RecorderModule*)ctx;
|
||||
volk_32f_s32f_convert_16i(_this->wavSampleBuf, (float*)data, 32767.0f, count*2);
|
||||
volk_32f_s32f_convert_16i(_this->wavSampleBuf, (float*)data, 32767.0f, count * 2);
|
||||
_this->audioWriter->writeSamples(_this->wavSampleBuf, count * 2 * sizeof(int16_t));
|
||||
_this->samplesWritten += count;
|
||||
}
|
||||
|
||||
static void _basebandHandler(dsp::complex_t *data, int count, void *ctx) {
|
||||
static void _basebandHandler(dsp::complex_t* data, int count, void* ctx) {
|
||||
RecorderModule* _this = (RecorderModule*)ctx;
|
||||
volk_32f_s32f_convert_16i(_this->wavSampleBuf, (float*)data, 32767.0f, count*2);
|
||||
volk_32f_s32f_convert_16i(_this->wavSampleBuf, (float*)data, 32767.0f, count * 2);
|
||||
_this->basebandWriter->writeSamples(_this->wavSampleBuf, count * 2 * sizeof(int16_t));
|
||||
_this->samplesWritten += count;
|
||||
}
|
||||
@ -364,7 +365,7 @@ private:
|
||||
else if (recMode == RECORDER_MODE_AUDIO) {
|
||||
if (selectedStreamName.empty()) {
|
||||
spdlog::error("Cannot record with no selected stream");
|
||||
}
|
||||
}
|
||||
samplesWritten = 0;
|
||||
std::string expandedPath = expandString(folderSelect.path + genFileName("/audio_", true, selectedStreamName));
|
||||
sampleRate = sigpath::sinkManager.getStreamSampleRate(selectedStreamName);
|
||||
@ -398,7 +399,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
static void onStreamRegistered(std::string name, void* ctx){
|
||||
static void onStreamRegistered(std::string name, void* ctx) {
|
||||
RecorderModule* _this = (RecorderModule*)ctx;
|
||||
_this->refreshStreams();
|
||||
|
||||
@ -423,7 +424,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
static void onStreamUnregister(std::string name, void* ctx){
|
||||
static void onStreamUnregister(std::string name, void* ctx) {
|
||||
RecorderModule* _this = (RecorderModule*)ctx;
|
||||
if (name != _this->selectedStreamName) { return; }
|
||||
if (_this->recording) { _this->stopRecording(); }
|
||||
@ -434,7 +435,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
static void onStreamUnregistered(std::string name, void* ctx){
|
||||
static void onStreamUnregistered(std::string name, void* ctx) {
|
||||
RecorderModule* _this = (RecorderModule*)ctx;
|
||||
_this->refreshStreams();
|
||||
|
||||
@ -476,7 +477,7 @@ private:
|
||||
float lvlR = -90.0f;
|
||||
|
||||
dsp::stream<dsp::stereo_t> dummyStream;
|
||||
|
||||
|
||||
std::mutex recMtx;
|
||||
|
||||
FolderSelect folderSelect;
|
||||
@ -507,7 +508,6 @@ private:
|
||||
EventHandler<std::string> streamRegisteredHandler;
|
||||
EventHandler<std::string> streamUnregisterHandler;
|
||||
EventHandler<std::string> streamUnregisteredHandler;
|
||||
|
||||
};
|
||||
|
||||
struct RecorderContext_t {
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
file.write((char*)data, size);
|
||||
bytesWritten += size;
|
||||
}
|
||||
|
||||
|
||||
void close() {
|
||||
hdr.fileSize = bytesWritten + sizeof(WavHeader_t) - 8;
|
||||
hdr.dataSize = bytesWritten;
|
||||
@ -45,18 +45,18 @@ public:
|
||||
|
||||
private:
|
||||
struct WavHeader_t {
|
||||
char signature[4]; // "RIFF"
|
||||
uint32_t fileSize; // data bytes + sizeof(WavHeader_t) - 8
|
||||
char fileType[4]; // "WAVE"
|
||||
char formatMarker[4]; // "fmt "
|
||||
uint32_t formatHeaderLength; // Always 16
|
||||
uint16_t sampleType; // PCM (1)
|
||||
char signature[4]; // "RIFF"
|
||||
uint32_t fileSize; // data bytes + sizeof(WavHeader_t) - 8
|
||||
char fileType[4]; // "WAVE"
|
||||
char formatMarker[4]; // "fmt "
|
||||
uint32_t formatHeaderLength; // Always 16
|
||||
uint16_t sampleType; // PCM (1)
|
||||
uint16_t channelCount;
|
||||
uint32_t sampleRate;
|
||||
uint32_t bytesPerSecond;
|
||||
uint16_t bytesPerSample;
|
||||
uint16_t bitDepth;
|
||||
char dataMarker[4]; // "data"
|
||||
char dataMarker[4]; // "data"
|
||||
uint32_t dataSize;
|
||||
};
|
||||
|
||||
|
@ -13,9 +13,9 @@
|
||||
#include <radio_interface.h>
|
||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
||||
|
||||
#define MAX_COMMAND_LENGTH 8192
|
||||
#define MAX_COMMAND_LENGTH 8192
|
||||
|
||||
SDRPP_MOD_INFO {
|
||||
SDRPP_MOD_INFO{
|
||||
/* Name: */ "rigctl_server",
|
||||
/* Description: */ "My fancy new module",
|
||||
/* Author: */ "Ryzerth",
|
||||
@ -139,7 +139,7 @@ private:
|
||||
config.release(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ImGui::LeftLabel("Controlled Recorder");
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
{
|
||||
@ -175,7 +175,7 @@ private:
|
||||
config.conf[_this->name]["autoStart"] = _this->autoStart;
|
||||
config.release(true);
|
||||
}
|
||||
|
||||
|
||||
if (listening && ImGui::Button(CONCAT("Stop##_rigctl_srv_stop_", _this->name), ImVec2(menuWidth, 0))) {
|
||||
_this->stopServer();
|
||||
}
|
||||
@ -247,7 +247,7 @@ private:
|
||||
selectVfoByName(vfoNames[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Select the VFO
|
||||
{
|
||||
if (lock) { std::lock_guard lck(vfoMtx); }
|
||||
@ -271,8 +271,8 @@ private:
|
||||
}
|
||||
|
||||
std::string type = core::modComManager.getModuleName(_name);
|
||||
|
||||
|
||||
|
||||
|
||||
// Select the VFO
|
||||
{
|
||||
if (lock) { std::lock_guard lck(recorderMtx); }
|
||||
@ -483,7 +483,7 @@ private:
|
||||
core::modComManager.callInterface(selectedVfo, RADIO_IFACE_CMD_SET_BANDWIDTH, &newBandwidth, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
client->write(resp.size(), (uint8_t*)resp.c_str());
|
||||
}
|
||||
else if (parts[0] == "m" || parts[0] == "\\get_mode") {
|
||||
@ -493,7 +493,7 @@ private:
|
||||
if (!selectedVfo.empty() && core::modComManager.getModuleName(selectedVfo) == "radio") {
|
||||
int mode;
|
||||
core::modComManager.callInterface(selectedVfo, RADIO_IFACE_CMD_GET_MODE, NULL, &mode);
|
||||
|
||||
|
||||
if (mode == RADIO_IFACE_MODE_NFM) {
|
||||
resp = "FM\n";
|
||||
}
|
||||
@ -684,7 +684,7 @@ private:
|
||||
/* Bit field list of get level */
|
||||
"0x40000020\n" /* RIG_LEVEL_SQL | RIG_LEVEL_STRENGTH */
|
||||
/* Bit field list of set level */
|
||||
"0x20\n" /* RIG_LEVEL_SQL */
|
||||
"0x20\n" /* RIG_LEVEL_SQL */
|
||||
/* Bit field list of get parm */
|
||||
"0\n" /* RIG_PARM_NONE */
|
||||
/* Bit field list of set parm */
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <module.h>
|
||||
#include <gui/gui.h>
|
||||
|
||||
SDRPP_MOD_INFO {
|
||||
SDRPP_MOD_INFO{
|
||||
/* Name: */ "scanner",
|
||||
/* Description: */ "Frequency scanner for SDR++",
|
||||
/* Author: */ "Ryzerth",
|
||||
@ -43,7 +43,6 @@ private:
|
||||
|
||||
std::string name;
|
||||
bool enabled = true;
|
||||
|
||||
};
|
||||
|
||||
MOD_EXPORT void _INIT_() {
|
||||
|
@ -8,11 +8,9 @@ namespace sched_action {
|
||||
~StartRecorderClass() {}
|
||||
|
||||
void trigger() {
|
||||
|
||||
}
|
||||
|
||||
void prepareEditMenu() {
|
||||
|
||||
}
|
||||
|
||||
bool showEditMenu(bool& valid) {
|
||||
@ -40,7 +38,6 @@ namespace sched_action {
|
||||
std::string recorderName;
|
||||
|
||||
std::string name = "Start \"\"";
|
||||
|
||||
};
|
||||
|
||||
Action StartRecorder() {
|
||||
|
@ -138,7 +138,6 @@ namespace sched_action {
|
||||
int vfoNameId = -1;
|
||||
|
||||
std::string name;
|
||||
|
||||
};
|
||||
|
||||
Action TuneVFO() {
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <sched_task.h>
|
||||
#include <map>
|
||||
|
||||
SDRPP_MOD_INFO {
|
||||
SDRPP_MOD_INFO{
|
||||
/* Name: */ "scheduler",
|
||||
/* Description: */ "SDR++ Scheduler",
|
||||
/* Author: */ "Ryzerth",
|
||||
@ -23,7 +23,7 @@ public:
|
||||
|
||||
json recStartConfig;
|
||||
recStartConfig["recorder"] = "Recorder";
|
||||
|
||||
|
||||
json tuneVFOConfig;
|
||||
tuneVFOConfig["vfo"] = "Radio";
|
||||
tuneVFOConfig["frequency"] = 103500000.0;
|
||||
@ -62,7 +62,7 @@ public:
|
||||
private:
|
||||
static void menuHandler(void* ctx) {
|
||||
DemoModule* _this = (DemoModule*)ctx;
|
||||
|
||||
|
||||
// If editing, show menu
|
||||
if (!_this->editedTask.empty()) {
|
||||
gui::mainWindow.lockWaterfallControls = true;
|
||||
@ -89,7 +89,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::BeginTable(("freq_manager_bkm_table"+_this->name).c_str(), 2, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY, ImVec2(0, 200))) {
|
||||
if (ImGui::BeginTable(("freq_manager_bkm_table" + _this->name).c_str(), 2, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY, ImVec2(0, 200))) {
|
||||
ImGui::TableSetupColumn("Name");
|
||||
ImGui::TableSetupColumn("Countdown");
|
||||
ImGui::TableSetupScrollFreeze(2, 1);
|
||||
@ -127,7 +127,6 @@ private:
|
||||
char editedName[1024];
|
||||
|
||||
std::map<std::string, Task> tasks;
|
||||
|
||||
};
|
||||
|
||||
MOD_EXPORT void _INIT_() {
|
||||
|
@ -8,7 +8,7 @@ using namespace nlohmann;
|
||||
namespace sched_action {
|
||||
class ActionClass {
|
||||
public:
|
||||
virtual ~ActionClass() {};
|
||||
virtual ~ActionClass(){};
|
||||
virtual void trigger() = 0;
|
||||
virtual void prepareEditMenu() = 0;
|
||||
virtual bool showEditMenu(bool& valid) = 0;
|
||||
@ -21,12 +21,12 @@ namespace sched_action {
|
||||
}
|
||||
|
||||
bool selected = false;
|
||||
|
||||
|
||||
private:
|
||||
bool valid = false;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<ActionClass> Action;
|
||||
typedef std::shared_ptr<ActionClass> Action;
|
||||
}
|
||||
|
||||
#include <actions/start_recorder.h>
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
ImGui::TableSetupColumn("Triggers");
|
||||
ImGui::TableSetupScrollFreeze(1, 1);
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
|
||||
// Fill rows here
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
@ -119,5 +119,4 @@ private:
|
||||
std::vector<sched_action::Action> actions;
|
||||
|
||||
int editedAction = -1;
|
||||
|
||||
};
|
Reference in New Issue
Block a user