From 4c9eb37337fc5658288de737c64860906c3a4e3e Mon Sep 17 00:00:00 2001 From: Astrid Smith Date: Sun, 18 Sep 2011 20:28:29 -0700 Subject: Stabilized the read slightly, added a diagram --- host/client.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'host') diff --git a/host/client.c b/host/client.c index 42a1f72..17f3fba 100644 --- a/host/client.c +++ b/host/client.c @@ -7,16 +7,17 @@ #include #include -#define QUEUE 60 +#define QUEUE 3600 #define WIDTH 40 +#define SCALE 1000000 int main(int *argc, char **argv) { char line[WIDTH + 10]; char blankline[] = " | "; - double bottom = 1000000/59.9; - double top = 1000000/60.1; - double center = 1000000/60; + double bottom = SCALE/59.8; + double top = SCALE/60.2; + double center = SCALE/60; double queue[QUEUE]; int counter; int qpos = 0; @@ -29,7 +30,7 @@ int main(int *argc, char **argv) double current, average; char inlin[20]; int position, pos_avg, i; - int len = read(fd, &inlin, 20); + int len = read(fd, &inlin, 6); if (len == 0) { puts("Fucked\n"); continue; @@ -56,7 +57,7 @@ int main(int *argc, char **argv) line[position] = '.'; } - if (counter % 6 == 0) { + if (counter % 60 == 0) { if (pos_avg > WIDTH) { line[WIDTH] = '_'; } else if (pos_avg < 0) { @@ -64,6 +65,7 @@ int main(int *argc, char **argv) } else { line[pos_avg] = '#'; } + line[20] = '|'; printf("[%s] %f\n", line, 1/(average/1000000)); strcpy(&line, &blankline); } -- cgit v1.2.3