mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-22 19:42:48 +02:00
atrf-path: the GUI is now activated with -g; also changed arguments in GUI mode
- atrf-path.c (usage, main): new option -g to invoke the GUI - atrf-path.c (usage, main): in GUI mode, the number of sweeps is optional (default: infinite) - atrf-path.c (main), gui.h (gui), gui.c (gui): exit after the specified number of sweeps
This commit is contained in:
parent
cee0296579
commit
436c9faed5
@ -139,10 +139,26 @@ static void usage(const char *name)
|
|||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usage: %s [-p power] [-t trim_tx [-t trim_rx]] driver_tx[:arg]\n"
|
"usage: %s [-p power] [-t trim_tx [-t trim_rx]] driver_tx[:arg]\n"
|
||||||
"%16s driver_rx[:arg] [sweeps [samples]]\n\n"
|
"%16s driver_rx[:arg] [sweeps [samples]]\n"
|
||||||
|
|
||||||
|
#ifdef HAVE_GFX
|
||||||
|
"%6s %s -g [-p power] [-t trim_tx [-t trim_rx]] driver_tx[:arg]\n"
|
||||||
|
"%16s driver_rx[:arg] [[sweeps] samples]\n"
|
||||||
|
#endif
|
||||||
|
"\n"
|
||||||
|
|
||||||
|
#ifdef HAVE_GFX
|
||||||
|
" -g display results graphically\n"
|
||||||
|
#endif
|
||||||
" -p power transmit power, 0 to 15 (default %d)\n"
|
" -p power transmit power, 0 to 15 (default %d)\n"
|
||||||
" -t trim trim capacitor, 0 to 15 (default %d)\n"
|
" -t trim trim capacitor, 0 to 15 (default %d)\n"
|
||||||
, name, "", DEFAULT_POWER, DEFAULT_TRIM);
|
|
||||||
|
, name, "",
|
||||||
|
#ifdef HAVE_GFX
|
||||||
|
"", name, "",
|
||||||
|
#endif
|
||||||
|
DEFAULT_POWER, DEFAULT_TRIM);
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,14 +171,19 @@ int main(int argc, char **argv)
|
|||||||
.trim_rx = DEFAULT_TRIM,
|
.trim_rx = DEFAULT_TRIM,
|
||||||
.samples = 1,
|
.samples = 1,
|
||||||
};
|
};
|
||||||
|
int graphical = 0;
|
||||||
int power = DEFAULT_POWER;
|
int power = DEFAULT_POWER;
|
||||||
int sweeps = 1;
|
int sweeps = 1;
|
||||||
unsigned long tmp;
|
unsigned long tmp;
|
||||||
char *end;
|
char *end;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "p:t:")) != EOF)
|
while ((c = getopt(argc, argv, "gp:t:")) != EOF)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
case'g':
|
||||||
|
graphical = 1;
|
||||||
|
sweeps = 0;
|
||||||
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
tmp = strtoul(optarg, &end, 0);
|
tmp = strtoul(optarg, &end, 0);
|
||||||
if (*end || tmp > 15)
|
if (*end || tmp > 15)
|
||||||
@ -195,6 +216,10 @@ int main(int argc, char **argv)
|
|||||||
sweeps = strtoul(argv[optind+2], &end, 0);
|
sweeps = strtoul(argv[optind+2], &end, 0);
|
||||||
if (*end)
|
if (*end)
|
||||||
usage(*argv);
|
usage(*argv);
|
||||||
|
if (graphical && argc-optind == 3) {
|
||||||
|
sweep.samples = sweeps;
|
||||||
|
sweeps = 0;
|
||||||
|
}
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case 2:
|
case 2:
|
||||||
tx_drv = argv[optind];
|
tx_drv = argv[optind];
|
||||||
@ -212,10 +237,10 @@ int main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
sweep.power = 15-power;
|
sweep.power = 15-power;
|
||||||
if (sweeps) /* @@@ hack */
|
if (graphical)
|
||||||
do_sweeps(&sweep, sweeps);
|
gui(&sweep, sweeps);
|
||||||
else
|
else
|
||||||
gui(&sweep);
|
do_sweeps(&sweep, sweeps);
|
||||||
|
|
||||||
atrf_reg_write(sweep.tx, REG_TRX_STATE, TRX_CMD_TRX_OFF);
|
atrf_reg_write(sweep.tx, REG_TRX_STATE, TRX_CMD_TRX_OFF);
|
||||||
atrf_reg_write(sweep.rx, REG_TRX_STATE, TRX_CMD_TRX_OFF);
|
atrf_reg_write(sweep.rx, REG_TRX_STATE, TRX_CMD_TRX_OFF);
|
||||||
|
@ -109,7 +109,7 @@ static void tstop(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void gui(const struct sweep *sweep)
|
void gui(const struct sweep *sweep, int sweeps)
|
||||||
{
|
{
|
||||||
SDL_Surface *surf;
|
SDL_Surface *surf;
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
@ -127,7 +127,7 @@ void gui(const struct sweep *sweep)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (cycle != sweeps || !sweeps) {
|
||||||
struct sample res[N_CHAN*2];
|
struct sample res[N_CHAN*2];
|
||||||
|
|
||||||
while (SDL_PollEvent(&event))
|
while (SDL_PollEvent(&event))
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_GFX
|
#ifdef HAVE_GFX
|
||||||
void gui(const struct sweep *sweep);
|
void gui(const struct sweep *sweep, int sweeps);
|
||||||
#else
|
#else
|
||||||
#define gui(sweep) abort()
|
#define gui(sweep, sweeps) abort()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* !GUI_H */
|
#endif /* !GUI_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user