summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--circuit.txt21
-rw-r--r--host/client.c14
2 files changed, 29 insertions, 6 deletions
diff --git a/circuit.txt b/circuit.txt
new file mode 100644
index 0000000..408f8ee
--- /dev/null
+++ b/circuit.txt
@@ -0,0 +1,21 @@
+
+ +-------------------+
+ | |
+ +----)------------+ |
+ | | | |
+ | +-------+ | | +---------+----o Digital output
+ | | | | | | |
++24V ac o---\/\/\/\/--+ | __ __ __ __ |
+ 10K | | | | | | | | | | |
+ | | +--------------------------+ |
+ | | | | +--|(+)\ | | \
+ Voltage | | | | | >---+ / / Pull-up resistor
+ Divider | | | +--------|(-)/ | \ ~10K
+ | | | \ /
+ | | | Comparator (NS M8830) | \
+ | | +--------------------------+ |
+ | | |__| |__| |__| |__| |
+-24V ac o-+-\/\/\/\/--+ | | |
+ | 1K | +---------+----o Digital +5V
+ | |
+ +---------------+----------------------------------------o Digital ground
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 <string.h>
#include <fcntl.h>
-#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);
}