Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
7c101d17
Commit
7c101d17
authored
Sep 20, 2010
by
Bryan Godbolt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filled in curve calibrator functions
parent
95011df1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
11 deletions
+71
-11
AbstractCalibrator.cc
src/ui/RadioCalibration/AbstractCalibrator.cc
+1
-1
AbstractCalibrator.h
src/ui/RadioCalibration/AbstractCalibrator.h
+2
-0
CurveCalibrator.cc
src/ui/RadioCalibration/CurveCalibrator.cc
+54
-6
CurveCalibrator.h
src/ui/RadioCalibration/CurveCalibrator.h
+14
-4
No files found.
src/ui/RadioCalibration/AbstractCalibrator.cc
View file @
7c101d17
...
...
@@ -17,7 +17,7 @@ float AbstractCalibrator::logAverage()
float
total
=
0
;
for
(
int
i
=
0
;
i
<
log
->
size
();
++
i
)
total
+=
log
->
value
(
i
);
return
(
total
/
log
->
size
());
return
floor
(
total
/
log
->
size
());
}
float
AbstractCalibrator
::
logExtrema
()
...
...
src/ui/RadioCalibration/AbstractCalibrator.h
View file @
7c101d17
...
...
@@ -5,6 +5,8 @@
#include <QString>
#include <QLabel>
#include <math.h>
class
AbstractCalibrator
:
public
QWidget
{
Q_OBJECT
...
...
src/ui/RadioCalibration/CurveCalibrator.cc
View file @
7c101d17
...
...
@@ -2,9 +2,8 @@
CurveCalibrator
::
CurveCalibrator
(
QString
titleString
,
QWidget
*
parent
)
:
AbstractCalibrator
(
parent
),
setpoints
(
QVector
<
double
>
(
5
)),
positions
(
QVector
<
double
>
())
setpoints
(
new
QVector
<
double
>
(
5
)),
positions
(
new
QVector
<
double
>
())
{
QGridLayout
*
grid
=
new
QGridLayout
(
this
);
QLabel
*
title
=
new
QLabel
(
titleString
);
...
...
@@ -18,10 +17,10 @@ CurveCalibrator::CurveCalibrator(QString titleString, QWidget *parent) :
grid
->
addLayout
(
pulseLayout
,
1
,
0
,
1
,
5
,
Qt
::
AlignHCenter
);
for
(
int
i
=
0
;
i
<=
100
;
i
=
i
+
100
/
4
)
positions
.
append
(
static_cast
<
double
>
(
i
));
positions
->
append
(
static_cast
<
double
>
(
i
));
setpoints
.
fill
(
1500
);
setpoints
->
fill
(
1500
);
plot
=
new
QwtPlot
();
...
...
@@ -29,13 +28,62 @@ CurveCalibrator::CurveCalibrator(QString titleString, QWidget *parent) :
plot
->
setAxisScale
(
QwtPlot
::
yLeft
,
1000
,
2000
,
200
);
plot
->
setAxisScale
(
QwtPlot
::
xBottom
,
0
,
100
,
25
);
curve
=
new
QwtPlotCurve
();
curve
->
setData
(
positions
,
setpoints
);
curve
->
setPen
(
QPen
(
QColor
(
QString
(
"lime"
))));
curve
->
setData
(
*
positions
,
*
setpoints
);
curve
->
attach
(
plot
);
plot
->
replot
();
QPushButton
*
zero
=
new
QPushButton
(
tr
(
"0 %"
));
QPushButton
*
twentyfive
=
new
QPushButton
(
tr
(
"25 %"
));
QPushButton
*
fifty
=
new
QPushButton
(
tr
(
"50 %"
));
QPushButton
*
seventyfive
=
new
QPushButton
(
tr
(
"75 %"
));
QPushButton
*
hundred
=
new
QPushButton
(
tr
(
"100 %"
));
grid
->
addWidget
(
zero
,
3
,
0
);
grid
->
addWidget
(
twentyfive
,
3
,
1
);
grid
->
addWidget
(
fifty
,
3
,
2
);
grid
->
addWidget
(
seventyfive
,
3
,
3
);
grid
->
addWidget
(
hundred
,
3
,
4
);
this
->
setLayout
(
grid
);
signalMapper
=
new
QSignalMapper
(
this
);
signalMapper
->
setMapping
(
zero
,
0
);
signalMapper
->
setMapping
(
twentyfive
,
1
);
signalMapper
->
setMapping
(
fifty
,
2
);
signalMapper
->
setMapping
(
seventyfive
,
3
);
signalMapper
->
setMapping
(
hundred
,
4
);
connect
(
zero
,
SIGNAL
(
clicked
()),
signalMapper
,
SLOT
(
map
()));
connect
(
twentyfive
,
SIGNAL
(
clicked
()),
signalMapper
,
SLOT
(
map
()));
connect
(
fifty
,
SIGNAL
(
clicked
()),
signalMapper
,
SLOT
(
map
()));
connect
(
seventyfive
,
SIGNAL
(
clicked
()),
signalMapper
,
SLOT
(
map
()));
connect
(
hundred
,
SIGNAL
(
clicked
()),
signalMapper
,
SLOT
(
map
()));
connect
(
signalMapper
,
SIGNAL
(
mapped
(
int
)),
this
,
SLOT
(
setSetpoint
(
int
)));
}
CurveCalibrator
::~
CurveCalibrator
()
{
delete
setpoints
;
delete
positions
;
}
void
CurveCalibrator
::
setSetpoint
(
int
setpoint
)
{
if
(
setpoint
==
0
||
setpoint
==
4
)
{
setpoints
->
replace
(
setpoint
,
static_cast
<
double
>
(
logExtrema
()));
}
else
{
setpoints
->
replace
(
setpoint
,
static_cast
<
double
>
(
logAverage
()));
}
plot
->
replot
();
emit
setpointChanged
(
setpoint
,
static_cast
<
float
>
(
setpoints
->
value
(
setpoint
)));
}
src/ui/RadioCalibration/CurveCalibrator.h
View file @
7c101d17
...
...
@@ -9,6 +9,11 @@
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QPen>
#include <QColor>
#include <QString>
#include <QSignalMapper>
#include <QDebug>
#include "AbstractCalibrator.h"
...
...
@@ -17,15 +22,20 @@ class CurveCalibrator : public AbstractCalibrator
Q_OBJECT
public:
explicit
CurveCalibrator
(
QString
title
=
QString
(),
QWidget
*
parent
=
0
);
~
CurveCalibrator
();
signals:
void
setpointChanged
(
float
[
5
]);
void
setpointChanged
(
int
setpoint
,
float
raw
);
protected
slots
:
void
setSetpoint
(
int
setpoint
);
protected:
QVector
<
double
>
setpoints
;
QVector
<
double
>
positions
;
QVector
<
double
>
*
setpoints
;
QVector
<
double
>
*
positions
;
QwtPlot
*
plot
;
QwtPlotCurve
*
curve
;
QSignalMapper
*
signalMapper
;
};
#endif // CURVECALIBRATOR_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment