1
0
mirror of git://projects.qi-hardware.com/antorcha.git synced 2024-11-28 20:08:27 +02:00

tornado/fw/sim/alg.c: accept data from standard input; fix "process"

This commit is contained in:
Werner Almesberger 2012-12-09 16:56:32 -03:00
parent 95cfa9202c
commit a11670bb7b

View File

@ -47,10 +47,10 @@ static uint16_t sample(double t)
static void process(unsigned v) static void process(unsigned v)
{ {
uint16_t e = MID << E_SHIFT; static uint16_t e = MID << E_SHIFT;
uint32_t m = MID << M_SHIFT; static uint32_t m = MID << M_SHIFT;
static bool up = 0;
int d; int d;
bool up = 0;
e = v+(e-(e >> E_SHIFT)); e = v+(e-(e >> E_SHIFT));
m = v+(m-(m >> M_SHIFT)); m = v+(m-(m >> M_SHIFT));
@ -79,16 +79,25 @@ int main(int argc, char **argv)
double t; double t;
char *end; char *end;
int i; int i;
unsigned v;
if (argc != 2) switch (argc) {
usage(*argv); case 1:
while (scanf("%u", &v) == 1)
process(v);
break;
case 2:
t = strtod(argv[1], &end); t = strtod(argv[1], &end);
if (*end) if (*end)
usage(*argv); usage(*argv);
for (i = 0; i != t*S; i++) { for (i = 0; i != t*S; i++) {
unsigned v = sample((double) i/S); v = sample((double) i/S);
process(v); process(v);
} }
break;
default:
usage(*argv);
}
return 0; return 0;
} }