-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathscanner.cpp
More file actions
44 lines (34 loc) · 1.11 KB
/
scanner.cpp
File metadata and controls
44 lines (34 loc) · 1.11 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
#include <vector>
#include <chrono>
#include "scanner.h"
Scanner::Scanner(std::vector<ScanList> scanlist) {
ch_index = channels.size();
copy(scanlist.begin(), scanlist.end(), back_inserter(channels));
printf("[Scanner] scanlist size %ld %ld\n", channels.size(), scanlist.size());
for (uint8_t i = 0; i < channels.size(); i++ ) {
printf("[Scanner] Frq %f name %s\n", channels[i].frequency, channels[i].ch_name.c_str());
}
}
double Scanner::NextCh(bool sql)
{
static auto last_time = std::chrono::steady_clock::now();
double retval = 0.0f;
if (sql == true) {
auto now = std::chrono::steady_clock::now();
if (std::chrono::duration_cast<std::chrono::milliseconds>(now - last_time).count() >= stepDelayMs) {
last_time = now;
ch_index++;
if (ch_index >= channels.size()) {
ch_index = 0;
}
if (!channels.empty()) {
retval = channels[ch_index].frequency;
}
}
}
return retval;
}
void Scanner::SetStepDelay(uint16_t delay)
{
stepDelayMs = delay;
}