This commit is contained in:
2026-02-14 14:30:25 +01:00
parent d3c0cb1066
commit ee5c156e56
48 changed files with 549 additions and 510 deletions
-1
View File
@@ -7,7 +7,6 @@ UI_checkbox::UI_checkbox(QObject *parent) : UI_item(UI_CHECKBOX_TYPE, parent), m
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 *parent) : UI_item(UI_CHECKBOX_TYPE, parent), m_selected()
+1 -2
View File
@@ -9,8 +9,7 @@ class UI_checkbox : public UI_item
Q_OBJECT
public:
UI_checkbox(QObject *parent = nullptr);
UI_checkbox(std::string text, Color fg_color, Color bg_color,
QObject *parent = nullptr);
UI_checkbox(std::string text, Color fg_color, Color bg_color, QObject *parent = nullptr);
UI_checkbox(const json &j, QObject *parent = nullptr);
void toggle_selected();
+2 -2
View File
@@ -4,8 +4,8 @@ UI_combobox::UI_combobox(QObject *parent) : UI_x_boxes(UI_COMBOBOX_TYPE, parent)
{
}
UI_combobox::UI_combobox(Color fg_color, Color bg_color,
std::vector<std::string> options, size_t selected, QObject *parent)
UI_combobox::UI_combobox(Color fg_color, Color bg_color, std::vector<std::string> options, size_t selected,
QObject *parent)
: UI_x_boxes(UI_COMBOBOX_TYPE, "", fg_color, bg_color, options, parent), m_selected(selected)
{
}
+2 -2
View File
@@ -11,8 +11,8 @@ class UI_combobox : public UI_x_boxes
Q_OBJECT
public:
UI_combobox(QObject *parent = nullptr);
UI_combobox(Color fg_color, Color bg_color, std::vector<std::string> options,
size_t selected = 0, QObject *parent = nullptr);
UI_combobox(Color fg_color, Color bg_color, std::vector<std::string> options, size_t selected = 0,
QObject *parent = nullptr);
UI_combobox(const json &j, QObject *parent = nullptr);
void set_selected(size_t selected);
+5 -7
View File
@@ -1,20 +1,18 @@
#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 *parent)
UI_dial::UI_dial(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max,
double value, 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 *parent)
UI_dial::UI_dial(std::string text, Color fg_color, Color bg_color, double min, double max, double value,
QObject *parent)
: UI_dial(text, "", fg_color, bg_color, min, max, value, parent)
{
}
UI_dial::UI_dial(const json &j, QObject *parent)
: UI_item(UI_DIAL_TYPE, parent)
UI_dial::UI_dial(const json &j, QObject *parent) : UI_item(UI_DIAL_TYPE, parent)
{
from_json(j);
}
+1 -3
View File
@@ -1,7 +1,6 @@
#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 *parent)
UI_item::UI_item(std::string type, std::string text, uint8_t text_size, Color fg_color, Color bg_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)
{
@@ -171,5 +170,4 @@ void UI_item::can_send(uint32_t id, uint8_t dlc, std::array<uint8_t, 8> payload)
void UI_item::can_clear()
{
}
+3 -3
View File
@@ -6,8 +6,8 @@
#include <string>
#include <thread>
#include <QObject>
#include <QCanBusFrame>
#include <QObject>
using json = nlohmann::json;
#define UNUSED(x) (void)(x)
@@ -17,8 +17,8 @@ class UI_item : public QObject
Q_OBJECT
public:
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 *parent = nullptr);
explicit UI_item(std::string type, std::string text, uint8_t text_size, Color fg_color, Color bg_color,
QObject *parent = nullptr);
explicit UI_item(const json &j, QObject *parent = nullptr);
~UI_item();
+1 -2
View File
@@ -8,8 +8,7 @@ class UI_led : public UI_item
{
Q_OBJECT
public:
UI_led(std::string text, Color fg_color, Color bg_color, Color led_color,
QObject *parent = nullptr);
UI_led(std::string text, Color fg_color, Color bg_color, Color led_color, QObject *parent = nullptr);
UI_led(const json &j, QObject *parent = nullptr);
Color led_color() const;
+5 -5
View File
@@ -2,17 +2,17 @@
UI_slider::UI_slider(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max,
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_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 *parent)
: UI_slider(text, "", fg_color, bg_color, min, max, value, parent)
QObject *parent)
: UI_slider(text, "", fg_color, bg_color, min, max, value, parent)
{
}
UI_slider::UI_slider(const json &j, QObject *parent) : UI_item(UI_SLIDER_TYPE, parent)
{
from_json(j);
+2 -1
View File
@@ -2,7 +2,8 @@
UI_thermo::UI_thermo(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max,
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_item(UI_THERMO_TYPE, text, 12, fg_color, bg_color, parent), m_min(min), m_max(max), m_value(value),
m_unit(unit)
{
}
+2 -2
View File
@@ -7,8 +7,8 @@ class UI_x_boxes : public UI_item
Q_OBJECT
public:
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<std::string> options, QObject *parent = nullptr);
UI_x_boxes(std::string type, std::string text, Color fg_color, Color bg_color, std::vector<std::string> options,
QObject *parent = nullptr);
void from_json(const json &j) override;
json to_json(size_t id) const override;
+4 -2
View File
@@ -24,14 +24,16 @@ UI_can::UI_can(const json &j, QObject *parent) : UI_item(UI_CAN_TYPE, parent)
void UI_can::add_send_message(QCanBusFrame msg)
{
CanFrame frame(msg.frameId(), (uint8_t)msg.payload().size(), ByteArrayToStdArray<std::array<uint8_t, 8>>(msg.payload()));
CanFrame frame(msg.frameId(), (uint8_t)msg.payload().size(),
ByteArrayToStdArray<std::array<uint8_t, 8>>(msg.payload()));
m_can_send_messages.push_back(frame);
emit value_changed();
}
void UI_can::add_received_message(QCanBusFrame msg)
{
CanFrame frame(msg.frameId(), (uint8_t)msg.payload().size(), ByteArrayToStdArray<std::array<uint8_t, 8>>(msg.payload()));
CanFrame frame(msg.frameId(), (uint8_t)msg.payload().size(),
ByteArrayToStdArray<std::array<uint8_t, 8>>(msg.payload()));
m_can_received_messages.push_back(frame);
emit value_changed();
}
+2 -3
View File
@@ -8,10 +8,8 @@
class CanFrame
{
public:
CanFrame(uint32_t sid, uint8_t dlc, std::array<uint8_t, 8> payload)
: m_SID(sid), m_DLC(dlc), m_payload(payload)
CanFrame(uint32_t sid, uint8_t dlc, std::array<uint8_t, 8> payload) : m_SID(sid), m_DLC(dlc), m_payload(payload)
{
}
uint32_t m_SID;
uint8_t m_DLC;
@@ -37,6 +35,7 @@ class UI_can : public UI_item
void can_clear() override;
signals:
void on_send(QCanBusFrame msg);
private:
std::vector<CanFrame> m_can_send_messages;
std::vector<CanFrame> m_can_received_messages;