-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGpsPage.cpp
84 lines (80 loc) · 2.18 KB
/
GpsPage.cpp
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
73
74
75
76
77
78
79
80
81
82
83
84
/*
* This file is part of the Eclipse2017 project. It is subject to the GPLv3
* license terms in the LICENSE file found in the top-level directory of this
* distribution and at
* https://github.com/jjackowski/eclipse2017/blob/master/LICENSE.
* No part of the Eclipse2017 project, including this file, may be copied,
* modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*
* Copyright (C) 2017 Jeff Jackowski
*/
#include "GpsPage.hpp"
using duds::hardware::devices::displays::clearTo;
using duds::hardware::devices::displays::move;
using duds::hardware::devices::displays::startLine;
Page::SelectionResponse GpsPage::select(const DisplayInfo &, SelectionCause) {
return SelectPage;
}
void GpsPage::show(
const DisplayInfo &di,
duds::hardware::devices::displays::TextDisplayStream &tds
) {
if (di.goodfix) {
within = di.locerr;
sats = di.sats;
tds << "Within " << within << 'm' << clearTo(12, 1) << "Sats " <<
std::left << std::setw(2) << sats;
//<< startLine;
} else {
within = -1;
sats = 0;
tds << "No fix";
if (di.curloc.lon == 0.0) {
tds << "\n\n\nGPS";
return;
} else {
tds << "; old postion\n";
}
}
lon = di.curloc.lon;
lat - di.curloc.lat;
tds << "Lon " << std::setprecision(7) << std::setw(12) << std::fixed <<
lon << "\nLat " << std::setprecision(7) << std::setw(12) << std::fixed <<
lat << "\nGPS";
}
void GpsPage::update(
const DisplayInfo &di,
duds::hardware::devices::displays::TextDisplayStream &tds
) {
if (di.goodfix) {
if (within == -1) {
// redo page
show(di, tds);
return;
}
if (within != di.locerr) {
within = di.locerr;
tds << move(7, 1) << within << 'm' << clearTo(11, 1);
}
if (sats != di.sats) {
sats = di.sats;
tds << move(18, 1) << std::left << std::setw(2) << sats;// << startLine;
}
if (lon != di.curloc.lon) {
lon = di.curloc.lon;
tds << move(4, 2) << std::setprecision(7) << std::setw(12) <<
std::fixed << lon;
}
if (lat != di.curloc.lat) {
lat = di.curloc.lat;
tds << move(4, 3) << std::setprecision(7) << std::setw(12) <<
std::fixed << lat;
}
} else if (within != -1) {
// redo page
show(di, tds);
return;
}
tds << move(12, 0);
}