SBB Host
Host communication with the self balancing bike.
Loading...
Searching...
No Matches
HostControl.h
Go to the documentation of this file.
1
2#ifndef HOSTCONTROL_H
3#define HOSTCONTROL_H
4
5#include <gtkmm.h>
6#include <vector>
7#include "config.h"
8
16class Slider : public Gtk::Frame {
17public:
25 Slider(Glib::ustring str, double min, double max, double val);
26
31 void set_active(bool is_active = true);
32
37 bool get_active();
38
43 double get_value();
44
45protected:
46 Gtk::Scale scrollbar;
47 Gtk::ToggleButton button;
48 Gtk::Box vbox;
49 Gtk::Box hminbox;
50 Gtk::Box hmaxbox;
51 Gtk::SpinButton minEntry;
52 Gtk::SpinButton maxEntry;
53 Gtk::Label minLabel;
54 Gtk::Label maxLabel;
55 Glib::RefPtr<Gtk::Adjustment> p_adj;
56 Glib::RefPtr<Gtk::Adjustment> p_minadj;
57 Glib::RefPtr<Gtk::Adjustment> p_maxadj;
58
59private:
64
69
75};
76
77
84class HostControl : public Gtk::Frame {
85public:
90
98 void append_slider(Glib::ustring lbl, double min = -1, double max = +1, double val = 0);
99
103 void update();
104
111 bool get_values(float* buf, size_t len);
112
113protected:
114 Gtk::Grid grid;
115 //Gtk::ToggleButton enableButton; //!< Gtk::ToggleButton for the enable-all button.
116 std::vector<Slider*> sliders;
117
118private:
119
120 /* \brief Callback for enable-all button.
121 \details Callback function called when the enable-all button is toggled.
122 */
123 //void on_enable_button_pressed();
124 unsigned int nanVal = NAN_VAL;
125};
126
127
128
129#endif
A class for host control widget.
Definition: HostControl.h:84
bool get_values(float *buf, size_t len)
Get the values of the sliders.
std::vector< Slider * > sliders
Vector of pointers to Slider object.
Definition: HostControl.h:116
void update()
Update the widget appearance.
void append_slider(Glib::ustring lbl, double min=-1, double max=+1, double val=0)
Append a slider.
HostControl()
Constructor.
Gtk::Grid grid
Gtk::Grid object for the sliders.
Definition: HostControl.h:114
unsigned int nanVal
NaN variable, see NAN_VAL.
Definition: HostControl.h:124
A class for slider with Gtk::Label, Gtk::SpinButton and Gtk::ToggleButton.
Definition: HostControl.h:16
void on_enable_button_toggled()
Callback of enable button.
Gtk::Box hminbox
Gtk::Box object for the horizontal box of the minimum value.
Definition: HostControl.h:49
bool get_active()
Get the slider active.
Slider(Glib::ustring str, double min, double max, double val)
Constructor.
Gtk::SpinButton maxEntry
Gtk::SpinButton object for the maximum value entry.
Definition: HostControl.h:52
Gtk::SpinButton minEntry
Gtk::SpinButton object for the minimum value entry.
Definition: HostControl.h:51
Glib::RefPtr< Gtk::Adjustment > p_minadj
Gtk::Adjustment pointer for the minimum value entry.
Definition: HostControl.h:56
Gtk::Scale scrollbar
Gtk::Scale object for the scrollbar.
Definition: HostControl.h:46
void set_active(bool is_active=true)
Enable/disable the slider.
Gtk::Box vbox
Gtk::Box object for a vertical box.
Definition: HostControl.h:48
void on_minadj_changed()
Callback of minimum value entry.
Gtk::Label minLabel
Gtk::Label object for the minimum value label.
Definition: HostControl.h:53
Glib::RefPtr< Gtk::Adjustment > p_maxadj
Gtk::Adjustment pointer for the minimum value entry.
Definition: HostControl.h:57
Glib::RefPtr< Gtk::Adjustment > p_adj
Gtk::Adjustment pointer for the scrollbar.
Definition: HostControl.h:55
double get_value()
Get the slider value.
Gtk::Box hmaxbox
Gtk::Box object for the horizontal box of the maximum value.
Definition: HostControl.h:50
Gtk::Label maxLabel
Gtk::Label object for the maximum value label.
Definition: HostControl.h:54
void on_maxadj_changed()
Callback of maximum value entry.
Gtk::ToggleButton button
Gtk::Button object for the enable button.
Definition: HostControl.h:47
A configuration file for the source code.
#define NAN_VAL
NaN val sent when controls not enabled.
Definition: config.h:75