-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInTotalityPage.cpp
More file actions
70 lines (65 loc) · 1.87 KB
/
Copy pathInTotalityPage.cpp
File metadata and controls
70 lines (65 loc) · 1.87 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
/*
* 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 "InTotalityPage.hpp"
#include <sstream>
using duds::hardware::devices::displays::clearTo;
using duds::hardware::devices::displays::move;
using duds::hardware::devices::displays::startLine;
Page::SelectionResponse InTotalityPage::select(const DisplayInfo &di, SelectionCause) {
if (di.inTotality && (
(di.now >= (di.start - 64)) &&
(di.now <= (di.end + 4))
)) {
return SelectPage;
}
return SkipPage;
}
void InTotalityPage::rightJustified(
int t,
duds::hardware::devices::displays::TextDisplayStream &tds
) {
std::ostringstream remain;
Hms time(t);
time.writeDuration(remain);
std::string remstr = remain.str();
tds << clearTo(19 - remstr.length(), tds.display()->rowPos()) << remstr;
}
void InTotalityPage::show(
const DisplayInfo &di,
duds::hardware::devices::displays::TextDisplayStream &tds
) {
if (di.start <= di.now) {
Hms time(di.end);
tds << "End" << clearTo(11, 1);
time.writeTime(tds);
tds << "Remaining";
rightJustified(di.end - di.now, tds);
tds << " Look!\nTotality";
} else {
Hms time(di.start);
tds << "Start" << clearTo(11, 1);
time.writeTime(tds);
tds << "Duration";
rightJustified(di.end - di.start, tds);
tds << "Wait";
rightJustified(di.start - di.now, tds);
tds << "Totality";
}
}
void InTotalityPage::update(
const DisplayInfo &di,
duds::hardware::devices::displays::TextDisplayStream &tds
) {
// lazy solution
show(di, tds);
//tds << move(12, 0);
}