First experiments with AVR (AtTiny2313)
[mirrors/Programs.git] / c / dreammachine / strobe.c
index 1c2c797f6abec6f40559d8985a05424a7b06e40c..172130960e1a47789c5238d182684f42719ef1b4 100644 (file)
@@ -3,10 +3,16 @@
  * usage ./strobe [frequency]
  */
 
+//#define __WIN32__
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <signal.h>
+#ifndef __WIN32__
+  #include <fcntl.h>
+#else
+  #include <windows.h>
+#endif
 
 void signal_handler(int signo) {
        if(signo == SIGTERM || signo == SIGINT || signo == SIGQUIT) {
@@ -48,6 +54,14 @@ int main(int argc, char *argv[]) {
                fputs(state_a, stdout);
                        fflush(stdout);
                        usleep(half_interval);
+               #ifndef __WIN32__
+               int fflags = fcntl(fileno(stdin), F_GETFL, 0);
+               fcntl(fileno(stdin), F_SETFL, fflags | O_NONBLOCK);
+                               while(getchar()) puts(".");
+               fcntl(fileno(stdin), F_SETFL, fflags);
+               #else
+               //WARNING! Somehow implement FILE_FLAG_OVERLAPPED & FILE_FLAG_NO_BUFFERING support on windows
+                       #endif
                        if(argc > 2) getchar(); //interactive strobe
                fputs(state_b, stdout);
                        fflush(stdout);
This page took 0.145323 seconds and 4 git commands to generate.