diff --git a/.github/workflows/build_all.yml b/.github/workflows/build_all.yml index 23e44993..c62f7252 100644 --- a/.github/workflows/build_all.yml +++ b/.github/workflows/build_all.yml @@ -73,7 +73,7 @@ jobs: - name: Prepare CMake working-directory: ${{runner.workspace}}/build - run: cmake $GITHUB_WORKSPACE -DOPT_BUILD_AIRSPYHF_SOURCE=OFF -DOPT_BUILD_PLUTOSDR_SOURCE=OFF -DOPT_BUILD_SOAPY_SOURCE=OFF -DOPT_BUILD_AIRSPY_SOURCE=OFF + run: cmake $GITHUB_WORKSPACE -DOPT_BUILD_AIRSPYHF_SOURCE=OFF -DOPT_BUILD_PLUTOSDR_SOURCE=OFF -DOPT_BUILD_SOAPY_SOURCE=OFF - name: Build working-directory: ${{runner.workspace}}/build diff --git a/airspyhf_source/CMakeLists.txt b/airspyhf_source/CMakeLists.txt index 5e8ba4b7..afc552ff 100644 --- a/airspyhf_source/CMakeLists.txt +++ b/airspyhf_source/CMakeLists.txt @@ -30,6 +30,12 @@ else (MSVC) target_include_directories(airspyhf_source PUBLIC ${LIBAIRSPYHF_INCLUDE_DIRS}) target_link_directories(airspyhf_source PUBLIC ${LIBAIRSPYHF_LIBRARY_DIRS}) target_link_libraries(airspyhf_source PUBLIC ${LIBAIRSPYHF_LIBRARIES}) + + # Include it because for some reason pkgconfig doesn't look here? + if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + target_include_directories(airspy_source PUBLIC "/usr/local/include") + endif() + endif () # Install directives diff --git a/bladerf_source/CMakeLists.txt b/bladerf_source/CMakeLists.txt index b9cf1dd0..4c19fbea 100644 --- a/bladerf_source/CMakeLists.txt +++ b/bladerf_source/CMakeLists.txt @@ -24,7 +24,7 @@ if (MSVC) target_link_libraries(bladerf_source PUBLIC bladeRF) else (MSVC) # Not in pkg-config - target_link_libraries(bladerf_source PUBLIC libbladeRF) + target_link_libraries(bladerf_source PUBLIC bladeRF) endif () # Install directives diff --git a/bladerf_source/src/main.cpp b/bladerf_source/src/main.cpp index 9dad7682..32405761 100644 --- a/bladerf_source/src/main.cpp +++ b/bladerf_source/src/main.cpp @@ -194,6 +194,7 @@ private: _this->bufferSize = _this->sampleRate / 200.0; _this->bufferSize /= 1024; _this->bufferSize *= 1024; + if (_this->bufferSize < 1024) { _this->bufferSize = 1024; } bladerf_sample_rate wantedSr = _this->sampleRate; bladerf_sample_rate actualSr; @@ -255,13 +256,13 @@ private: if (_this->running) { style::beginDisabled(); } ImGui::SetNextItemWidth(menuWidth); - if (ImGui::Combo(CONCAT("##_airspyhf_dev_sel_", _this->name), &_this->devId, _this->devListTxt.c_str())) { + if (ImGui::Combo(CONCAT("##_balderf_dev_sel_", _this->name), &_this->devId, _this->devListTxt.c_str())) { // Select device core::setInputSampleRate(_this->sampleRate); // Save config } - if (ImGui::Combo(CONCAT("##_airspyhf_sr_sel_", _this->name), &_this->srId, sampleRatesTxt)) { + if (ImGui::Combo(CONCAT("##_balderf_sr_sel_", _this->name), &_this->srId, sampleRatesTxt)) { _this->sampleRate = sampleRates[_this->srId]; core::setInputSampleRate(_this->sampleRate); // Save config @@ -269,7 +270,7 @@ private: ImGui::SameLine(); float refreshBtnWdith = menuWidth - ImGui::GetCursorPosX(); - if (ImGui::Button(CONCAT("Refresh##_airspyhf_refr_", _this->name), ImVec2(refreshBtnWdith, 0))) { + if (ImGui::Button(CONCAT("Refresh##_balderf_refr_", _this->name), ImVec2(refreshBtnWdith, 0))) { _this->refresh(); config.aquire(); std::string devSerial = config.conf["device"]; @@ -281,7 +282,7 @@ private: if (_this->running) { style::endDisabled(); } // General config BS - if (ImGui::SliderInt("Test Gain", &_this->testGain, 0, 77)) { + if (ImGui::SliderInt("Test Gain", &_this->testGain, (_this->gainRange != NULL) ? _this->gainRange->min : 0, (_this->gainRange != NULL) ? _this->gainRange->max : 60)) { if (_this->running) { spdlog::info("Setting gain to {0}", _this->testGain); bladerf_set_gain(_this->openDev, BLADERF_CHANNEL_RX(0), _this->testGain); @@ -296,10 +297,7 @@ private: while (true) { int ret = bladerf_sync_rx(openDev, buffer, bufferSize, &meta, 3500); if (ret != 0) { printf("Error: %d\n", ret); break; } - for (int i = 0; i < bufferSize; i++) { - stream.writeBuf[i].re = (float)buffer[(i * 2)] / 32768.0f; - stream.writeBuf[i].im = (float)buffer[(i * 2) + 1] / 32768.0f; - } + volk_16i_s32f_convert_32f((float*)stream.writeBuf, buffer, 32768.0f, bufferSize * 2); if (!stream.swap(bufferSize)) { break; } } delete[] buffer; @@ -309,7 +307,6 @@ private: bladerf* openDev; bool enabled = true; dsp::stream stream; - //dsp::Packer packer(&steam, 2048); double sampleRate; SourceManager::SourceHandler handler; bool running = false; @@ -320,14 +317,14 @@ private: int channelCount; - const bladerf_range* srRange; - const bladerf_range* bwRange; - const bladerf_range* gainRange; + const bladerf_range* srRange = NULL; + const bladerf_range* bwRange = NULL; + const bladerf_range* gainRange = NULL; int bufferSize; struct bladerf_stream* rxStream; - int testGain; + int testGain = 0; std::thread workerThread; diff --git a/core/src/dsp/convertion.h b/core/src/dsp/convertion.h index c1821814..008b17af 100644 --- a/core/src/dsp/convertion.h +++ b/core/src/dsp/convertion.h @@ -168,4 +168,43 @@ namespace dsp { stream* _in; }; + + class Int16CToComplex : public generic_block { + public: + Int16CToComplex() {} + + Int16CToComplex(stream* in) { init(in); } + + void init(stream* in) { + _in = in; + generic_block::registerInput(_in); + generic_block::registerOutput(&out); + } + + void setInput(stream* in) { + std::lock_guard lck(generic_block::ctrlMtx); + generic_block::tempStop(); + generic_block::unregisterInput(_in); + _in = in; + generic_block::registerInput(_in); + generic_block::tempStart(); + } + + int run() { + int count = _in->read(); + if (count < 0) { return -1; } + + volk_16i_s32f_convert_32f((float*)out.writeBuf, _in->readBuf, 32768.0f, count * 2); + + _in->flush(); + if (!out.swap(count)) { return -1; } + return count; + } + + stream out; + + private: + stream* _in; + + }; } \ No newline at end of file diff --git a/core/src/gui/main_window.cpp b/core/src/gui/main_window.cpp index a3b3b990..6dcb31fb 100644 --- a/core/src/gui/main_window.cpp +++ b/core/src/gui/main_window.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -84,14 +83,10 @@ void fftHandler(dsp::complex_t* samples, int count, void* ctx) { gui::waterfall.pushFFT(); } -watcher freq((uint64_t)90500000); -watcher vfoFreq(92000000.0); float fftMin = -70.0; float fftMax = 0.0; -watcher offset(0.0, true); float bw = 8000000; bool playing = false; -watcher dcbias(false, false); bool showCredits = false; std::string audioStreamName = ""; std::string sourceName = ""; @@ -598,9 +593,6 @@ void drawWindow() { ImGui::Text("Framerate: %.1f FPS", ImGui::GetIO().Framerate); ImGui::Text("Center Frequency: %.0f Hz", gui::waterfall.getCenterFrequency()); ImGui::Text("Source name: %s", sourceName.c_str()); - if (ImGui::Checkbox("Test technique", &dcbias.val)) { - //sigpath::signalPath.setDCBiasCorrection(dcbias.val); - } ImGui::Checkbox("Show demo window", &demoWindow); ImGui::Checkbox("Experimental zoom", &experimentalZoom); ImGui::Text("ImGui version: %s", ImGui::GetVersion()); diff --git a/core/src/gui/widgets/frequency_select.cpp b/core/src/gui/widgets/frequency_select.cpp index edc04499..bc7a8589 100644 --- a/core/src/gui/widgets/frequency_select.cpp +++ b/core/src/gui/widgets/frequency_select.cpp @@ -69,6 +69,18 @@ void FrequencySelect::decrementDigit(int i) { digits[i]--; } else { + if (i == 0) { return; } + + // Check if there are non zero digits afterwards + bool otherNoneZero = false; + for (int j = i - 1; j >= 0; j--) { + if (digits[j] > 0) { + otherNoneZero = true; + break; + } + } + if (!otherNoneZero) { return; } + digits[i] = 9; decrementDigit(i - 1); } diff --git a/core/src/gui/widgets/waterfall.cpp b/core/src/gui/widgets/waterfall.cpp index c1334faf..e7abbc71 100644 --- a/core/src/gui/widgets/waterfall.cpp +++ b/core/src/gui/widgets/waterfall.cpp @@ -7,6 +7,7 @@ #include #include #include +#include float DEFAULT_COLOR_MAP[][3] = { {0x00, 0x00, 0x20}, diff --git a/core/src/signal_path/sink.h b/core/src/signal_path/sink.h index 061527e5..50bb4be7 100644 --- a/core/src/signal_path/sink.h +++ b/core/src/signal_path/sink.h @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include class SinkManager { diff --git a/core/src/utils/color.h b/core/src/utils/color.h new file mode 100644 index 00000000..4bb52e53 --- /dev/null +++ b/core/src/utils/color.h @@ -0,0 +1,50 @@ +#pragma once +#include +#include + +namespace color { + inline void RGBtoHSL(float r, float g, float b, float& h, float& s, float& l) { + // Calculate minimum, maximum and delta of components + float cmax = std::max(std::max(r, g), b); + float cmin = std::min(std::min(r, g), b); + float delta = cmax - cmin; + + // Calculate the hue + if (delta == 0) { h = 0; } + else if (r > g && r > b) { h = 60.0f * fmodf((g - b) / delta, 6.0f); } + else if (g > r && g > b) { h = 60.0f * (((b - r) / delta) + 2.0f); } + else { h = 60.0f * (((r - g) / delta) + 4.0f); } + + // Calculate lightness + l = (cmin + cmax) / 2.0f; + + // Calculate saturation + s = (delta == 0) ? 0 : (delta / (1.0f - fabsf((2.0f * l) - 1.0f))); + } + + inline void HSLtoRGB(float h, float s, float l, float& r, float& g, float& b) { + // Calculate coefficients + float c = s * (1.0f - fabsf((2.0f * l) - 1.0f)); + float x = c * (1.0f - fabsf(fmodf(h / 60.0f, 2.0f) - 1.0f)); + float m = l - (c / 2.0f); + + // Affect coefficients to R, G or B depending on hue + if (h < 60) { r = c; g = x; b = 0; } + else if (h < 120) { r = x; g = c; b = 0; } + else if (h < 180) { r = 0; g = c; b = x; } + else if (h < 240) { r = 0; g = x; b = c; } + else if (h < 300) { r = x; g = 0; b = c; } + else { r = c; g = 0; b = x; } + + // Add m + r += m; + g += m; + b += m; + } + + inline void interpRGB(float ar, float ag, float ab, float br, float bg, float bb, float& or, float& og, float& ob, float ratio) { + or = ar + (br - ar) * ratio; + og = ag + (bg - ag) * ratio; + ob = ab + (bb - ab) * ratio; + } +} \ No newline at end of file diff --git a/core/src/event.h b/core/src/utils/event.h similarity index 100% rename from core/src/event.h rename to core/src/utils/event.h diff --git a/core/src/watcher.h b/core/src/watcher.h deleted file mode 100644 index 940e3b02..00000000 --- a/core/src/watcher.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -template -class watcher { -public: - watcher(bool changed = false) { - _changed = changed; - } - - watcher(T value, bool changed = false) { - val = value; - _val = value; - _changed = changed; - } - - bool changed(bool clear = true) { - bool ch = ((val != _val) || _changed); - if (clear) { - _changed = false; - _val = val; - } - return ch; - } - - void markAsChanged() { - _changed = true; - } - - T val; - -private: - bool _changed; - T _val; -}; \ No newline at end of file diff --git a/falcon9_decoder/src/main.cpp b/falcon9_decoder/src/main.cpp index a83d42ff..7b6a8647 100644 --- a/falcon9_decoder/src/main.cpp +++ b/falcon9_decoder/src/main.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/meteor_demodulator/src/main.cpp b/meteor_demodulator/src/main.cpp index d99c7465..bec68010 100644 --- a/meteor_demodulator/src/main.cpp +++ b/meteor_demodulator/src/main.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/radio/src/main.cpp b/radio/src/main.cpp index 62a0d390..0c283c44 100644 --- a/radio/src/main.cpp +++ b/radio/src/main.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/recorder/src/main.cpp b/recorder/src/main.cpp index 3ee00255..66068af6 100644 --- a/recorder/src/main.cpp +++ b/recorder/src/main.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include diff --git a/weather_sat_decoder/src/main.cpp b/weather_sat_decoder/src/main.cpp index c8800eef..20143e72 100644 --- a/weather_sat_decoder/src/main.cpp +++ b/weather_sat_decoder/src/main.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include