-
Notifications
You must be signed in to change notification settings - Fork 0
/
interactive.c
108 lines (93 loc) · 1.83 KB
/
interactive.c
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
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_LIBNCURSES
#include <ncurses.h>
#endif
/* Needed to compile on older FC3 systems */
#if defined __linux
#include <sys/types.h>
#include <linux/limits.h>
#endif
#include <usb.h> /* this is libusb, see http://libusb.sourceforge.net/ */
#include "operations.h"
#include "interactive.h"
extern int setByValue;
extern double multiplier;
void run_interactive(usb_dev_handle *handle) {
char ch;
int row, col;
initscr();
getmaxyx(stdscr,row,col);
keypad(stdscr, TRUE);
cbreak();
noecho();
double currentFreq;
if (setByValue == 1)
currentFreq = readFrequencyByValue(handle);
else
currentFreq = getFrequency(handle);
currentFreq = currentFreq / multiplier;
attron(A_BOLD);
mvprintw(1, 0, "%3.6f MHz", currentFreq);
attroff(A_BOLD);
mvprintw(3, 0, "q/a = Up/Down 100 KHz\n");
printw("w/s = Up/Down 10 KHz\n");
printw("e/d = Up/Down 1 KHz\n");
printw("r/f = Up/Down 100 Hz\n");
printw("t/g = Up/Down 10 Hz\n");
printw("x = Exit");
refresh();
int ptt = 0;
while ((ch = getch()) != 'x') {
int inc = 0;
switch (ch) {
case 'q':
inc = 100000;
break;
case 'a':
inc = -100000;
break;
case 'w':
inc = 10000;
break;
case 's':
inc = -10000;
break;
case 'e':
inc = 1000;
break;
case 'd':
inc = -1000;
break;
case 'r':
inc = 100;
break;
case 'f':
inc = -100;
break;
case 't':
inc = 10;
break;
case 'g':
inc = -10;
break;
case 'p':
ptt = ptt == 0 ? 1 : 0;
setPTT(handle, ptt);
default:
inc = 0;
}
currentFreq = currentFreq + inc / 1000000.0;
/* Now set the new freq */
if (setByValue)
setFreqByValue(handle, currentFreq);
else
setFrequency(handle, currentFreq);
attron(A_BOLD);
mvprintw(1, 0, "%3.6f MHz", currentFreq);
attroff(A_BOLD);
refresh();
}
endwin();
}