mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-25 20:07:51 +02:00
Fixed scripting + cleaner code + fixed RTLTCP
This commit is contained in:
@ -1,4 +1,7 @@
|
||||
#include <config.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
|
||||
ConfigManager::ConfigManager() {
|
||||
|
||||
|
@ -1,13 +1,8 @@
|
||||
#pragma once
|
||||
#include <json.hpp>
|
||||
#include <fstream>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <filesystem>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
|
||||
using nlohmann::json;
|
||||
|
||||
|
@ -16,12 +16,11 @@
|
||||
#include <core.h>
|
||||
#include <duktape/duktape.h>
|
||||
#include <duktape/duk_console.h>
|
||||
#include <scripting.h>
|
||||
|
||||
#include <dsp/block.h>
|
||||
|
||||
#define STB_IMAGE_RESIZE_IMPLEMENTATION
|
||||
#include <stb_image_resize.h>
|
||||
#include <gui/gui.h>
|
||||
#include <signal_path/signal_path.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
@ -97,9 +96,9 @@ int sdrpp_main() {
|
||||
// duk_pop(ctx);
|
||||
|
||||
core::scriptManager.createScript("TestScript 1", "test.js");
|
||||
core::scriptManager.createScript("TestScript 2", "test.js");
|
||||
core::scriptManager.createScript("TestScript 3", "test.js");
|
||||
core::scriptManager.createScript("TestScript 4", "test.js");
|
||||
//core::scriptManager.createScript("TestScript 2", "test.js");
|
||||
//core::scriptManager.createScript("TestScript 3", "test.js");
|
||||
//core::scriptManager.createScript("TestScript 4", "test.js");
|
||||
|
||||
// TESTING
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <dsp/stream.h>
|
||||
#include <volk.h>
|
||||
|
||||
namespace dsp {
|
||||
template <class D, class I, class O, int IC, int OC>
|
||||
|
@ -1,4 +1,9 @@
|
||||
#include <gui/bandplan.h>
|
||||
#include <fstream>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <filesystem>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
namespace bandplan {
|
||||
std::map<std::string, BandPlan_t> bandplans;
|
||||
|
@ -1,11 +1,7 @@
|
||||
#pragma once
|
||||
#include <json.hpp>
|
||||
#include <fstream>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <filesystem>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <imgui/imgui.h>
|
||||
#include <stdint.h>
|
||||
|
||||
using nlohmann::json;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <gui/dialogs/credits.h>
|
||||
#include <imgui.h>
|
||||
#include <gui/icons.h>
|
||||
#include <config.h>
|
||||
|
||||
namespace credits {
|
||||
ImFont* bigFont;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <gui/frequency_select.h>
|
||||
#include <config.h>
|
||||
|
||||
bool isInArea(ImVec2 val, ImVec2 min, ImVec2 max) {
|
||||
return val.x >= min.x && val.x < max.x && val.y >= min.y && val.y < max.y;
|
||||
|
@ -2,7 +2,6 @@
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
#include <stdint.h>
|
||||
#include <config.h>
|
||||
|
||||
class FrequencySelect {
|
||||
public:
|
||||
|
@ -8,4 +8,6 @@ namespace gui {
|
||||
SDRPP_EXPORT ImGui::WaterFall waterfall;
|
||||
SDRPP_EXPORT FrequencySelect freqSelect;
|
||||
SDRPP_EXPORT Menu menu;
|
||||
|
||||
void selectSource(std::string name);
|
||||
};
|
@ -1,4 +1,7 @@
|
||||
#include <gui/icons.h>
|
||||
#include <stdint.h>
|
||||
#include <GL/glew.h>
|
||||
#include <config.h>
|
||||
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include <imgui/stb_image.h>
|
||||
|
@ -1,8 +1,7 @@
|
||||
#pragma once
|
||||
#include <imgui/imgui.h>
|
||||
#include <stdint.h>
|
||||
#include <GL/glew.h>
|
||||
#include <config.h>
|
||||
#include <string>
|
||||
|
||||
namespace icons {
|
||||
extern ImTextureID LOGO;
|
||||
|
@ -1,5 +1,40 @@
|
||||
#include <gui/main_window.h>
|
||||
#include <gui/gui.h>
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_glfw.h"
|
||||
#include "imgui_impl_opengl3.h"
|
||||
#include <stdio.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <imgui_plot.h>
|
||||
#include <dsp/resampling.h>
|
||||
#include <dsp/demodulator.h>
|
||||
#include <dsp/filter.h>
|
||||
#include <thread>
|
||||
#include <complex>
|
||||
#include <dsp/source.h>
|
||||
#include <dsp/math.h>
|
||||
#include <gui/waterfall.h>
|
||||
#include <gui/frequency_select.h>
|
||||
#include <fftw3.h>
|
||||
#include <signal_path/dsp.h>
|
||||
#include <gui/icons.h>
|
||||
#include <gui/bandplan.h>
|
||||
#include <watcher.h>
|
||||
#include <module.h>
|
||||
#include <signal_path/vfo_manager.h>
|
||||
#include <signal_path/audio.h>
|
||||
#include <gui/style.h>
|
||||
#include <config.h>
|
||||
#include <signal_path/signal_path.h>
|
||||
#include <core.h>
|
||||
#include <gui/menus/source.h>
|
||||
#include <gui/menus/display.h>
|
||||
#include <gui/menus/bandplan.h>
|
||||
#include <gui/menus/audio.h>
|
||||
#include <gui/menus/scripting.h>
|
||||
#include <gui/dialogs/credits.h>
|
||||
#include <signal_path/source.h>
|
||||
|
||||
std::thread worker;
|
||||
std::mutex fft_mtx;
|
||||
@ -106,7 +141,6 @@ void windowInit() {
|
||||
gui::waterfall.setWaterfallMax(fftMax);
|
||||
|
||||
float frequency = core::configManager.conf["frequency"];
|
||||
|
||||
|
||||
gui::freqSelect.setFrequency(frequency);
|
||||
gui::freqSelect.frequencyChanged = false;
|
||||
@ -459,12 +493,4 @@ void drawWindow() {
|
||||
if (showCredits) {
|
||||
credits::show();
|
||||
}
|
||||
}
|
||||
|
||||
void bindVolumeVariable(float* vol) {
|
||||
volume = vol;
|
||||
}
|
||||
|
||||
void unbindVolumeVariable() {
|
||||
volume = &dummyVolume;
|
||||
}
|
@ -1,43 +1,7 @@
|
||||
#pragma once
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_glfw.h"
|
||||
#include "imgui_impl_opengl3.h"
|
||||
#include <stdio.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <imgui_plot.h>
|
||||
#include <dsp/resampling.h>
|
||||
#include <dsp/demodulator.h>
|
||||
#include <dsp/filter.h>
|
||||
#include <thread>
|
||||
#include <complex>
|
||||
#include <dsp/source.h>
|
||||
#include <dsp/math.h>
|
||||
#include <gui/waterfall.h>
|
||||
#include <gui/frequency_select.h>
|
||||
#include <fftw3.h>
|
||||
#include <signal_path/dsp.h>
|
||||
#include <gui/icons.h>
|
||||
#include <gui/bandplan.h>
|
||||
#include <watcher.h>
|
||||
#include <module.h>
|
||||
#include <signal_path/vfo_manager.h>
|
||||
#include <signal_path/audio.h>
|
||||
#include <gui/style.h>
|
||||
#include <config.h>
|
||||
#include <signal_path/signal_path.h>
|
||||
#include <core.h>
|
||||
#include <gui/menus/source.h>
|
||||
#include <gui/menus/display.h>
|
||||
#include <gui/menus/bandplan.h>
|
||||
#include <gui/menus/audio.h>
|
||||
#include <gui/menus/scripting.h>
|
||||
#include <gui/dialogs/credits.h>
|
||||
#include <signal_path/source.h>
|
||||
|
||||
#define WINDOW_FLAGS ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoBackground
|
||||
|
||||
void windowInit();
|
||||
void drawWindow();
|
||||
void bindVolumeVariable(float* vol);
|
||||
void unbindVolumeVariable();
|
||||
void drawWindow();
|
@ -1,4 +1,5 @@
|
||||
#include <gui/menu.h>
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
Menu::Menu() {
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
#pragma once
|
||||
#include <imgui/imgui.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <gui/menus/scripting.h>
|
||||
#include <core.h>
|
||||
#include <gui/style.h>
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
namespace scriptingmenu {
|
||||
void init() {
|
||||
|
@ -1,4 +1,7 @@
|
||||
#include <gui/style.h>
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
#include <config.h>
|
||||
|
||||
namespace style {
|
||||
void setDefaultStyle() {
|
||||
|
@ -1,7 +1,4 @@
|
||||
#pragma once
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
#include <config.h>
|
||||
|
||||
namespace style {
|
||||
void setDefaultStyle();
|
||||
|
@ -1,4 +1,9 @@
|
||||
#include <gui/waterfall.h>
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
#include <GL/glew.h>
|
||||
#include <imutils.h>
|
||||
#include <algorithm>
|
||||
|
||||
float COLOR_MAP[][3] = {
|
||||
{0x00, 0x00, 0x20},
|
||||
|
@ -1,12 +1,10 @@
|
||||
#pragma once
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
#include <GL/glew.h>
|
||||
#include <imutils.h>
|
||||
#include <gui/bandplan.h>
|
||||
#include <algorithm>
|
||||
#include <imgui/imgui.h>
|
||||
#include <imgui/imgui_internal.h>
|
||||
#include <GL/glew.h>
|
||||
|
||||
#define WATERFALL_RESOLUTION 1000000
|
||||
|
||||
|
@ -1,12 +1,14 @@
|
||||
#include <module.h>
|
||||
#include <signal_path/vfo_manager.h>
|
||||
#include <gui/main_window.h>
|
||||
#include <signal_path/audio.h>
|
||||
#include <filesystem>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <json.hpp>
|
||||
#include <fstream>
|
||||
|
||||
using nlohmann::json;
|
||||
|
||||
namespace mod {
|
||||
std::map<std::string, Module_t> modules;
|
||||
std::vector<std::string> moduleNames;
|
||||
ImGui::WaterFall* _wtf;
|
||||
|
||||
void loadModule(std::string path, std::string name) {
|
||||
if (!std::filesystem::exists(path)) {
|
||||
|
@ -1,13 +1,6 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <filesystem>
|
||||
#include <stdint.h>
|
||||
#include <imgui.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <dsp/types.h>
|
||||
#include <dsp/stream.h>
|
||||
#include <gui/waterfall.h>
|
||||
#include <json.hpp>
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include <version.h>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <signal_path/signal_path.h>
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
ScriptManager::ScriptManager() {
|
||||
|
||||
@ -42,9 +44,16 @@ duk_context* ScriptManager::createContext(ScriptManager* _this, std::string name
|
||||
|
||||
duk_idx_t sdrppBase = duk_push_object(ctx);
|
||||
|
||||
// API
|
||||
|
||||
duk_push_string(ctx, VERSION_STR);
|
||||
duk_put_prop_string(ctx, sdrppBase, "version");
|
||||
|
||||
duk_push_c_function(ctx, ScriptManager::duk_setSource, 1);
|
||||
duk_put_prop_string(ctx, sdrppBase, "selectSource");
|
||||
|
||||
// Modules
|
||||
|
||||
duk_idx_t modObjId = duk_push_object(ctx);
|
||||
for (const auto& [name, handler] : _this->handlers) {
|
||||
duk_idx_t objId = duk_push_object(ctx);
|
||||
@ -72,4 +81,13 @@ void ScriptManager::Script::scriptWorker(Script* script) {
|
||||
void ScriptManager::bindScriptRunHandler(std::string name, ScriptManager::ScriptRunHandler_t handler) {
|
||||
// TODO: check if it exists and add a "unbind" function
|
||||
handlers[name] = handler;
|
||||
}
|
||||
|
||||
duk_ret_t ScriptManager::duk_setSource(duk_context* dukCtx) {
|
||||
const char* name = duk_require_string(dukCtx, -1);
|
||||
sigpath::sourceManager.selectSource(name);
|
||||
|
||||
duk_pop_n(dukCtx, 1); // Pop demod name, this and context
|
||||
|
||||
return 0;
|
||||
}
|
@ -43,6 +43,9 @@ public:
|
||||
private:
|
||||
static duk_context* createContext(ScriptManager* _this, std::string name);
|
||||
|
||||
// API
|
||||
static duk_ret_t duk_setSource(duk_context* ctx);
|
||||
|
||||
std::map<std::string, ScriptManager::ScriptRunHandler_t> handlers;
|
||||
|
||||
};
|
@ -3,7 +3,6 @@
|
||||
#include <dsp/routing.h>
|
||||
#include <io/audio.h>
|
||||
#include <map>
|
||||
#include <watcher.h>
|
||||
|
||||
namespace audio {
|
||||
enum {
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <dsp/sink.h>
|
||||
#include <dsp/correction.h>
|
||||
#include <dsp/vfo.h>
|
||||
#include <io/audio.h>
|
||||
#include <map>
|
||||
#include <module.h>
|
||||
|
||||
|
Reference in New Issue
Block a user