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
4f4d88ba
Commit
4f4d88ba
authored
Jun 06, 2013
by
Michael Carpenter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for min/max values of radio configuration sliders not being scaled appropriatly
parent
e9e36e41
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
12 deletions
+70
-12
QGCVehicleConfig.cc
src/ui/QGCVehicleConfig.cc
+25
-3
QGCVehicleConfig.h
src/ui/QGCVehicleConfig.h
+2
-0
QGCRadioChannelDisplay.cpp
src/ui/designer/QGCRadioChannelDisplay.cpp
+43
-9
No files found.
src/ui/QGCVehicleConfig.cc
View file @
4f4d88ba
...
...
@@ -1182,6 +1182,7 @@ void QGCVehicleConfig::parameterChanged(int uas, int component, QString paramete
if
(
ok
&&
index
<
chanMax
)
{
rcMin
[
index
]
=
value
.
toInt
();
updateMinMax
();
}
}
...
...
@@ -1191,6 +1192,7 @@ void QGCVehicleConfig::parameterChanged(int uas, int component, QString paramete
if
(
ok
&&
index
<
chanMax
)
{
rcMax
[
index
]
=
value
.
toInt
();
updateMinMax
();
}
}
...
...
@@ -1323,6 +1325,26 @@ void QGCVehicleConfig::updateError(const QString& str)
ui
->
statusLabel
->
setText
(
str
);
ui
->
statusLabel
->
setStyleSheet
(
QString
(
"QLabel { margin: 0px 2px; font: 14px; color: %1; background-color: %2; }"
).
arg
(
QGC
::
colorDarkWhite
.
name
()).
arg
(
QGC
::
colorMagenta
.
name
()));
}
void
QGCVehicleConfig
::
updateMinMax
()
{
// Order is: roll, pitch, yaw, throttle, mode sw, aux 1-3
/*ui->rollWidget->setMin(rcMin[0]);
ui->rollWidget->setMax(rcMax[0]);
ui->pitchWidget->setMin(rcMin[1]);
ui->pitchWidget->setMax(rcMax[1]);
ui->yawWidget->setMin(rcMin[2]);
ui->yawWidget->setMax(rcMax[2]);
ui->throttleWidget->setMin(rcMin[3]);
ui->throttleWidget->setMax(rcMax[3]);
ui->radio5Widget->setMin(rcMin[4]);
ui->radio5Widget->setMax(rcMax[4]);
ui->radio6Widget->setMin(rcMin[5]);
ui->radio6Widget->setMax(rcMax[5]);
ui->radio7Widget->setMin(rcMin[6]);
ui->radio7Widget->setMax(rcMax[6]);
ui->radio8Widget->setMin(rcMin[7]);
ui->radio8Widget->setMax(rcMax[7]);*/
}
void
QGCVehicleConfig
::
setRCType
(
int
type
)
{
...
...
@@ -1466,7 +1488,7 @@ void QGCVehicleConfig::updateView()
if
(
rcValue
[
rcMapping
[
5
]]
!=
UINT16_MAX
)
{
//ui->aux1Slider->setValue(rcAux1 * 50 + 50);
ui
->
radio
5
Widget
->
setValue
(
rcValue
[
5
]);
ui
->
radio
6
Widget
->
setValue
(
rcValue
[
5
]);
ui
->
chanLabel_6
->
setText
(
QString
(
"%1/%2"
).
arg
(
rcValue
[
rcMapping
[
5
]]).
arg
(
rcAux1
,
5
,
'f'
,
2
,
QChar
(
' '
)));
}
else
{
ui
->
chanLabel_6
->
setText
(
tr
(
"---"
));
...
...
@@ -1474,7 +1496,7 @@ void QGCVehicleConfig::updateView()
if
(
rcValue
[
rcMapping
[
6
]]
!=
UINT16_MAX
)
{
//ui->aux2Slider->setValue(rcAux2 * 50 + 50);
ui
->
radio
6
Widget
->
setValue
(
rcValue
[
6
]);
ui
->
radio
7
Widget
->
setValue
(
rcValue
[
6
]);
ui
->
chanLabel_7
->
setText
(
QString
(
"%1/%2"
).
arg
(
rcValue
[
rcMapping
[
6
]]).
arg
(
rcAux2
,
5
,
'f'
,
2
,
QChar
(
' '
)));
}
else
{
ui
->
chanLabel_7
->
setText
(
tr
(
"---"
));
...
...
@@ -1482,7 +1504,7 @@ void QGCVehicleConfig::updateView()
if
(
rcValue
[
rcMapping
[
7
]]
!=
UINT16_MAX
)
{
//ui->aux3Slider->setValue(rcAux3 * 50 + 50);
ui
->
radio
7
Widget
->
setValue
(
rcValue
[
7
]);
ui
->
radio
8
Widget
->
setValue
(
rcValue
[
7
]);
ui
->
chanLabel_8
->
setText
(
QString
(
"%1/%2"
).
arg
(
rcValue
[
rcMapping
[
7
]]).
arg
(
rcAux3
,
5
,
'f'
,
2
,
QChar
(
' '
)));
}
else
{
ui
->
chanLabel_8
->
setText
(
tr
(
"---"
));
...
...
src/ui/QGCVehicleConfig.h
View file @
4f4d88ba
...
...
@@ -57,6 +57,8 @@ public slots:
/** Render the data updated */
void
updateView
();
void
updateMinMax
();
/** Set the RC channel */
void
setRollChan
(
int
channel
)
{
rcMapping
[
0
]
=
channel
-
1
;
...
...
src/ui/designer/QGCRadioChannelDisplay.cpp
View file @
4f4d88ba
...
...
@@ -4,7 +4,7 @@ QGCRadioChannelDisplay::QGCRadioChannelDisplay(QWidget *parent) : QWidget(parent
{
m_showMinMax
=
false
;
m_min
=
0
;
m_max
=
0
;
m_max
=
1
;
m_value
=
1500
;
m_orientation
=
Qt
::
Vertical
;
m_name
=
"Yaw"
;
...
...
@@ -26,14 +26,36 @@ void QGCRadioChannelDisplay::paintEvent(QPaintEvent *event)
//1500 is the middle, static servo value.
QPainter
painter
(
this
);
int
currval
=
m_value
;
if
(
currval
>
m_max
)
{
currval
=
m_max
;
}
if
(
currval
<
m_min
)
{
currval
=
m_min
;
}
if
(
m_orientation
==
Qt
::
Vertical
)
{
painter
.
drawRect
(
0
,
0
,
width
()
-
1
,(
height
()
-
1
)
-
(
painter
.
fontMetrics
().
height
()
*
2
));
painter
.
setBrush
(
Qt
::
SolidPattern
);
painter
.
setPen
(
QColor
::
fromRgb
(
50
,
255
,
50
));
int
newval
=
(
height
()
-
2
-
(
painter
.
fontMetrics
().
height
()
*
2
))
*
((
float
)
m_value
/
3001.0
);
int
newvaly
=
(
height
()
-
2
-
(
painter
.
fontMetrics
().
height
()
*
2
))
-
newval
;
painter
.
drawRect
(
1
,
newvaly
,
width
()
-
3
,((
height
()
-
2
)
-
newvaly
-
(
painter
.
fontMetrics
().
height
()
*
2
)));
//m_value - m_min / m_max - m_min
if
(
!
m_showMinMax
)
{
int
newval
=
(
height
()
-
2
-
(
painter
.
fontMetrics
().
height
()
*
2
))
*
((
float
)(
currval
-
m_min
)
/
((
m_max
-
m_min
)
+
1
));
int
newvaly
=
(
height
()
-
2
-
(
painter
.
fontMetrics
().
height
()
*
2
))
-
newval
;
painter
.
drawRect
(
1
,
newvaly
,
width
()
-
3
,((
height
()
-
2
)
-
newvaly
-
(
painter
.
fontMetrics
().
height
()
*
2
)));
}
else
{
int
newval
=
(
height
()
-
2
-
(
painter
.
fontMetrics
().
height
()
*
2
))
*
((
float
)(
currval
/
3001.0
));
int
newvaly
=
(
height
()
-
2
-
(
painter
.
fontMetrics
().
height
()
*
2
))
-
newval
;
painter
.
drawRect
(
1
,
newvaly
,
width
()
-
3
,((
height
()
-
2
)
-
newvaly
-
(
painter
.
fontMetrics
().
height
()
*
2
)));
}
QString
valstr
=
QString
::
number
(
m_value
);
painter
.
setPen
(
QColor
::
fromRgb
(
255
,
255
,
255
));
painter
.
drawText
((
width
()
/
2.0
)
-
(
painter
.
fontMetrics
().
width
(
m_name
)
/
2.0
),((
height
()
-
3
)
-
(
painter
.
fontMetrics
().
height
()
*
1
)),
m_name
);
...
...
@@ -44,10 +66,7 @@ void QGCRadioChannelDisplay::paintEvent(QPaintEvent *event)
painter
.
setPen
(
QColor
::
fromRgb
(
255
,
0
,
0
));
int
maxyval
=
(
height
()
-
3
-
(
painter
.
fontMetrics
().
height
()
*
2
))
-
(((
height
()
-
3
-
(
painter
.
fontMetrics
().
height
()
*
2
))
*
((
float
)
m_max
/
3000.0
)));
int
minyval
=
(
height
()
-
3
-
(
painter
.
fontMetrics
().
height
()
*
2
))
-
(((
height
()
-
3
-
(
painter
.
fontMetrics
().
height
()
*
2
))
*
((
float
)
m_min
/
3000.0
)));
painter
.
drawRect
(
2
,
maxyval
,
width
()
-
3
,
minyval
-
maxyval
);
painter
.
drawRect
(
2
,
maxyval
,
width
()
-
3
,
minyval
-
maxyval
);
QString
minstr
=
QString
::
number
(
m_min
);
painter
.
drawText
((
width
()
/
2.0
)
-
(
painter
.
fontMetrics
().
width
(
"min"
)
/
2.0
),
minyval
,
"min"
);
painter
.
drawText
((
width
()
/
2.0
)
-
(
painter
.
fontMetrics
().
width
(
minstr
)
/
2.0
),
minyval
+
painter
.
fontMetrics
().
height
(),
minstr
);
...
...
@@ -64,7 +83,14 @@ void QGCRadioChannelDisplay::paintEvent(QPaintEvent *event)
painter
.
drawRect
(
0
,
0
,
width
()
-
1
,(
height
()
-
1
)
-
(
painter
.
fontMetrics
().
height
()
*
2
));
painter
.
setBrush
(
Qt
::
SolidPattern
);
painter
.
setPen
(
QColor
::
fromRgb
(
50
,
255
,
50
));
painter
.
drawRect
(
1
,
1
,(
width
()
-
3
)
*
((
float
)
m_value
/
3000.0
),(
height
()
-
3
)
-
(
painter
.
fontMetrics
().
height
()
*
2
));
if
(
!
m_showMinMax
)
{
painter
.
drawRect
(
1
,
1
,(
width
()
-
3
)
*
((
float
)(
currval
-
m_min
)
/
(
m_max
-
m_min
)),(
height
()
-
3
)
-
(
painter
.
fontMetrics
().
height
()
*
2
));
}
else
{
painter
.
drawRect
(
1
,
1
,(
width
()
-
3
)
*
((
float
)
currval
/
3000.0
),(
height
()
-
3
)
-
(
painter
.
fontMetrics
().
height
()
*
2
));
}
painter
.
setPen
(
QColor
::
fromRgb
(
255
,
255
,
255
));
QString
valstr
=
QString
::
number
(
m_value
);
painter
.
drawText
((
width
()
/
2.0
)
-
(
painter
.
fontMetrics
().
width
(
m_name
)
/
2.0
),((
height
()
-
3
)
-
(
painter
.
fontMetrics
().
height
()
*
1
)),
m_name
);
...
...
@@ -118,11 +144,19 @@ void QGCRadioChannelDisplay::hideMinMax()
void
QGCRadioChannelDisplay
::
setMin
(
int
value
)
{
m_min
=
value
;
if
(
m_min
==
m_max
)
{
m_min
--
;
}
update
();
}
void
QGCRadioChannelDisplay
::
setMax
(
int
value
)
{
m_max
=
value
;
if
(
m_min
==
m_max
)
{
m_max
++
;
}
update
();
}
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