mirror of
git://projects.qi-hardware.com/antorcha.git
synced 2024-11-22 07:36:17 +02:00
tornado/fw/sim/alg.c: separate data processing from sample generation
This commit is contained in:
parent
4d09658036
commit
07e0df0d6a
@ -44,16 +44,14 @@ static uint16_t sample(double t)
|
||||
#define E_SHIFT 3 /* ~ 0.1 */
|
||||
#define M_SHIFT 10 /* ~ 1/S */
|
||||
|
||||
int main(void)
|
||||
|
||||
static void process(unsigned v)
|
||||
{
|
||||
uint16_t e = MID << E_SHIFT;
|
||||
uint32_t m = MID << M_SHIFT;
|
||||
int d;
|
||||
int i;
|
||||
bool up = 0;
|
||||
|
||||
for (i = 0; i != 10*S; i++) {
|
||||
unsigned v = sample((double) i/S);
|
||||
e = v+(e-(e >> E_SHIFT));
|
||||
m = v+(m-(m >> M_SHIFT));
|
||||
d = (e >> E_SHIFT)-(m >> M_SHIFT);
|
||||
@ -66,6 +64,17 @@ int main(void)
|
||||
}
|
||||
printf("%d %d %d %d %d\n",
|
||||
v, e >> E_SHIFT, m >> M_SHIFT, d, up);
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i != 10*S; i++) {
|
||||
unsigned v = sample((double) i/S);
|
||||
|
||||
process(v);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user