v0.0.3
This commit is contained in:
parent
2b4f09bb49
commit
a934520cd9
6 changed files with 180 additions and 36 deletions
98
Main.qml
98
Main.qml
|
|
@ -15,7 +15,7 @@ Window {
|
||||||
property color water_color: "#F00F7FAF"
|
property color water_color: "#F00F7FAF"
|
||||||
Material.accent: root.accent_color
|
Material.accent: root.accent_color
|
||||||
property int font_enlarged_text_size: 20
|
property int font_enlarged_text_size: 20
|
||||||
property int font_normal_text_size: 18
|
property int font_normal_text_size: 16
|
||||||
property double distance: 0
|
property double distance: 0
|
||||||
property int distance_count: 0
|
property int distance_count: 0
|
||||||
// visibility: Window.FullScreen
|
// visibility: Window.FullScreen
|
||||||
|
|
@ -180,7 +180,7 @@ Window {
|
||||||
height: max_thres_input.height
|
height: max_thres_input.height
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
color: root.accent_color
|
color: root.accent_color
|
||||||
font.pixelSize: root.font_normal_text_size
|
font.pointSize: root.font_normal_text_size
|
||||||
}
|
}
|
||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
|
|
@ -192,8 +192,9 @@ Window {
|
||||||
top: settings_label.bottom
|
top: settings_label.bottom
|
||||||
topMargin: 20
|
topMargin: 20
|
||||||
}
|
}
|
||||||
|
width: parent.width / 2
|
||||||
color: root.accent_color
|
color: root.accent_color
|
||||||
font.pixelSize: root.font_normal_text_size
|
font.pointSize: root.font_normal_text_size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -208,7 +209,7 @@ Window {
|
||||||
height: min_thres_input.height
|
height: min_thres_input.height
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
color: root.accent_color
|
color: root.accent_color
|
||||||
font.pixelSize: root.font_normal_text_size
|
font.pointSize: root.font_normal_text_size
|
||||||
}
|
}
|
||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
|
|
@ -220,8 +221,9 @@ Window {
|
||||||
top: max_thres_label.bottom
|
top: max_thres_label.bottom
|
||||||
topMargin: 20
|
topMargin: 20
|
||||||
}
|
}
|
||||||
|
width: parent.width / 2
|
||||||
color: root.accent_color
|
color: root.accent_color
|
||||||
font.pixelSize: root.font_normal_text_size
|
font.pointSize: root.font_normal_text_size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -236,7 +238,7 @@ Window {
|
||||||
height: alert_thres_input.height
|
height: alert_thres_input.height
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
color: root.accent_color
|
color: root.accent_color
|
||||||
font.pixelSize: root.font_normal_text_size
|
font.pointSize: root.font_normal_text_size
|
||||||
}
|
}
|
||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
|
|
@ -248,9 +250,29 @@ Window {
|
||||||
top: min_thres_label.bottom
|
top: min_thres_label.bottom
|
||||||
topMargin: 20
|
topMargin: 20
|
||||||
}
|
}
|
||||||
|
width: parent.width / 2
|
||||||
color: root.accent_color
|
color: root.accent_color
|
||||||
font.pixelSize: root.font_normal_text_size
|
font.pointSize: root.font_normal_text_size
|
||||||
}
|
}
|
||||||
|
CheckBox {
|
||||||
|
id: flip_bits_box
|
||||||
|
text: "Flip Bits"
|
||||||
|
checked: config.flipBits
|
||||||
|
anchors {
|
||||||
|
topMargin: 20
|
||||||
|
top: alert_thres_label.bottom
|
||||||
|
left: parent.left
|
||||||
|
}
|
||||||
|
width: parent.width - 20
|
||||||
|
contentItem: Text {
|
||||||
|
text: flip_bits_box.text
|
||||||
|
font.pointSize: root.font_normal_text_size
|
||||||
|
color: root.accent_color
|
||||||
|
leftPadding: flip_bits_box.indicator.width + flip_bits_box.spacing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: settings_error_label
|
id: settings_error_label
|
||||||
|
|
@ -259,7 +281,9 @@ Window {
|
||||||
visible: settings_error_text === "" ? false : true
|
visible: settings_error_text === "" ? false : true
|
||||||
anchors {
|
anchors {
|
||||||
topMargin: 20
|
topMargin: 20
|
||||||
top: alert_thres_label.bottom
|
top: flip_bits_box.bottom
|
||||||
|
bottom: flip_bits_box.top
|
||||||
|
bottomMargin: 10
|
||||||
left: parent.left
|
left: parent.left
|
||||||
horizontalCenter: parent.horizontalCenter
|
horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
|
|
@ -268,7 +292,52 @@ Window {
|
||||||
font.pixelSize: root.font_normal_text_size
|
font.pixelSize: root.font_normal_text_size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: reset_averages
|
||||||
|
anchors {
|
||||||
|
topMargin: 10
|
||||||
|
bottom: save_config.top
|
||||||
|
horizontalCenter: parent.horizontalCenter
|
||||||
|
}
|
||||||
|
color: "#F0121212"
|
||||||
|
width: parent.width / 2.5
|
||||||
|
height: 60
|
||||||
|
border {
|
||||||
|
width: 1
|
||||||
|
color: root.accent_color
|
||||||
|
}
|
||||||
|
radius: 3
|
||||||
|
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: "Reset Averages"
|
||||||
|
color: root.accent_color
|
||||||
|
font.pointSize: root.font_enlarged_text_size
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
property color settings_rect_pressed_prev: "#00000000"
|
||||||
|
property color settings_rect_entered_prev: "#00000000"
|
||||||
|
onEntered: {
|
||||||
|
settings_rect_entered_prev = save_config.color
|
||||||
|
save_config.color = "#5A1F1F1F"
|
||||||
|
}
|
||||||
|
onExited: {
|
||||||
|
save_config.color = settings_rect_entered_prev
|
||||||
|
}
|
||||||
|
onPressed: {
|
||||||
|
settings_rect_pressed_prev = save_config.color
|
||||||
|
save_config.color = "#5A1F4F1F"
|
||||||
|
settings_popup.close();
|
||||||
|
listener.resetAverages();
|
||||||
|
}
|
||||||
|
onReleased: {
|
||||||
|
save_config.color = settings_rect_pressed_prev
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: save_config
|
id: save_config
|
||||||
|
|
@ -310,7 +379,8 @@ Window {
|
||||||
let max = parseFloat(min_thres_input.text);
|
let max = parseFloat(min_thres_input.text);
|
||||||
let min = parseFloat(min_thres_input.text);
|
let min = parseFloat(min_thres_input.text);
|
||||||
let alert = parseFloat(alert_thres_input.text);
|
let alert = parseFloat(alert_thres_input.text);
|
||||||
console.log("Parsed values:", max, min, alert);
|
let flipBits = flip_bits_box.checked;
|
||||||
|
console.log("Parsed values:", max, min, alert, flip_bits_box.checked);
|
||||||
if(max < min) {
|
if(max < min) {
|
||||||
settings_error_label.settings_error_text = "Max cannot be less than min";
|
settings_error_label.settings_error_text = "Max cannot be less than min";
|
||||||
return;
|
return;
|
||||||
|
|
@ -319,20 +389,19 @@ Window {
|
||||||
settings_error_label.settings_error_text = "Alert must be between 0 to 100";
|
settings_error_label.settings_error_text = "Alert must be between 0 to 100";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let current_min_reading = Math.max(0, (parseFloat(min_thres_input.text)));
|
let current_min_reading = Math.max(0, (parseFloat(min_thres_input.text)));
|
||||||
let effective_max_reading = Math.max(0, (parseFloat(max_thres_input.text)) - current_min_reading);
|
let effective_max_reading = Math.max(0, (parseFloat(max_thres_input.text)) - current_min_reading);
|
||||||
let alert_effective_reading = (effective_max_reading * (100 - alert) / 100) + current_min_reading;
|
let alert_effective_reading = (effective_max_reading * (100 - alert) / 100) + current_min_reading;
|
||||||
console.log("Alert effective reading is: " + alert_effective_reading + " for value: " + alert);
|
console.log("Alert effective reading is: " + alert_effective_reading + " for value: " + alert);
|
||||||
listener.setAlert(alert_effective_reading);
|
listener.setConfig(alert_effective_reading, flipBits);
|
||||||
config.saveConfig(max_thres_input.text, min_thres_input.text, alert_thres_input.text);
|
config.saveConfig(max_thres_input.text, min_thres_input.text, alert_thres_input.text, flip_bits_box.checked);
|
||||||
settings_popup.close();
|
settings_popup.close();
|
||||||
}
|
}
|
||||||
onReleased: {
|
onReleased: {
|
||||||
save_config.color = settings_rect_pressed_prev
|
save_config.color = settings_rect_pressed_prev
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -507,7 +576,8 @@ Window {
|
||||||
let alert = parseFloat(alert_thres_input.text);
|
let alert = parseFloat(alert_thres_input.text);
|
||||||
let alert_effective_reading = (effective_max_reading * (100 - alert) / 100) + current_min_reading;
|
let alert_effective_reading = (effective_max_reading * (100 - alert) / 100) + current_min_reading;
|
||||||
console.log("Alert effective reading is: " + alert_effective_reading + " for value: " + alert);
|
console.log("Alert effective reading is: " + alert_effective_reading + " for value: " + alert);
|
||||||
listener.setAlert(alert_effective_reading);
|
|
||||||
|
listener.setConfig(alert_effective_reading, flip_bits_box.checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
distance_count += 1;
|
distance_count += 1;
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,15 @@ ConfigInterface::ConfigInterface(QObject *parent)
|
||||||
config.close();
|
config.close();
|
||||||
QJsonObject top = QJsonDocument::fromJson(data).object();
|
QJsonObject top = QJsonDocument::fromJson(data).object();
|
||||||
QString max, min, alert;
|
QString max, min, alert;
|
||||||
|
bool flipbits;
|
||||||
max = top["max_threshold"].toString();
|
max = top["max_threshold"].toString();
|
||||||
min = top["min_threshold"].toString();
|
min = top["min_threshold"].toString();
|
||||||
alert = top["alert_threshold"].toString();
|
alert = top["alert_threshold"].toString();
|
||||||
|
flipbits = top["flip_bits"].toBool();
|
||||||
setMax(max);
|
setMax(max);
|
||||||
setMin(min);
|
setMin(min);
|
||||||
setAlert(alert);
|
setAlert(alert);
|
||||||
|
setFlipBits(flipbits);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qDebug() << "File does not exist creating one...";
|
qDebug() << "File does not exist creating one...";
|
||||||
|
|
@ -47,7 +50,7 @@ ConfigInterface::ConfigInterface(QObject *parent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigInterface::saveConfig(QString max, QString min, QString alert)
|
void ConfigInterface::saveConfig(QString max, QString min, QString alert, bool flipbits)
|
||||||
{
|
{
|
||||||
auto paths = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
auto paths = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||||
qDebug() << "Got writable path as: " << paths;
|
qDebug() << "Got writable path as: " << paths;
|
||||||
|
|
@ -58,6 +61,7 @@ void ConfigInterface::saveConfig(QString max, QString min, QString alert)
|
||||||
top["max_threshold"] = max;
|
top["max_threshold"] = max;
|
||||||
top["min_threshold"] = min;
|
top["min_threshold"] = min;
|
||||||
top["alert_threshold"] = alert;
|
top["alert_threshold"] = alert;
|
||||||
|
top["flip_bits"] = flipbits;
|
||||||
setMax(max);
|
setMax(max);
|
||||||
setMin(min);
|
setMin(min);
|
||||||
setAlert(alert);
|
setAlert(alert);
|
||||||
|
|
@ -106,3 +110,16 @@ void ConfigInterface::setMin(const QString &newMin)
|
||||||
m_min = newMin;
|
m_min = newMin;
|
||||||
emit minChanged();
|
emit minChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ConfigInterface::flipBits() const
|
||||||
|
{
|
||||||
|
return m_flipBits;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigInterface::setFlipBits(bool newFlipBits)
|
||||||
|
{
|
||||||
|
if (m_flipBits == newFlipBits)
|
||||||
|
return;
|
||||||
|
m_flipBits = newFlipBits;
|
||||||
|
emit flipBitsChanged();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ class ConfigInterface : public QObject
|
||||||
Q_PROPERTY(QString min READ min WRITE setMin NOTIFY minChanged FINAL)
|
Q_PROPERTY(QString min READ min WRITE setMin NOTIFY minChanged FINAL)
|
||||||
Q_PROPERTY(QString max READ max WRITE setMax NOTIFY maxChanged FINAL)
|
Q_PROPERTY(QString max READ max WRITE setMax NOTIFY maxChanged FINAL)
|
||||||
Q_PROPERTY(QString alert READ alert WRITE setAlert NOTIFY alertChanged FINAL)
|
Q_PROPERTY(QString alert READ alert WRITE setAlert NOTIFY alertChanged FINAL)
|
||||||
|
Q_PROPERTY(bool flipBits READ flipBits WRITE setFlipBits NOTIFY flipBitsChanged FINAL)
|
||||||
public:
|
public:
|
||||||
explicit ConfigInterface(QObject *parent = nullptr);
|
explicit ConfigInterface(QObject *parent = nullptr);
|
||||||
QString alert() const;
|
QString alert() const;
|
||||||
|
|
@ -28,18 +29,24 @@ public:
|
||||||
QString min() const;
|
QString min() const;
|
||||||
void setMin(const QString &newMin);
|
void setMin(const QString &newMin);
|
||||||
|
|
||||||
|
bool flipBits() const;
|
||||||
|
void setFlipBits(bool newFlipBits);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void configData(QString max, QString min, QString alert);
|
void configData(QString max, QString min, QString alert, bool flipbits);
|
||||||
void alertChanged();
|
void alertChanged();
|
||||||
void maxChanged();
|
void maxChanged();
|
||||||
void minChanged();
|
void minChanged();
|
||||||
|
|
||||||
|
void flipBitsChanged();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void saveConfig(QString max, QString min, QString alert);
|
void saveConfig(QString max, QString min, QString alert, bool flipbits);
|
||||||
private:
|
private:
|
||||||
QString m_alert;
|
QString m_alert;
|
||||||
QString m_max;
|
QString m_max;
|
||||||
QString m_min;
|
QString m_min;
|
||||||
|
bool m_flipBits;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONFIGINTERFACE_H
|
#endif // CONFIGINTERFACE_H
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef MOVING_CONTAINER
|
#ifndef MOVING_CONTAINER
|
||||||
#define MOVING_CONTAINER
|
#define MOVING_CONTAINER
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
using ld = long double;
|
using ld = long double;
|
||||||
|
|
||||||
template<typename T> class average {
|
template<typename T> class average {
|
||||||
|
|
@ -21,11 +21,16 @@ public:
|
||||||
|
|
||||||
~average() {
|
~average() {
|
||||||
curr = head;
|
curr = head;
|
||||||
|
if(!curr)
|
||||||
|
return;
|
||||||
while(curr != nullptr) {
|
while(curr != nullptr) {
|
||||||
info *now = curr;
|
info *now = curr;
|
||||||
curr = curr->next;
|
curr = curr->next;
|
||||||
delete now;
|
delete now;
|
||||||
}
|
}
|
||||||
|
curr = nullptr;
|
||||||
|
head = nullptr;
|
||||||
|
tail = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int size() {
|
unsigned int size() {
|
||||||
|
|
@ -36,6 +41,22 @@ public:
|
||||||
return this->avg;
|
return this->avg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clear() {
|
||||||
|
curr = head;
|
||||||
|
if(!curr)
|
||||||
|
return;
|
||||||
|
while(curr != nullptr) {
|
||||||
|
info *now = curr;
|
||||||
|
curr = curr->next;
|
||||||
|
delete now;
|
||||||
|
}
|
||||||
|
qDebug() << "Clearing";
|
||||||
|
curr = nullptr;
|
||||||
|
head = nullptr;
|
||||||
|
tail = nullptr;
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void recalculate_average() {
|
void recalculate_average() {
|
||||||
curr = head;
|
curr = head;
|
||||||
this->avg = 0;
|
this->avg = 0;
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,19 @@ void UDPListener::setDistance(double newDistance)
|
||||||
emit distanceChanged();
|
emit distanceChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDPListener::setAlert(float distance)
|
void UDPListener::resetAverages()
|
||||||
{
|
{
|
||||||
|
averages.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UDPListener::setFlipBits(bool flip_bits)
|
||||||
|
{
|
||||||
|
m_flip_bits = flip_bits;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UDPListener::setConfig(float distance, bool flip_bits)
|
||||||
|
{
|
||||||
|
setFlipBits(flip_bits);
|
||||||
if(!command_socket) {
|
if(!command_socket) {
|
||||||
command_socket = new QUdpSocket(this);
|
command_socket = new QUdpSocket(this);
|
||||||
bool bind = command_socket->bind(8181);
|
bool bind = command_socket->bind(8181);
|
||||||
|
|
@ -57,6 +68,7 @@ void UDPListener::setAlert(float distance)
|
||||||
command_socket->close();
|
command_socket->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
averages.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDPListener::socketError(QString err)
|
void UDPListener::socketError(QString err)
|
||||||
|
|
@ -73,12 +85,25 @@ void UDPListener::startService()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDPListener::datagramRecieved(float distance)
|
void UDPListener::datagramRecieved(QByteArray data1, QByteArray data2)
|
||||||
{
|
{
|
||||||
qDebug() << "Data received in main class: " << distance;
|
std::string correct_order = "";
|
||||||
averages.push_back(distance);
|
#ifdef Q_OS_ANDROID
|
||||||
|
if(!m_flip_bits)
|
||||||
|
correct_order = "0x" + data2.toHex().toStdString();
|
||||||
|
else
|
||||||
|
correct_order = "0x" + data1.toHex().toStdString();
|
||||||
|
#else
|
||||||
|
if(!m_flip_bits)
|
||||||
|
correct_order = "0x" + data1.toHex().toStdString();
|
||||||
|
else
|
||||||
|
correct_order = "0x" + data2.toHex().toStdString();
|
||||||
|
#endif
|
||||||
|
float data = convertToFloat(correct_order);
|
||||||
|
qDebug() << "Data received in main class: " << data;
|
||||||
|
averages.push_back(data);
|
||||||
prev_time_point = std::chrono::high_resolution_clock::now();
|
prev_time_point = std::chrono::high_resolution_clock::now();
|
||||||
emit distanceReceived(distance, QDateTime::currentDateTime().toString("dd/mm/yyyy hh:mm:ss.z ap"));
|
emit distanceReceived(data, QDateTime::currentDateTime().toString("dd/mm/yyyy hh:mm:ss.z ap"));
|
||||||
if(averages.size() >= 5) {
|
if(averages.size() >= 5) {
|
||||||
this->m_distance = averages.get_average();
|
this->m_distance = averages.get_average();
|
||||||
emit distanceChanged();
|
emit distanceChanged();
|
||||||
|
|
@ -111,6 +136,14 @@ void UDPListener::connectionTimerTimedOut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float UDPListener::convertToFloat(std::string hex)
|
||||||
|
{
|
||||||
|
uint32_t num;
|
||||||
|
sscanf(hex.c_str(), "%x", &num);
|
||||||
|
float dist = *((float*)&num);
|
||||||
|
return dist;
|
||||||
|
}
|
||||||
|
|
||||||
Worker::Worker(QObject *parent)
|
Worker::Worker(QObject *parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -146,16 +179,8 @@ void Worker::socketDataReceived()
|
||||||
ch[i] = buff[3-i];
|
ch[i] = buff[3-i];
|
||||||
}
|
}
|
||||||
auto data2 = QByteArray(ch,4);
|
auto data2 = QByteArray(ch,4);
|
||||||
#ifdef Q_OS_ANDROID
|
std::string correct_order = "";
|
||||||
std::string correct_order = "0x" + data2.toHex().toStdString();
|
|
||||||
#else
|
|
||||||
std::string correct_order = "0x" + data2.toHex().toStdString();
|
|
||||||
#endif
|
|
||||||
qDebug() << "Distance received: " << correct_order;
|
qDebug() << "Distance received: " << correct_order;
|
||||||
uint32_t num;
|
emit datagramReceived(data, data2);
|
||||||
sscanf(correct_order.c_str(), "%x", &num);
|
|
||||||
float dist = *((float*)&num);
|
|
||||||
qDebug() << "Float is: " << dist;
|
|
||||||
emit datagramReceived(dist);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ public:
|
||||||
explicit Worker(QObject *parent = nullptr);
|
explicit Worker(QObject *parent = nullptr);
|
||||||
signals:
|
signals:
|
||||||
void socketError(QString error);
|
void socketError(QString error);
|
||||||
void datagramReceived(float distance);
|
void datagramReceived(QByteArray data, QByteArray data2);
|
||||||
public slots:
|
public slots:
|
||||||
void run();
|
void run();
|
||||||
private slots:
|
private slots:
|
||||||
|
|
@ -41,13 +41,16 @@ signals:
|
||||||
void disconnected();
|
void disconnected();
|
||||||
void distanceReceived(double dist, QString timestamp);
|
void distanceReceived(double dist, QString timestamp);
|
||||||
public slots:
|
public slots:
|
||||||
void setAlert(float distance);
|
void resetAverages();
|
||||||
|
void setFlipBits(bool flip_bits);
|
||||||
|
void setConfig(float distance, bool flip_bits);
|
||||||
void socketError(QString err);
|
void socketError(QString err);
|
||||||
void startService();
|
void startService();
|
||||||
void datagramRecieved(float distance);
|
void datagramRecieved(QByteArray data, QByteArray data2);
|
||||||
private slots:
|
private slots:
|
||||||
void destroy();
|
void destroy();
|
||||||
void connectionTimerTimedOut();
|
void connectionTimerTimedOut();
|
||||||
|
float convertToFloat(std::string hex);
|
||||||
private:
|
private:
|
||||||
QUdpSocket *command_socket = nullptr;
|
QUdpSocket *command_socket = nullptr;
|
||||||
std::chrono::time_point<std::chrono::high_resolution_clock> prev_time_point;
|
std::chrono::time_point<std::chrono::high_resolution_clock> prev_time_point;
|
||||||
|
|
@ -56,6 +59,7 @@ private:
|
||||||
Worker *worker = nullptr;
|
Worker *worker = nullptr;
|
||||||
QThread *thread = nullptr;
|
QThread *thread = nullptr;
|
||||||
QTimer *timer = nullptr;
|
QTimer *timer = nullptr;
|
||||||
|
bool m_flip_bits;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // UDPLISTENER_H
|
#endif // UDPLISTENER_H
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue