mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-01-24 00:34:44 +01:00
Added persistant settings to recorder module
This commit is contained in:
parent
9b1c9e9e29
commit
2c729bf646
@ -5,6 +5,8 @@
|
|||||||
#include <imutils.h>
|
#include <imutils.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
float COLOR_MAP[][3] = {
|
float COLOR_MAP[][3] = {
|
||||||
{0x00, 0x00, 0x20},
|
{0x00, 0x00, 0x20},
|
||||||
{0x00, 0x00, 0x30},
|
{0x00, 0x00, 0x30},
|
||||||
@ -152,9 +154,6 @@ namespace ImGui {
|
|||||||
for (int i = 1; i < dataWidth; i++) {
|
for (int i = 1; i < dataWidth; i++) {
|
||||||
double aPos = widgetPos.y + fftHeight + 10 - ((latestFFT[i - 1] - fftMin) * scaleFactor);
|
double aPos = widgetPos.y + fftHeight + 10 - ((latestFFT[i - 1] - fftMin) * scaleFactor);
|
||||||
double bPos = widgetPos.y + fftHeight + 10 - ((latestFFT[i] - fftMin) * scaleFactor);
|
double bPos = widgetPos.y + fftHeight + 10 - ((latestFFT[i] - fftMin) * scaleFactor);
|
||||||
if (aPos < fftMin && bPos < fftMin) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
aPos = std::clamp<double>(aPos, widgetPos.y + 10, widgetPos.y + fftHeight + 10);
|
aPos = std::clamp<double>(aPos, widgetPos.y + 10, widgetPos.y + fftHeight + 10);
|
||||||
bPos = std::clamp<double>(bPos, widgetPos.y + 10, widgetPos.y + fftHeight + 10);
|
bPos = std::clamp<double>(bPos, widgetPos.y + 10, widgetPos.y + fftHeight + 10);
|
||||||
window->DrawList->AddLine(ImVec2(widgetPos.x + 49 + i, roundf(aPos)),
|
window->DrawList->AddLine(ImVec2(widgetPos.x + 49 + i, roundf(aPos)),
|
||||||
|
@ -25,6 +25,8 @@ SDRPP_MOD_INFO {
|
|||||||
|
|
||||||
// TODO: Fix this and finish module
|
// TODO: Fix this and finish module
|
||||||
|
|
||||||
|
ConfigManager config;
|
||||||
|
|
||||||
std::string genFileName(std::string prefix) {
|
std::string genFileName(std::string prefix) {
|
||||||
time_t now = time(0);
|
time_t now = time(0);
|
||||||
tm *ltm = localtime(&now);
|
tm *ltm = localtime(&now);
|
||||||
@ -54,7 +56,17 @@ public:
|
|||||||
selectedStreamName = "";
|
selectedStreamName = "";
|
||||||
selectedStreamId = 0;
|
selectedStreamId = 0;
|
||||||
lastNameList = "";
|
lastNameList = "";
|
||||||
strcpy(path, "%ROOT%/recordings");
|
|
||||||
|
config.aquire();
|
||||||
|
if (!config.conf.contains(name)) {
|
||||||
|
config.conf[name]["recMode"] = 1;
|
||||||
|
config.conf[name]["directory"] = "%ROOT%/recordings";
|
||||||
|
}
|
||||||
|
recMode = config.conf[name]["recMode"];
|
||||||
|
std::string recPath = config.conf[name]["directory"];
|
||||||
|
strcpy(path, recPath.c_str());
|
||||||
|
config.release(true);
|
||||||
|
|
||||||
gui::menu.registerEntry(name, menuHandler, this);
|
gui::menu.registerEntry(name, menuHandler, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +134,9 @@ private:
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_this->pathValid = true;
|
_this->pathValid = true;
|
||||||
|
config.aquire();
|
||||||
|
config.conf[_this->name]["directory"] = _this->path;
|
||||||
|
config.release(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!lastPathValid) {
|
if (!lastPathValid) {
|
||||||
@ -133,10 +148,16 @@ private:
|
|||||||
ImGui::Columns(2, CONCAT("RecordModeColumns##_", _this->name), false);
|
ImGui::Columns(2, CONCAT("RecordModeColumns##_", _this->name), false);
|
||||||
if (ImGui::RadioButton(CONCAT("Baseband##_", _this->name), _this->recMode == 0) && _this->recMode != 0) {
|
if (ImGui::RadioButton(CONCAT("Baseband##_", _this->name), _this->recMode == 0) && _this->recMode != 0) {
|
||||||
_this->recMode = 0;
|
_this->recMode = 0;
|
||||||
|
config.aquire();
|
||||||
|
config.conf[_this->name]["recMode"] = _this->recMode;
|
||||||
|
config.release(true);
|
||||||
}
|
}
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
if (ImGui::RadioButton(CONCAT("Audio##_", _this->name), _this->recMode == 1) && _this->recMode != 1) {
|
if (ImGui::RadioButton(CONCAT("Audio##_", _this->name), _this->recMode == 1) && _this->recMode != 1) {
|
||||||
_this->recMode = 1;
|
_this->recMode = 1;
|
||||||
|
config.aquire();
|
||||||
|
config.conf[_this->name]["recMode"] = _this->recMode;
|
||||||
|
config.release(true);
|
||||||
}
|
}
|
||||||
if (_this->recording) { style::endDisabled(); }
|
if (_this->recording) { style::endDisabled(); }
|
||||||
ImGui::Columns(1, CONCAT("EndRecordModeColumns##_", _this->name), false);
|
ImGui::Columns(1, CONCAT("EndRecordModeColumns##_", _this->name), false);
|
||||||
@ -275,7 +296,7 @@ private:
|
|||||||
uint64_t samplesWritten;
|
uint64_t samplesWritten;
|
||||||
float sampleRate;
|
float sampleRate;
|
||||||
float vfoSampleRate = 200000;
|
float vfoSampleRate = 200000;
|
||||||
int recMode = 0;
|
int recMode = 1;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -284,7 +305,10 @@ struct RecorderContext_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
MOD_EXPORT void _INIT_() {
|
MOD_EXPORT void _INIT_() {
|
||||||
// Nothing here
|
json def = json({});
|
||||||
|
config.setPath(ROOT_DIR "/recorder_config.json");
|
||||||
|
config.load(def);
|
||||||
|
config.enableAutoSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
MOD_EXPORT ModuleManager::Instance* _CREATE_INSTANCE_(std::string name) {
|
MOD_EXPORT ModuleManager::Instance* _CREATE_INSTANCE_(std::string name) {
|
||||||
@ -296,5 +320,6 @@ MOD_EXPORT void _DELETE_INSTANCE_(ModuleManager::Instance* inst) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MOD_EXPORT void _END_(RecorderContext_t* ctx) {
|
MOD_EXPORT void _END_(RecorderContext_t* ctx) {
|
||||||
|
config.disableAutoSave();
|
||||||
|
config.save();
|
||||||
}
|
}
|
@ -3,7 +3,7 @@
|
|||||||
"bandPlanEnabled": true,
|
"bandPlanEnabled": true,
|
||||||
"centerTuning": false,
|
"centerTuning": false,
|
||||||
"fftHeight": 300,
|
"fftHeight": 300,
|
||||||
"frequency": 99808000,
|
"frequency": 99716000,
|
||||||
"max": 0.0,
|
"max": 0.0,
|
||||||
"maximized": false,
|
"maximized": false,
|
||||||
"menuOrder": [
|
"menuOrder": [
|
||||||
@ -17,7 +17,7 @@
|
|||||||
"Display"
|
"Display"
|
||||||
],
|
],
|
||||||
"menuWidth": 300,
|
"menuWidth": 300,
|
||||||
"min": -70.0,
|
"min": -65.44117736816406,
|
||||||
"moduleInstances": {
|
"moduleInstances": {
|
||||||
"Audio Sink": "audio_sink",
|
"Audio Sink": "audio_sink",
|
||||||
"PlutoSDR Source": "plutosdr_source",
|
"PlutoSDR Source": "plutosdr_source",
|
||||||
@ -41,7 +41,7 @@
|
|||||||
"Radio": {
|
"Radio": {
|
||||||
"muted": false,
|
"muted": false,
|
||||||
"sink": "Audio",
|
"sink": "Audio",
|
||||||
"volume": 0.41326531767845154
|
"volume": 0.4285714328289032
|
||||||
},
|
},
|
||||||
"Radio 1": {
|
"Radio 1": {
|
||||||
"muted": false,
|
"muted": false,
|
||||||
|
6
root_dev/recorder_config.json
Normal file
6
root_dev/recorder_config.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"Recorder": {
|
||||||
|
"directory": "%ROOT%/recordings",
|
||||||
|
"recMode": 1
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user