1
0
mirror of git://projects.qi-hardware.com/antorcha.git synced 2024-11-28 18:14:59 +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)
{
uint16_t e = MID << E_SHIFT;
uint32_t m = MID << M_SHIFT;
static uint16_t e = MID << E_SHIFT;
static uint32_t m = MID << M_SHIFT;
static bool up = 0;
int d;
bool up = 0;
e = v+(e-(e >> E_SHIFT));
m = v+(m-(m >> M_SHIFT));
@ -79,16 +79,25 @@ int main(int argc, char **argv)
double t;
char *end;
int i;
unsigned v;
if (argc != 2)
usage(*argv);
switch (argc) {
case 1:
while (scanf("%u", &v) == 1)
process(v);
break;
case 2:
t = strtod(argv[1], &end);
if (*end)
usage(*argv);
for (i = 0; i != t*S; i++) {
unsigned v = sample((double) i/S);
v = sample((double) i/S);
process(v);
}
break;
default:
usage(*argv);
}
return 0;
}