forked from vedderb/vesc_tool
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutility.h
More file actions
72 lines (59 loc) · 3.13 KB
/
Copy pathutility.h
File metadata and controls
72 lines (59 loc) · 3.13 KB
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
/*
Copyright 2017 Benjamin Vedder benjamin@vedder.se
This file is part of VESC Tool.
VESC Tool is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
VESC Tool is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UTILITY_H
#define UTILITY_H
#include <QObject>
#include <QMetaEnum>
#include <cstdint>
#include "vescinterface.h"
class Utility : public QObject
{
Q_OBJECT
public:
explicit Utility(QObject *parent = nullptr);
static double map(double x, double in_min, double in_max, double out_min, double out_max);
static float throttle_curve(float val, float curve_acc, float curve_brake, int mode);
static bool autoconnectBlockingWithProgress(VescInterface *vesc, QWidget *parent = 0);
Q_INVOKABLE static void checkVersion(VescInterface *vesc = 0);
Q_INVOKABLE static QString fwChangeLog();
Q_INVOKABLE static QString vescToolChangeLog();
Q_INVOKABLE static QString aboutText();
Q_INVOKABLE static QString uuid2Str(QByteArray uuid, bool space);
Q_INVOKABLE static bool requestFilePermission();
Q_INVOKABLE static void keepScreenOn(bool on);
Q_INVOKABLE static bool waitSignal(QObject *sender, QString signal, int timeoutMs);
Q_INVOKABLE static QString detectAllFoc(VescInterface *vesc,
bool detect_can, double max_power_loss, double min_current_in,
double max_current_in, double openloop_rpm, double sl_erpm);
Q_INVOKABLE static bool resetInputCan(VescInterface *vesc, QVector<int> canIds);
Q_INVOKABLE static bool setBatteryCutCan(VescInterface *vesc, QVector<int> canIds,
double cutStart, double cutEnd);
Q_INVOKABLE static bool setBatteryCutCanFromCurrentConfig(VescInterface *vesc, QVector<int> canIds);
Q_INVOKABLE static bool setInvertDirection(VescInterface *vesc, int canId, bool inverted);
Q_INVOKABLE static bool getInvertDirection(VescInterface *vesc, int canId);
Q_INVOKABLE static QString testDirection(VescInterface *vesc, int canId, double duty, int ms);
Q_INVOKABLE static bool restoreConfAll(VescInterface *vesc, bool can, bool mc, bool app);
Q_INVOKABLE static bool almostEqual(double A, double B, double eps);
static bool createParamParserC(VescInterface *vesc, QString filename);
static uint32_t crc32c(uint8_t *data, uint32_t len);
static bool checkFwCompatibility(VescInterface *vesc);
template<typename QEnum>
static QString QEnumToQString (const QEnum value) {
return QString(QMetaEnum::fromType<QEnum>().valueToKey(value));
}
signals:
public slots:
};
#endif // UTILITY_H