mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-25 12:07:49 +02:00
new scripting system
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
#include <path.h>
|
||||
#include <watcher.h>
|
||||
#include <config.h>
|
||||
#include <core.h>
|
||||
|
||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
||||
#define DEEMP_LIST "50µS\00075µS\000none\000"
|
||||
@ -26,6 +27,11 @@ public:
|
||||
sigPath.start();
|
||||
sigPath.setDemodulator(SigPath::DEMOD_FM, bandWidth);
|
||||
gui::menu.registerEntry(name, menuHandler, this);
|
||||
|
||||
ScriptManager::ScriptRunHandler_t handler;
|
||||
handler.ctx = this;
|
||||
handler.handler = scriptCreateHandler;
|
||||
core::scriptManager.bindScriptRunHandler(name, handler);
|
||||
}
|
||||
|
||||
~RadioModule() {
|
||||
@ -117,6 +123,32 @@ private:
|
||||
ImGui::PopItemWidth();
|
||||
}
|
||||
|
||||
static void scriptCreateHandler(void* ctx, duk_context* dukCtx, duk_idx_t objId) {
|
||||
duk_push_string(dukCtx, "Hello from modules ;)");
|
||||
duk_put_prop_string(dukCtx, objId, "test");
|
||||
|
||||
duk_push_c_function(dukCtx, duk_setDemodulator, 1);
|
||||
duk_put_prop_string(dukCtx, objId, "setDemodulator");
|
||||
|
||||
duk_push_pointer(dukCtx, ctx);
|
||||
duk_put_prop_string(dukCtx, objId, DUK_HIDDEN_SYMBOL("radio_ctx"));
|
||||
}
|
||||
|
||||
static duk_ret_t duk_setDemodulator(duk_context* dukCtx) {
|
||||
const char* str = duk_require_string(dukCtx, -1);
|
||||
std::string modName = str;
|
||||
|
||||
if (modName == "USB") {
|
||||
_this->demod = 4;
|
||||
_this->bandWidth = 3000;
|
||||
_this->bandWidthMin = 1500;
|
||||
_this->bandWidthMax = 3000;
|
||||
_this->sigPath.setDemodulator(SigPath::DEMOD_USB, _this->bandWidth);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string name;
|
||||
int demod = 1;
|
||||
int deemp = 0;
|
||||
|
Reference in New Issue
Block a user