-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui.c
More file actions
140 lines (108 loc) · 3.38 KB
/
Copy pathui.c
File metadata and controls
140 lines (108 loc) · 3.38 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#include "ui.h"
#include "options.h"
#include <ncurses.h>
#include <time.h>
#include <string.h>
void showCard(WINDOW *win, int cardIdx, cardInfo *cInfo)
{
box(win,0,0);
attron(A_BOLD);
mvwprintw(win, 1, 1, "%s", cInfo->name);
mvwprintw(win, 2, 1, "Type: %s", cInfo->type);
attroff(A_BOLD);
mvwprintw(win, 4, 1, "Freq:\t%4.2f MHz",(float)((int)cInfo->freq / 1000000));
mvwprintw(win, 4, 21, "Signal:\t%u",cInfo->signal);
mvwprintw(win, 5, 1, "BER:\t%u",cInfo->ber);
mvwprintw(win, 5, 21, "SNR:\t%u",cInfo->snr);
printCaps(win, cInfo->capsInfo);
printStatus(win, cInfo->statInfo);
/* Modulation */
printOFDM(win, &cInfo->u.ofdm);
/* Info */
mvwprintw(win, INFO_ROFFSET, INFO_COFFSET, "Frequency\tMin:\t%4.2f MHz\tMax:\t%4.2f MHz\tStep:\t%4.2f MHz",
(float)((int)cInfo->freq_min / 1000000),
(float)((int)cInfo->freq_max / 1000000),
(float)((int)cInfo->freq_step / 1000000));
mvwprintw(win, INFO_ROFFSET+1, INFO_COFFSET, "Symbol rate\tMin:\t%u ppm\t\tMax:\t%u ppm\t\tTolerance:\t%u ppm",
cInfo->symbol_rate_min,
cInfo->symbol_rate_max,
cInfo->symbol_rate_tolerance);
wrefresh(win);
}
void showTitle()
{
/* Print first row */
attron(A_BOLD);
mvprintw(0,0,"DVBTop v. %.2f",VER);
// Print current time
time_t ct = time(NULL);
struct tm *ctime = localtime(&ct);
char currentTime[50];
strftime(currentTime, sizeof(currentTime), "Last update: %H:%M:%S %d.%m.%y",ctime);
mvprintw(0, COLS-strlen(currentTime), currentTime);
//mvwprintw(0, 0, 1, "[Card: %d]", 25);
attroff(A_BOLD);
// Print help
mvprintw(1,0,"Press [q] or ^C to quit.");
}
void printCaps(WINDOW *win, capInfo_t *ci)
{
wattron(win,A_BOLD);
mvwprintw(win, CAPS_ROFFSET, 1, "Capabilites:");
wattroff(win,A_BOLD);
int i = 0, rowOffset = CAPS_ROFFSET, colOffset = 0;
for (i = 0; i < CAPS_COUNT; ++i)
{
if(ci[i].has == 0)
{
wattron(win,COLOR_PAIR(1));
} else
{
wattron(win,COLOR_PAIR(2));
}
colOffset = CAPS_COFFSET + (i % 5)*10;
if((i%5) == 0) rowOffset++;
mvwprintw(win, rowOffset, colOffset , "%s", ci[i].title);
wattroff(win,COLOR_PAIR(1));
wattroff(win,COLOR_PAIR(2));
}
}
void printStatus(WINDOW *win, capInfo_t *st)
{
int i = 0, coffset = STAT_COFFSET, roffset = STAT_ROFFSET;
wattron(win,A_BOLD);
mvwprintw(win, roffset, coffset, "Status: ");
wattroff(win,A_BOLD);
for (i = 0; i < STAT_COUNT; ++i)
{
if(st[i].has == 0)
{
wattron(win,COLOR_PAIR(1));
} else
{
wattron(win,COLOR_PAIR(2));
}
wprintw(win, "%s ", st[i].title);
wattroff(win,COLOR_PAIR(1));
wattroff(win,COLOR_PAIR(2));
}
}
void printOFDM(WINDOW *win, ofdmInfo_t *ofdm)
{
wattron(win,A_BOLD);
mvwprintw(win, OFDM_ROFFSET, OFDM_COFFSET, "OFDM Status: ");
wattroff(win,A_BOLD);
mvwprintw(win, OFDM_ROFFSET + 1, OFDM_COFFSET, "Bandwidth:\t%s\tModulation:\t%s", ofdm->bandwidth, ofdm->modulation);
mvwprintw(win, OFDM_ROFFSET + 2, OFDM_COFFSET, "Trans Mode:\t%s\tGuard interval:\t%s", ofdm->trMode, ofdm->guardInt);
mvwprintw(win, OFDM_ROFFSET + 3, OFDM_COFFSET, "Hierarchy:\t%s", ofdm->hierarchy);
mvwprintw(win, OFDM_ROFFSET + 4, OFDM_COFFSET, "Code rate:\tHigh:\t%s\tLow:\t%s", ofdm->crHP, ofdm->crLP);
}
void showCardMenu(uint16_t cardCount, uint16_t currentCard, uint16_t row)
{
for (uint16_t i = 0; i < cardCount; ++i)
{
if(i == currentCard) attron(A_BOLD | COLOR_PAIR(2));
mvprintw(row, (i*10),"[Card: %u]", i);
if(i == currentCard) attroff(A_BOLD | COLOR_PAIR(2));
}
}