summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--multiplexer.c30
-rw-r--r--multiplexer.h4
2 files changed, 20 insertions, 14 deletions
diff --git a/multiplexer.c b/multiplexer.c
index 48e218c..b06b5a0 100644
--- a/multiplexer.c
+++ b/multiplexer.c
@@ -2,7 +2,7 @@
#include <stdlib.h>
#include <fcntl.h>
#include <sys/mman.h>
-#endif
+#endif // SKIP_GPIO
#include <stdio.h>
#include <unistd.h>
#include <string.h>
@@ -42,7 +42,7 @@ int multiplexer_setup_root()
// Always use volatile pointer!
gpio = (volatile unsigned *)gpio_map;
-#endif
+#endif // !SKIP_GPIO
} // multiplexer_setup_root
//
@@ -54,13 +54,13 @@ void *put_on_display(void *param)
int line, column;
#ifndef SKIP_GPIO
struct timespec start_time, stop_time;
-#endif
+#endif // !SKIP_GPIO
while (display_data -> keep_running) {
#ifdef SKIP_GPIO
usleep(10000);
-#endif
+#endif // SKIP_GPIO
display_data -> is_buf = display_data -> should_buf;
if (!display_data -> should_be_on) {
if (!display_data -> is_on)
@@ -71,14 +71,18 @@ void *put_on_display(void *param)
}
display_data -> is_on = display_data -> should_be_on;
#ifdef SKIP_GPIO
+#ifndef SILENT
printf("=\n");
+#endif // !SILENT
for (line=0; line<7; line++) {
for (column=0; column<40; column++) {
+#ifndef SILENT
if (display_data -> buf[display_data -> is_buf][column] & (0x01 << line))
printf("X");
else
printf(" ");
-#else
+#endif // !SILENT
+#else // SKIP_GPIO
for (line=7; line>=0; line--) {
GPIO_CLR = 1<<GATE_PIN; // Licht an
if (clock_gettime(CLOCK_MONOTONIC_RAW, &start_time) != 0) {
@@ -95,11 +99,13 @@ void *put_on_display(void *param)
GPIO_CLR = 1<<SER_CLK_PIN;
GPIO_ALTER(display_data -> buf[display_data -> is_buf][column] & (0x01 << line)) = 1<<SER_DAT_PIN;
GPIO_SET = 1<<SER_CLK_PIN;
-#endif
+#endif // SKIP_GPIO
}
#ifdef SKIP_GPIO
+#ifndef SILENT
printf("\n");
-#else
+#endif // !SILENT
+#else // SKIP_GPIO
if (clock_gettime(CLOCK_MONOTONIC_RAW, &stop_time) != 0) {
display_data -> keep_running = 0;
perror("clock_gettime failed");
@@ -112,7 +118,7 @@ void *put_on_display(void *param)
GPIO_SET = 1<<GATE_PIN; // Licht aus
GPIO_CLR = 1<<PAR_CLK_PIN;
GPIO_SET = 1<<PAR_CLK_PIN;
-#endif
+#endif // SKIP_GPIO
}
}
return NULL;
@@ -219,7 +225,7 @@ void multiplexer_setup_non_root(t_display_data *display_data)
*(gpio + gpioToPUDCLK[SENSE_PIN]) = 0;
usleep(5);
/** end of adoption **/
-#endif
+#endif // !SKIP_GPIO
for (int i=0; i<3; i++)
memset(display_data -> buf[i],0,40);
@@ -252,7 +258,7 @@ void turn_off_display()
}
GPIO_CLR = 1<<PAR_CLK_PIN;
GPIO_SET = 1<<PAR_CLK_PIN;
-#endif
+#endif // !SKIP_GPIO
} // turn_off_display
int got_input()
@@ -269,7 +275,7 @@ int got_input()
}
else
return 0;
-#else
+#else // SKIP_GPIO
return ! GET_GPIO(SENSE_PIN); // low = active
-#endif
+#endif // SKIP_GPIO
} // got_input
diff --git a/multiplexer.h b/multiplexer.h
index f9105ae..738d6ad 100644
--- a/multiplexer.h
+++ b/multiplexer.h
@@ -13,8 +13,8 @@
#ifndef __arm__
#ifndef FORCE_GPIO
#define SKIP_GPIO
-#endif
-#endif
+#endif // FORCE_GPIO
+#endif // __arm__
// Access from ARM Running Linux