Skip to content

Commit a06bc68

Browse files
committed
GRInstantInfoBox show average GR on comment label
1 parent 81efed4 commit a06bc68

6 files changed

Lines changed: 27 additions & 7 deletions

File tree

‎NEWS.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Version JET
1919
- Increase cylinder waypoint circle interpolation from 20 to 100 - 400 sections based on radius
2020
- Update SnailTrail Vario#2 color
2121
- NextArrowInfoBox show bearing different instead of distance
22+
- GRInstantInfoBox show average GR on comment label
2223

2324
------------------------
2425

‎src/Formatter/GlideRatioFormatter.cpp‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@
88
#include <math.h>
99

1010
void
11-
FormatGlideRatio(TCHAR *buffer, size_t size, double gr)
11+
FormatGlideRatio(TCHAR *buffer, size_t size, double gr, const TCHAR *suffix)
1212
{
1313
assert(buffer != NULL);
1414
assert(size >= 8);
1515

16-
StringFormat(buffer, size,
17-
fabs(gr) < 100 ? _T("%.1f") : _T("%.0f"), (double) gr);
16+
if(suffix == NULL) {
17+
StringFormat(buffer, size,
18+
fabs(gr) < 100 ? _T("%.1f") : _T("%.0f"), (double) gr);
19+
} else {
20+
StringFormat(buffer, size,
21+
fabs(gr) < 100 ? _T("%s%.1f") : _T("%s%.0f"), suffix, (double) gr);
22+
}
23+
1824
}

‎src/Formatter/GlideRatioFormatter.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
#include <cstddef>
88

99
void
10-
FormatGlideRatio(TCHAR *buffer, size_t size, double gr);
10+
FormatGlideRatio(TCHAR *buffer, size_t size, double gr, const TCHAR *suffix = NULL);

‎src/InfoBoxes/Content/Glide.cpp‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ UpdateInfoBoxGRInstant(InfoBoxData &data) noexcept
1515

1616
if (!::GradientValid(gr)) {
1717
data.SetInvalid();
18-
return;
18+
} else {
19+
data.SetValueFromGlideRatio(gr);
1920
}
2021

21-
// Set Value
22-
data.SetValueFromGlideRatio(gr);
22+
const auto average_gr = CommonInterface::Calculated().average_gr;
23+
24+
if (!::GradientValid(average_gr) || average_gr == 0.0) {
25+
data.SetCommentInvalid();
26+
} else {
27+
data.SetCommentFromGlideRatio(average_gr, _T("avg:"));
28+
}
2329
}
2430

2531
void

‎src/InfoBoxes/Data.hpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ struct InfoBoxData {
136136
* Set the InfoBox value to the specified glide ratio.
137137
*/
138138
void SetValueFromGlideRatio(double gr) noexcept;
139+
void SetCommentFromGlideRatio(double gr, const TCHAR *suffix=_T("")) noexcept;
139140

140141
/**
141142
* Set the InfoBox value to the specified distance.

‎src/InfoBoxes/Format.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ InfoBoxData::SetValueFromGlideRatio(double gr) noexcept
2828
SetValueUnit(Unit::GRADIENT);
2929
}
3030

31+
void
32+
InfoBoxData::SetCommentFromGlideRatio(double gr, const TCHAR *suffix) noexcept
33+
{
34+
FormatGlideRatio(comment.buffer(), comment.capacity(), gr, suffix);
35+
}
36+
3137
void
3238
InfoBoxData::SetComment(Angle _value, const TCHAR *suffix) noexcept
3339
{

0 commit comments

Comments
 (0)