1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-26 04:56:16 +02:00

atrf-path: new option -T to sweep only one offset

atrf-path -T +0.5 -g ... 10 10 time:

before (both offsets)	0.65 s
after (one offset)	0.32-0.33 s	(50%)

- atrf-path.c (usage, main): new option -T to specify which offset to
  sweep (default: sweep both)
- atrf-path.c (do_half_sweep): only sample points with the desired offset
- atrf-path.c (print_sweep): only prints points we've sweeped
- gui.c (segment, draw): inverted flag logic from "have_last" to "first"
- gui.c (draw): only plot points we've sweeped
- gui.c (gui): pass the offset selection to "draw"
This commit is contained in:
Werner Almesberger 2011-04-13 14:01:12 -03:00
parent 598582c26a
commit e2a9c9d068
3 changed files with 45 additions and 17 deletions

View File

@ -14,6 +14,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "at86rf230.h"
@ -111,6 +112,8 @@ static void do_half_sweep(const struct sweep *sweep, int cont_tx,
{
int chan;
if (sweep->cont_tx && sweep->cont_tx != cont_tx)
return;
for (chan = 11; chan <= 26; chan++) {
set_channel(sweep->rx, chan);
set_channel(sweep->tx, chan);
@ -134,11 +137,13 @@ static void print_sweep(const struct sweep *sweep, const struct sample *res)
int chan;
for (chan = 11; chan <= 26; chan++) {
printf("%.1f %.2f %.0f %.0f\n",
2350+5*chan-0.5, res->avg, res->min, res->max);
if (sweep->cont_tx != CONT_TX_P500K)
printf("%.1f %.2f %.0f %.0f\n",
2350+5*chan-0.5, res->avg, res->min, res->max);
res++;
printf("%.1f %.2f %.0f %.0f\n",
2350+5*chan+0.5, res->avg, res->min, res->max);
if (sweep->cont_tx != CONT_TX_M500K)
printf("%.1f %.2f %.0f %.0f\n",
2350+5*chan+0.5, res->avg, res->min, res->max);
res++;
}
}
@ -167,14 +172,15 @@ static void usage(const char *name)
"%6s %s -g common_args [[sweeps] samples]\n"
#endif
"\n"
" common args: [-p power] [-t trim_tx [-t trim_rx]] driver_tx[:arg]\n"
" driver_rx[:arg]\n\n"
" common args: [-p power] [-t trim_tx [-t trim_rx]] [-T offset]\n"
" driver_tx[:arg] driver_rx[:arg]\n\n"
#ifdef HAVE_GFX
" -g display results graphically\n"
" -g display results graphically\n"
#endif
" -p power transmit power, 0 to 15 (default %d)\n"
" -t trim trim capacitor, 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 offset constant wave offset in MHz, -0.5 or +0.5 (default: scan both)\n"
, name,
#ifdef HAVE_GFX
@ -192,6 +198,7 @@ int main(int argc, char **argv)
struct sweep sweep = {
.trim_tx = -1,
.trim_rx = DEFAULT_TRIM,
.cont_tx = 0,
.samples = 1,
};
int graphical = 0;
@ -201,7 +208,7 @@ int main(int argc, char **argv)
char *end;
int c;
while ((c = getopt(argc, argv, "gp:t:")) != EOF)
while ((c = getopt(argc, argv, "gp:t:T:")) != EOF)
switch (c) {
case'g':
graphical = 1;
@ -222,6 +229,14 @@ int main(int argc, char **argv)
else
sweep.trim_rx = tmp;
break;
case 'T':
if (!strcmp(optarg, "-0.5"))
sweep.cont_tx = CONT_TX_M500K;
else if (!strcmp(optarg, "+0.5"))
sweep.cont_tx = CONT_TX_P500K;
else
usage(*argv);
break;
default:
usage(*argv);
}

View File

@ -47,11 +47,11 @@
static void segment(SDL_Surface *s, int *last_x, int *last_y, int x,
const struct sample *res, int have_last)
const struct sample *res, int first)
{
int y = YRES-(res->avg-Y_MIN)/(Y_MAX-Y_MIN)*YRES-1;
if (have_last) {
if (!first) {
aalineColor(s, *last_x, *last_y, x, y, FG_RGBA);
}
*last_x = x;
@ -59,16 +59,26 @@ static void segment(SDL_Surface *s, int *last_x, int *last_y, int x,
}
static void draw(SDL_Surface *s, const struct sample *res)
static void draw(SDL_Surface *s, const struct sample *res, int cont_tx)
{
int last_x, last_y;
int x, i;
int first, x, i;
x = CHAN_X_OFFSET;
first = 1;
for (i = 0; i != N_CHAN; i++) {
segment(s, &last_x, &last_y, x, res++, i);
if (cont_tx != CONT_TX_P500K) {
segment(s, &last_x, &last_y, x, res, first);
first = 0;
}
res++;
x += 2*SIDE_STEP;
segment(s, &last_x, &last_y, x, res++, 1);
if (cont_tx != CONT_TX_M500K) {
segment(s, &last_x, &last_y, x, res, first);
first = 0;
}
res++;
x += CHAN_STEP-2*SIDE_STEP;
}
}
@ -148,7 +158,7 @@ void gui(const struct sweep *sweep, int sweeps)
aacircleColor(surf, STATUS_X, STATUS_Y, STATUS_R,
OK_RGBA);
}
draw(surf, res);
draw(surf, res, sweep->cont_tx);
SDL_UnlockSurface(surf);
SDL_UpdateRect(surf, 0, 0, 0, 0);

View File

@ -14,6 +14,8 @@
#ifndef SWEEP_H
#define SWEEP_H
#include <stdint.h>
#include "atrf.h"
@ -23,6 +25,7 @@ struct sweep {
int trim_tx;
int trim_rx;
int power;
uint8_t cont_tx;
int samples;
};