kopia lustrzana https://github.com/AlexandreRouma/SDRPlusPlus
more work on the spectran
rodzic
643d47fe47
commit
fa2e13f3ea
|
@ -31,12 +31,11 @@ public:
|
|||
if (AARTSAAPI_Init(AARTSAAPI_MEMORY_MEDIUM) != AARTSAAPI_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (AARTSAAPI_Open(&api) != AARTSAAPI_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
sampleRate = 245760000.0/1.0;
|
||||
samplerate.effective = 1000000.0;
|
||||
|
||||
handler.ctx = this;
|
||||
handler.selectHandler = menuSelected;
|
||||
|
@ -112,6 +111,68 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
// Set ID
|
||||
devId = devList.keyId(serial);
|
||||
|
||||
// Open device
|
||||
if (AARTSAAPI_OpenDevice(&api, &dev, L"spectranv6/raw", devList[devId].c_str()) != AARTSAAPI_OK) {
|
||||
spdlog::error("Failed to open device");
|
||||
selectedSerial.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
// Get config root
|
||||
AARTSAAPI_Config config;
|
||||
AARTSAAPI_ConfigRoot(&dev, &croot);
|
||||
|
||||
// Get valid clock rates
|
||||
AARTSAAPI_ConfigInfo clockInfo;
|
||||
AARTSAAPI_ConfigFind(&dev, &croot, &config, L"device/receiverclock");
|
||||
AARTSAAPI_ConfigGetInfo(&dev, &config, &clockInfo);
|
||||
|
||||
// Enumerate valid samplerates
|
||||
spdlog::warn("{0}", clockInfo.disabledOptions);
|
||||
std::vector<SRCombo> srs;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if ((clockInfo.disabledOptions >> i) & 1) { continue; }
|
||||
int dCount = sizeof(decimations)/sizeof(decimations[0]);
|
||||
for (int j = 0; j < dCount; j++) {
|
||||
SRCombo combo;
|
||||
combo.baseId = i;
|
||||
combo.decimId = j;
|
||||
combo.effective = clockRates[combo.baseId] / (double)decimations[combo.decimId];
|
||||
srs.push_back(combo);
|
||||
}
|
||||
}
|
||||
|
||||
// Sort list in ascending order
|
||||
std::sort(srs.begin(), srs.end(), [](SRCombo a, SRCombo b) {
|
||||
if (a.effective != b.effective) {
|
||||
return a.effective < b.effective;
|
||||
}
|
||||
else {
|
||||
return a.baseId < b.baseId;
|
||||
}
|
||||
});
|
||||
|
||||
// Create SR list
|
||||
char buf[128];
|
||||
sampleRateList.clear();
|
||||
for (const auto& sr : srs) {
|
||||
sprintf(buf, "%s (%s / %d)", getBandwdithScaled(sr.effective).c_str(), getBandwdithScaled(clockRates[sr.baseId]).c_str(), decimations[sr.decimId]);
|
||||
sampleRateList.define(buf, sr);
|
||||
}
|
||||
|
||||
// Default config
|
||||
srId = 0;
|
||||
|
||||
// Set samplerate
|
||||
samplerate = sampleRateList.value(srId);
|
||||
core::setInputSampleRate(samplerate.effective);
|
||||
|
||||
// Close device
|
||||
AARTSAAPI_CloseDevice(&api, &dev);
|
||||
|
||||
selectedSerial = serial;
|
||||
}
|
||||
|
||||
|
@ -132,7 +193,7 @@ private:
|
|||
|
||||
static void menuSelected(void* ctx) {
|
||||
SpectranSourceModule* _this = (SpectranSourceModule*)ctx;
|
||||
core::setInputSampleRate(_this->sampleRate);
|
||||
core::setInputSampleRate(_this->samplerate.effective);
|
||||
spdlog::info("SpectranSourceModule '{0}': Menu Select!", _this->name);
|
||||
}
|
||||
|
||||
|
@ -161,10 +222,10 @@ private:
|
|||
AARTSAAPI_ConfigSetString(&_this->dev, &config, L"iq");
|
||||
|
||||
AARTSAAPI_ConfigFind(&_this->dev, &_this->croot, &config, L"device/receiverclock");
|
||||
AARTSAAPI_ConfigSetString(&_this->dev, &config, L"245MHz");
|
||||
AARTSAAPI_ConfigSetString(&_this->dev, &config, _this->clkRatesTxt[_this->samplerate.baseId]);
|
||||
|
||||
AARTSAAPI_ConfigFind(&_this->dev, &_this->croot, &config, L"main/decimation");
|
||||
AARTSAAPI_ConfigSetString(&_this->dev, &config, L"Full");
|
||||
AARTSAAPI_ConfigSetString(&_this->dev, &config, _this->decimationsTxt[_this->samplerate.decimId]);
|
||||
|
||||
AARTSAAPI_ConfigFind(&_this->dev, &_this->croot, &config, L"main/centerfreq");
|
||||
AARTSAAPI_ConfigSetFloat(&_this->dev, &config, _this->freq);
|
||||
|
@ -234,18 +295,22 @@ private:
|
|||
|
||||
SmGui::FillWidth();
|
||||
SmGui::ForceSync();
|
||||
if (ImGui::Combo(CONCAT("Refresh##_spectran_dev_", _this->name), &_this->devId, _this->devList.txt)) {
|
||||
if (ImGui::Combo(CONCAT("##_spectran_dev_", _this->name), &_this->devId, _this->devList.txt)) {
|
||||
|
||||
}
|
||||
// TODO: SR sel
|
||||
if (ImGui::Combo(CONCAT("##_spectran_sr_", _this->name), &_this->srId, _this->sampleRateList.txt)) {
|
||||
_this->samplerate = _this->sampleRateList.value(_this->srId);
|
||||
core::setInputSampleRate(_this->samplerate.effective);
|
||||
}
|
||||
|
||||
//SmGui::SameLine();
|
||||
SmGui::SameLine();
|
||||
SmGui::FillWidth();
|
||||
SmGui::ForceSync();
|
||||
if (SmGui::Button(CONCAT("Refresh##_spectran_refr_", _this->name))) {
|
||||
_this->refresh();
|
||||
_this->selectSerial(_this->selectedSerial);
|
||||
core::setInputSampleRate(_this->sampleRate);
|
||||
core::setInputSampleRate(_this->samplerate.effective);
|
||||
}
|
||||
|
||||
if (_this->running) { SmGui::EndDisabled(); }
|
||||
|
@ -312,11 +377,32 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
const double clockRates[4] = {
|
||||
92160000.0,
|
||||
122880000.0,
|
||||
184320000.0,
|
||||
245760000.0
|
||||
};
|
||||
|
||||
const wchar_t* clkRatesTxt[4] = {
|
||||
L"92MHz",
|
||||
L"122MHz",
|
||||
L"184MHz",
|
||||
L"245MHz"
|
||||
};
|
||||
|
||||
const int decimations[10] = {
|
||||
512, 256, 128, 64, 32, 16, 8, 4, 2, 1
|
||||
};
|
||||
|
||||
const wchar_t* decimationsTxt[10] = {
|
||||
L"1 / 512", L"1 / 256", L"1 / 128", L"1 / 64", L"1 / 32",
|
||||
L"1 / 16", L"1 / 8", L"1 / 4", L"1 / 2", L"Full"
|
||||
};
|
||||
|
||||
std::string name;
|
||||
bool enabled = true;
|
||||
dsp::stream<dsp::complex_t> stream;
|
||||
double sampleRate;
|
||||
SourceManager::SourceHandler handler;
|
||||
bool running = false;
|
||||
double freq;
|
||||
|
@ -327,7 +413,20 @@ private:
|
|||
bool amp = false;
|
||||
bool preamp = false;
|
||||
|
||||
struct SRCombo {
|
||||
bool operator==(const SRCombo& b) {
|
||||
return baseId == b.baseId && decimId == b.decimId;
|
||||
}
|
||||
|
||||
int baseId;
|
||||
int decimId;
|
||||
double effective;
|
||||
};
|
||||
|
||||
SRCombo samplerate;
|
||||
|
||||
OptionList<std::string, std::wstring> devList;
|
||||
OptionList<std::string, SRCombo> sampleRateList;
|
||||
|
||||
AARTSAAPI_Handle api;
|
||||
AARTSAAPI_Device dev;
|
||||
|
|
Ładowanie…
Reference in New Issue