added antialias.c
authorDavid Schleef <ds@schleef.org>
Fri, 2 Jun 2000 21:37:40 +0000 (21:37 +0000)
committerDavid Schleef <ds@schleef.org>
Fri, 2 Jun 2000 21:37:40 +0000 (21:37 +0000)
demo/antialias.c [new file with mode: 0644]

diff --git a/demo/antialias.c b/demo/antialias.c
new file mode 100644 (file)
index 0000000..01583cf
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+   A little output demo
+ */
+
+#include <stdio.h>
+#include <comedilib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <getopt.h>
+#include <ctype.h>
+
+extern int verbose_flag;
+extern int subdevice;
+extern int range;
+extern int channel;
+extern int aref;
+extern int value;
+extern char *filename;
+
+comedi_t *device;
+
+void ao_antialias(unsigned int data);
+
+int main(int argc, char *argv[])
+{
+       lsampl_t data;
+       int ret;
+
+#if 0
+       parse_options(argc,argv);
+
+       device=comedi_open(filename);
+       if(!device){
+               comedi_perror(filename);
+               exit(0);
+       }
+
+       data = value; 
+       if(verbose_flag){
+               printf("writing %d to device=%s subdevice=%d channel=%d range=%d analog reference=%d\n",
+                       data,filename,subdevice,channel,range,aref);
+       }
+
+       ret=comedi_data_write(device,subdevice,channel,range,aref,data);
+       if(ret<0){
+               comedi_perror(filename);
+               exit(0);
+       }
+
+       printf("%d\n",data);
+#endif
+
+       ao_antialias((1000<<16)+1000);
+
+       return 0;
+}
+
+
+void ao_antialias(unsigned int data)
+{
+       unsigned int hibits=data>>16;
+       unsigned int lobits=data&0xffff;
+       int i;
+       unsigned int acc;
+
+       acc=0;
+       for(i=0;i<100;i++){
+               acc+=lobits;
+               printf("%d\n",hibits+(acc>>16));
+               acc&=0xffff;
+       }
+}
+