File: base_sink_c_python.cc

package info (click to toggle)
gr-fosphor 3.9~git20240323.74d54fc-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,268 kB
  • sloc: python: 9,483; ansic: 3,422; cpp: 1,281; lisp: 609; makefile: 33
file content (93 lines) | stat: -rw-r--r-- 2,432 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
 * Copyright 2013-2021 Sylvain Munaut <tnt@246tNt.com>
 *
 * This file is part of gr-fosphor
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include <pybind11/complex.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

namespace py = pybind11;

#include <gnuradio/fosphor/base_sink_c.h>

#define D(...) ""

void bind_base_sink_c(py::module& m)
{
	using base_sink_c = gr::fosphor::base_sink_c;

	py::class_<base_sink_c,
		gr::sync_block,
		gr::block,
		gr::basic_block,
		std::shared_ptr<base_sink_c>> sink_class (m, "base_sink_c", D(base_sink_c));


	py::enum_<base_sink_c::ui_action_t>(sink_class, "ui_action")
	.value("DB_PER_DIV_UP",    base_sink_c::DB_PER_DIV_UP)
	.value("DB_PER_DIV_DOWN",  base_sink_c::DB_PER_DIV_DOWN)
	.value("REF_UP",           base_sink_c::REF_UP)
	.value("REF_DOWN",         base_sink_c::REF_DOWN)
	.value("ZOOM_TOGGLE",      base_sink_c::ZOOM_TOGGLE)
	.value("ZOOM_WIDTH_UP",    base_sink_c::ZOOM_WIDTH_UP)
	.value("ZOOM_WIDTH_DOWN",  base_sink_c::ZOOM_WIDTH_DOWN)
	.value("ZOOM_CENTER_UP",   base_sink_c::ZOOM_CENTER_UP)
	.value("ZOOM_CENTER_DOWN", base_sink_c::ZOOM_CENTER_DOWN)
	.value("RATIO_UP",         base_sink_c::RATIO_UP)
	.value("RATIO_DOWN",       base_sink_c::RATIO_DOWN)
	.value("FREEZE_TOGGLE",    base_sink_c::FREEZE_TOGGLE)
        .export_values();

	py::enum_<base_sink_c::mouse_action_t>(sink_class, "mouse_action")
	.value("CLICK",           base_sink_c::CLICK)
        .export_values();

	py::implicitly_convertible<int, base_sink_c::ui_action_t>();
	py::implicitly_convertible<int, base_sink_c::mouse_action_t>();

	sink_class
		.def("execute_ui_action",
			&base_sink_c::execute_ui_action,
			py::arg("action"),
			D(base_sink_c,execute_ui_action)
		)

		.def("execute_mouse_action",
			&base_sink_c::execute_mouse_action,
			py::arg("action"),
			py::arg("x"),
			py::arg("y"),
			D(base_sink_c,execute_mouse_action)
		)

		.def("set_frequency_range",
			&base_sink_c::set_frequency_range,
			py::arg("center"),
			py::arg("span"),
			D(base_sink_c,set_frequency_range)
		)

		.def("set_frequency_center",
			&base_sink_c::set_frequency_center,
			py::arg("center"),
			D(base_sink_c,set_frequency_center)
		)

		.def("set_frequency_span",
			&base_sink_c::set_frequency_span,
			py::arg("span"),
			D(base_sink_c,set_frequency_span)
		)

		.def("set_fft_window",
			&base_sink_c::set_fft_window,
			py::arg("win"),
			D(base_sink_c,set_fft_window)
		)

		;
}