-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtello_state.cpp
More file actions
46 lines (39 loc) · 1.13 KB
/
tello_state.cpp
File metadata and controls
46 lines (39 loc) · 1.13 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
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include "tello.h"
using tello::Tello;
void ShowStatus(const std::string& state) {
int ret = system("clear");
if (ret == -1) {
std::cerr << "Error clearing the screen" << "\n";
return;
}
int begin{0};
std::cout << "+-----------+-----------+" << "\n";
const int padding = 10;
while (begin < state.size()) {
const auto split{state.find(':', begin)};
const auto name{state.substr(begin, split - begin)};
const auto end{state.find(';', split)};
const auto value{state.substr(split + 1, end - split - 1)};
begin = end + 1;
std::cout << "| " << name;
std::cout << std::setw(padding - name.size()) << "|";
std::cout << " " << value;
std::cout << std::setw(padding - value.size()) << "|";
std::cout << "\n";
}
std::cout << "+-----------+-----------+" << "\n";
}
int main() {
Tello tello{};
if (!tello.Bind()) {
return 0;
}
while (true) {
if (const auto state = tello.GetState()) {
ShowStatus(*state);
}
}
}