diff --git a/src/UI/CMakeLists.txt b/src/UI/CMakeLists.txt index 09f2d7b..5c7f06c 100644 --- a/src/UI/CMakeLists.txt +++ b/src/UI/CMakeLists.txt @@ -5,7 +5,7 @@ include(FetchContent) FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz DOWNLOAD_EXTRACT_TIMESTAMP TRUE) FetchContent_MakeAvailable(json) -find_package(Qt6 REQUIRED COMPONENTS Core) +find_package(Qt6 REQUIRED COMPONENTS Core SerialBus) set_target_properties( UI @@ -62,4 +62,5 @@ target_link_libraries(UI Color nlohmann_json::nlohmann_json Qt::Core + Qt::SerialBus ) diff --git a/src/UI/UI_button.cpp b/src/UI/UI_button.cpp index 4d48e7c..eae06c4 100644 --- a/src/UI/UI_button.cpp +++ b/src/UI/UI_button.cpp @@ -1,11 +1,11 @@ #include "UI_button.hpp" -UI_button::UI_button(std::string text, Color fg_color, Color bg_color, QObject *parrent) - : UI_item(UI_BUTTON_TYPE, text, 12, fg_color, bg_color, parrent) +UI_button::UI_button(std::string text, Color fg_color, Color bg_color, QObject *parent) + : UI_item(UI_BUTTON_TYPE, text, 12, fg_color, bg_color, parent) { } -UI_button::UI_button(const json &j, QObject *parrent) : UI_item(UI_BUTTON_TYPE, parrent) +UI_button::UI_button(const json &j, QObject *parent) : UI_item(UI_BUTTON_TYPE, parent) { from_json(j); } diff --git a/src/UI/UI_button.hpp b/src/UI/UI_button.hpp index 18cd691..5908a9a 100644 --- a/src/UI/UI_button.hpp +++ b/src/UI/UI_button.hpp @@ -8,8 +8,8 @@ class UI_button : public UI_item { Q_OBJECT public: - UI_button(std::string text, Color fg_color, Color bg_color, QObject *parrent = nullptr); - UI_button(const json &j, QObject *parrent = nullptr); + UI_button(std::string text, Color fg_color, Color bg_color, QObject *parent = nullptr); + UI_button(const json &j, QObject *parent = nullptr); void from_json(const json &j) override; json to_json(size_t id) const override; diff --git a/src/UI/UI_checkbox.cpp b/src/UI/UI_checkbox.cpp index 9856f12..02d069b 100644 --- a/src/UI/UI_checkbox.cpp +++ b/src/UI/UI_checkbox.cpp @@ -1,16 +1,16 @@ #include "UI_checkbox.hpp" -UI_checkbox::UI_checkbox(QObject *parrent) : UI_item(UI_CHECKBOX_TYPE, parrent), m_selected() +UI_checkbox::UI_checkbox(QObject *parent) : UI_item(UI_CHECKBOX_TYPE, parent), m_selected() { } -UI_checkbox::UI_checkbox(std::string text, Color fg_color, Color bg_color, QObject *parrent) - : UI_item(UI_CHECKBOX_TYPE, text, 0, fg_color, bg_color, parrent), m_selected(false) +UI_checkbox::UI_checkbox(std::string text, Color fg_color, Color bg_color, QObject *parent) + : UI_item(UI_CHECKBOX_TYPE, text, 0, fg_color, bg_color, parent), m_selected(false) { } -UI_checkbox::UI_checkbox(const json &j, QObject *parrent) : UI_item(UI_CHECKBOX_TYPE, parrent), m_selected() +UI_checkbox::UI_checkbox(const json &j, QObject *parent) : UI_item(UI_CHECKBOX_TYPE, parent), m_selected() { from_json(j); } diff --git a/src/UI/UI_checkbox.hpp b/src/UI/UI_checkbox.hpp index ec5cad9..a125e7c 100644 --- a/src/UI/UI_checkbox.hpp +++ b/src/UI/UI_checkbox.hpp @@ -8,10 +8,10 @@ class UI_checkbox : public UI_item { Q_OBJECT public: - UI_checkbox(QObject *parrent = nullptr); + UI_checkbox(QObject *parent = nullptr); UI_checkbox(std::string text, Color fg_color, Color bg_color, - QObject *parrent = nullptr); - UI_checkbox(const json &j, QObject *parrent = nullptr); + QObject *parent = nullptr); + UI_checkbox(const json &j, QObject *parent = nullptr); void toggle_selected(); bool selected() const; diff --git a/src/UI/UI_combobox.cpp b/src/UI/UI_combobox.cpp index 02b8f01..a4c5f7d 100644 --- a/src/UI/UI_combobox.cpp +++ b/src/UI/UI_combobox.cpp @@ -1,6 +1,6 @@ #include "UI_combobox.hpp" -UI_combobox::UI_combobox(QObject *parrent) : UI_x_boxes(UI_COMBOBOX_TYPE, parrent) +UI_combobox::UI_combobox(QObject *parent) : UI_x_boxes(UI_COMBOBOX_TYPE, parent) { } @@ -10,7 +10,7 @@ UI_combobox::UI_combobox(Color fg_color, Color bg_color, { } -UI_combobox::UI_combobox(const json &j, QObject *parrent) : UI_x_boxes(UI_COMBOBOX_TYPE, parrent) +UI_combobox::UI_combobox(const json &j, QObject *parent) : UI_x_boxes(UI_COMBOBOX_TYPE, parent) { from_json(j); } diff --git a/src/UI/UI_dial.cpp b/src/UI/UI_dial.cpp index 2d911ce..54417bc 100644 --- a/src/UI/UI_dial.cpp +++ b/src/UI/UI_dial.cpp @@ -1,20 +1,20 @@ #include "UI_dial.hpp" UI_dial::UI_dial(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, double value, - QObject *parrent) - : UI_item(UI_DIAL_TYPE, text, 12, fg_color, bg_color, parrent), m_min(min), m_max(max), m_value(value), m_unit(unit) + QObject *parent) + : UI_item(UI_DIAL_TYPE, text, 12, fg_color, bg_color, parent), m_min(min), m_max(max), m_value(value), m_unit(unit) { } UI_dial::UI_dial(std::string text, Color fg_color, Color bg_color, double min, double max, - double value, QObject *parrent) - : UI_dial(text, "", fg_color, bg_color, min, max, value, parrent) + double value, QObject *parent) + : UI_dial(text, "", fg_color, bg_color, min, max, value, parent) { } -UI_dial::UI_dial(const json &j, QObject *parrent) - : UI_item(UI_DIAL_TYPE, parrent) +UI_dial::UI_dial(const json &j, QObject *parent) + : UI_item(UI_DIAL_TYPE, parent) { from_json(j); } diff --git a/src/UI/UI_dial.hpp b/src/UI/UI_dial.hpp index 3ed072c..f74c2a4 100644 --- a/src/UI/UI_dial.hpp +++ b/src/UI/UI_dial.hpp @@ -8,10 +8,10 @@ class UI_dial : public UI_item Q_OBJECT public: UI_dial(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, double value, - QObject *parrent = nullptr); + QObject *parent = nullptr); UI_dial(std::string text, Color fg_color, Color bg_color, double min, double max, double value, - QObject *parrent = nullptr); - UI_dial(const json &j, QObject *parrent = nullptr); + QObject *parent = nullptr); + UI_dial(const json &j, QObject *parent = nullptr); void set_value(double value) override; double value() const; diff --git a/src/UI/UI_item.cpp b/src/UI/UI_item.cpp index 404e7d1..a733887 100644 --- a/src/UI/UI_item.cpp +++ b/src/UI/UI_item.cpp @@ -1,19 +1,19 @@ #include "UI_item.hpp" UI_item::UI_item(std::string type, std::string text, uint8_t text_size, Color fg_color, Color bg_color, - QObject *parrent) - : QObject(parrent), m_id((size_t)-1), m_type(type), m_text(text), m_text_size(text_size), m_fg_color(fg_color), + QObject *parent) + : QObject(parent), m_id((size_t)-1), m_type(type), m_text(text), m_text_size(text_size), m_fg_color(fg_color), m_bg_color(bg_color), enabled(true), visible(true) { } -UI_item::UI_item(std::string type, QObject *parrent) - : QObject(parrent), m_id((size_t)-1), m_type(type), m_text(""), m_text_size(12), m_fg_color(Color::Black), +UI_item::UI_item(std::string type, QObject *parent) + : QObject(parent), m_id((size_t)-1), m_type(type), m_text(""), m_text_size(12), m_fg_color(Color::Black), m_bg_color(Color::White), enabled(true), visible(true) { } -UI_item::UI_item(const json &j, QObject *parrent) : QObject(parrent) +UI_item::UI_item(const json &j, QObject *parent) : QObject(parent) { from_json(j); } @@ -162,7 +162,9 @@ void UI_item::set_value(double value) UNUSED(value); }; -void UI_item::can_send(can_message_t msg) +void UI_item::can_send(uint32_t id, uint8_t dlc, std::array payload) { - UNUSED(msg); -}; \ No newline at end of file + UNUSED(id); + UNUSED(dlc); + UNUSED(payload); +}; diff --git a/src/UI/UI_item.hpp b/src/UI/UI_item.hpp index 7fa43a2..b9a479a 100644 --- a/src/UI/UI_item.hpp +++ b/src/UI/UI_item.hpp @@ -7,6 +7,7 @@ #include #include +#include using json = nlohmann::json; #define UNUSED(x) (void)(x) @@ -15,10 +16,10 @@ class UI_item : public QObject { Q_OBJECT public: - explicit UI_item(std::string type, QObject *parrent = nullptr); + explicit UI_item(std::string type, QObject *parent = nullptr); explicit UI_item(std::string type, std::string text, uint8_t text_size, Color fg_color, - Color bg_color, QObject *parrent = nullptr); - explicit UI_item(const json &j, QObject *parrent = nullptr); + Color bg_color, QObject *parent = nullptr); + explicit UI_item(const json &j, QObject *parent = nullptr); ~UI_item(); std::string type() const; @@ -49,7 +50,7 @@ class UI_item : public QObject virtual void click(); virtual void set_selected(std::string selected); virtual void set_value(double value); - virtual void can_send(can_message_t msg); + virtual void can_send(uint32_t id, uint8_t dlc, std::array payload); signals: void value_changed(); diff --git a/src/UI/UI_label.cpp b/src/UI/UI_label.cpp index 5b73242..92330b1 100644 --- a/src/UI/UI_label.cpp +++ b/src/UI/UI_label.cpp @@ -1,11 +1,11 @@ #include "UI_label.hpp" -UI_label::UI_label(std::string text, Color fg_color, Color bg_color, QObject *parrent) - : UI_item(UI_LABEL_TYPE, text, 12, fg_color, bg_color, parrent) +UI_label::UI_label(std::string text, Color fg_color, Color bg_color, QObject *parent) + : UI_item(UI_LABEL_TYPE, text, 12, fg_color, bg_color, parent) { } -UI_label::UI_label(const json &j, QObject *parrent) : UI_item(UI_LABEL_TYPE, parrent) +UI_label::UI_label(const json &j, QObject *parent) : UI_item(UI_LABEL_TYPE, parent) { from_json(j); } diff --git a/src/UI/UI_label.hpp b/src/UI/UI_label.hpp index a025710..6201962 100644 --- a/src/UI/UI_label.hpp +++ b/src/UI/UI_label.hpp @@ -8,8 +8,8 @@ class UI_label : public UI_item { Q_OBJECT public: - UI_label(std::string text, Color fg_color, Color bg_color, QObject *parrent = nullptr); - UI_label(const json &j, QObject *parrent = nullptr); + UI_label(std::string text, Color fg_color, Color bg_color, QObject *parent = nullptr); + UI_label(const json &j, QObject *parent = nullptr); void from_json(const json &j) override; json to_json(size_t id) const override; diff --git a/src/UI/UI_led.cpp b/src/UI/UI_led.cpp index 78aab90..5084b08 100644 --- a/src/UI/UI_led.cpp +++ b/src/UI/UI_led.cpp @@ -1,11 +1,11 @@ #include "UI_led.hpp" -UI_led::UI_led(std::string text, Color fg_color, Color bg_color, Color led_color, QObject *parrent) - : UI_item(UI_LED_TYPE, text, 12, fg_color, bg_color, parrent), m_led_color(led_color) +UI_led::UI_led(std::string text, Color fg_color, Color bg_color, Color led_color, QObject *parent) + : UI_item(UI_LED_TYPE, text, 12, fg_color, bg_color, parent), m_led_color(led_color) { } -UI_led::UI_led(const json &j, QObject *parrent) : UI_item(UI_LED_TYPE, parrent) +UI_led::UI_led(const json &j, QObject *parent) : UI_item(UI_LED_TYPE, parent) { from_json(j); } diff --git a/src/UI/UI_led.hpp b/src/UI/UI_led.hpp index 25eefed..5161f50 100644 --- a/src/UI/UI_led.hpp +++ b/src/UI/UI_led.hpp @@ -9,8 +9,8 @@ class UI_led : public UI_item Q_OBJECT public: UI_led(std::string text, Color fg_color, Color bg_color, Color led_color, - QObject *parrent = nullptr); - UI_led(const json &j, QObject *parrent = nullptr); + QObject *parent = nullptr); + UI_led(const json &j, QObject *parent = nullptr); Color led_color() const; void set_led_color(Color led_color); diff --git a/src/UI/UI_slider.cpp b/src/UI/UI_slider.cpp index b6ce3f1..e565b58 100644 --- a/src/UI/UI_slider.cpp +++ b/src/UI/UI_slider.cpp @@ -1,19 +1,19 @@ #include "UI_slider.hpp" UI_slider::UI_slider(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, - double value, QObject *parrent) - : UI_item(UI_SLIDER_TYPE, text, 12, fg_color, bg_color, parrent), m_min(min), m_max(max), m_value(value), m_unit(unit) + double value, QObject *parent) + : UI_item(UI_SLIDER_TYPE, text, 12, fg_color, bg_color, parent), m_min(min), m_max(max), m_value(value), m_unit(unit) { } UI_slider::UI_slider(std::string text, Color fg_color, Color bg_color, double min, double max, double value, - QObject *parrent) - : UI_slider(text, "", fg_color, bg_color, min, max, value, parrent) + QObject *parent) + : UI_slider(text, "", fg_color, bg_color, min, max, value, parent) { } -UI_slider::UI_slider(const json &j, QObject *parrent) : UI_item(UI_SLIDER_TYPE, parrent) +UI_slider::UI_slider(const json &j, QObject *parent) : UI_item(UI_SLIDER_TYPE, parent) { from_json(j); } diff --git a/src/UI/UI_slider.hpp b/src/UI/UI_slider.hpp index 428a717..7be0fb6 100644 --- a/src/UI/UI_slider.hpp +++ b/src/UI/UI_slider.hpp @@ -8,10 +8,10 @@ class UI_slider : public UI_item Q_OBJECT public: UI_slider(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, double value, - QObject *parrent = nullptr); + QObject *parent = nullptr); UI_slider(std::string text, Color fg_color, Color bg_color, double min, double max, double value, - QObject *parrent = nullptr); - UI_slider(const json &j, QObject *parrent = nullptr); + QObject *parent = nullptr); + UI_slider(const json &j, QObject *parent = nullptr); void set_value(double value) override; double value() const; diff --git a/src/UI/UI_textbox.cpp b/src/UI/UI_textbox.cpp index c260551..85a9145 100644 --- a/src/UI/UI_textbox.cpp +++ b/src/UI/UI_textbox.cpp @@ -1,11 +1,11 @@ #include "UI_textbox.hpp" -UI_textbox::UI_textbox(std::string hint, Color fg_color, Color bg_color, QObject *parrent) - : UI_item(UI_TEXTBOX_TYPE, "", 0, fg_color, bg_color, parrent), m_hint(hint) +UI_textbox::UI_textbox(std::string hint, Color fg_color, Color bg_color, QObject *parent) + : UI_item(UI_TEXTBOX_TYPE, "", 0, fg_color, bg_color, parent), m_hint(hint) { } -UI_textbox::UI_textbox(const json &j, QObject *parrent) : UI_item(UI_TEXTBOX_TYPE, parrent) +UI_textbox::UI_textbox(const json &j, QObject *parent) : UI_item(UI_TEXTBOX_TYPE, parent) { from_json(j); } diff --git a/src/UI/UI_textbox.hpp b/src/UI/UI_textbox.hpp index f5cbdf5..728e59e 100644 --- a/src/UI/UI_textbox.hpp +++ b/src/UI/UI_textbox.hpp @@ -8,8 +8,8 @@ class UI_textbox : public UI_item { Q_OBJECT public: - UI_textbox(std::string hint, Color fg_color, Color bg_color, QObject *parrent = nullptr); - UI_textbox(const json &j, QObject *parrent = nullptr); + UI_textbox(std::string hint, Color fg_color, Color bg_color, QObject *parent = nullptr); + UI_textbox(const json &j, QObject *parent = nullptr); void set_text(std::string text) override; diff --git a/src/UI/UI_thermo.cpp b/src/UI/UI_thermo.cpp index cc2bdbf..8b149d0 100644 --- a/src/UI/UI_thermo.cpp +++ b/src/UI/UI_thermo.cpp @@ -1,18 +1,18 @@ #include "UI_thermo.hpp" UI_thermo::UI_thermo(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, - double value, QObject *parrent) - : UI_item(UI_THERMO_TYPE, text, 12, fg_color, bg_color, parrent), m_min(min), m_max(max), m_value(value), m_unit(unit) + double value, QObject *parent) + : UI_item(UI_THERMO_TYPE, text, 12, fg_color, bg_color, parent), m_min(min), m_max(max), m_value(value), m_unit(unit) { } UI_thermo::UI_thermo(std::string text, Color fg_color, Color bg_color, double min, double max, double value, - QObject *parrent) - : UI_thermo(text, "", fg_color, bg_color, min, max, value, parrent) + QObject *parent) + : UI_thermo(text, "", fg_color, bg_color, min, max, value, parent) { } -UI_thermo::UI_thermo(const json &j, QObject *parrent) : UI_item(UI_THERMO_TYPE, parrent) +UI_thermo::UI_thermo(const json &j, QObject *parent) : UI_item(UI_THERMO_TYPE, parent) { from_json(j); } diff --git a/src/UI/UI_thermo.hpp b/src/UI/UI_thermo.hpp index 50dcbe0..0735303 100644 --- a/src/UI/UI_thermo.hpp +++ b/src/UI/UI_thermo.hpp @@ -9,10 +9,10 @@ class UI_thermo : public UI_item Q_OBJECT public: UI_thermo(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, double value, - QObject *parrent = nullptr); + QObject *parent = nullptr); UI_thermo(std::string text, Color fg_color, Color bg_color, double min, double max, double value, - QObject *parrent = nullptr); - UI_thermo(const json &j, QObject *parrent = nullptr); + QObject *parent = nullptr); + UI_thermo(const json &j, QObject *parent = nullptr); void set_value(double value) override; double value() const; diff --git a/src/UI/UI_x_boxes.cpp b/src/UI/UI_x_boxes.cpp index 0a9cf54..29def9e 100644 --- a/src/UI/UI_x_boxes.cpp +++ b/src/UI/UI_x_boxes.cpp @@ -1,12 +1,12 @@ #include "UI_x_boxes.hpp" -UI_x_boxes::UI_x_boxes(std::string type, QObject *parrent) : UI_item(type, parrent), m_options() +UI_x_boxes::UI_x_boxes(std::string type, QObject *parent) : UI_item(type, parent), m_options() { } UI_x_boxes::UI_x_boxes(std::string type, std::string text, Color fg_color, Color bg_color, - std::vector options, QObject *parrent) - : UI_item(type, text, 12, fg_color, bg_color, parrent), m_options(options) + std::vector options, QObject *parent) + : UI_item(type, text, 12, fg_color, bg_color, parent), m_options(options) { } diff --git a/src/UI/UI_x_boxes.hpp b/src/UI/UI_x_boxes.hpp index e7ba1b7..071cf12 100644 --- a/src/UI/UI_x_boxes.hpp +++ b/src/UI/UI_x_boxes.hpp @@ -6,9 +6,9 @@ class UI_x_boxes : public UI_item { Q_OBJECT public: - UI_x_boxes(std::string type, QObject *parrent = nullptr); + UI_x_boxes(std::string type, QObject *parent = nullptr); UI_x_boxes(std::string type, std::string text, Color fg_color, Color bg_color, - std::vector options, QObject *parrent = nullptr); + std::vector options, QObject *parent = nullptr); void from_json(const json &j) override; json to_json(size_t id) const override; diff --git a/tools/simulator_base.cpp b/tools/simulator_base.cpp index 7789a17..769c69e 100644 --- a/tools/simulator_base.cpp +++ b/tools/simulator_base.cpp @@ -1,7 +1,7 @@ #include "simulator_base.hpp" -Simulator_base::Simulator_base(std::string name, std::chrono::milliseconds interval, QObject *parrent) - : QObject(parrent), m_name(name), m_timer(new QTimer(this)), m_interval(interval) +Simulator_base::Simulator_base(std::string name, std::chrono::milliseconds interval, QObject *parent) + : QObject(parent), m_name(name), m_timer(new QTimer(this)), m_interval(interval) { connect(m_timer, &QTimer::timeout, this, [this] { timer(); }); m_UI_items.reserve(50); diff --git a/tools/simulator_base.hpp b/tools/simulator_base.hpp index 30aea13..915d142 100644 --- a/tools/simulator_base.hpp +++ b/tools/simulator_base.hpp @@ -15,7 +15,7 @@ class Simulator_base : public QObject * @param interval The interval of the timer (default is 100ms) */ Simulator_base(std::string name, std::chrono::milliseconds interval = std::chrono::milliseconds(100), - QObject *parrent = nullptr); + QObject *parent = nullptr); /** * @brief Returns the name of the simulator diff --git a/tools/simulators.cpp b/tools/simulators.cpp index c939d75..541a0a3 100644 --- a/tools/simulators.cpp +++ b/tools/simulators.cpp @@ -4,7 +4,7 @@ #include #include -Simulators::Simulators(uint16_t port, QObject *parrent) : QObject(parrent), m_server(new Websocket(port, this)) +Simulators::Simulators(uint16_t port, QObject *parent) : QObject(parent), m_server(new Websocket(port, this)) { INSERT_SIMULATOR(Test_Sim); INSERT_SIMULATOR(Can_Debugger); diff --git a/tools/simulators/test_sim.cpp b/tools/simulators/test_sim.cpp index 09de6ee..2a2b382 100644 --- a/tools/simulators/test_sim.cpp +++ b/tools/simulators/test_sim.cpp @@ -1,7 +1,7 @@ #include "test_sim.hpp" -Test_Sim::Test_Sim(QObject* parrent) : -Simulator_base("Test_Sim", std::chrono::milliseconds(1000), parrent), +Test_Sim::Test_Sim(QObject* parent) : +Simulator_base("Test_Sim", std::chrono::milliseconds(1000), parent), m_button("Off", Color(Color::White), Color(Color::Red)), m_combobox(Color(Color::White), Color(Color::Black), {"Option 1", "Option 2", "Option 3"}, 0), m_label("Label", Color(Color::White), Color(Color::Black)), diff --git a/tools/simulators/test_sim.hpp b/tools/simulators/test_sim.hpp index bd66131..a6e98a3 100644 --- a/tools/simulators/test_sim.hpp +++ b/tools/simulators/test_sim.hpp @@ -4,7 +4,7 @@ class Test_Sim : public Simulator_base { Q_OBJECT public: - Test_Sim(QObject* parrent = nullptr); + Test_Sim(QObject* parent = nullptr); void timer() override; void run_at_startup() override; private: