Use negative options.value to set up time as a duty cycle.
authorIan Abbott <abbotti@mev.co.uk>
Thu, 13 Aug 2009 11:09:05 +0000 (11:09 +0000)
committerIan Abbott <abbotti@mev.co.uk>
Thu, 13 Aug 2009 11:09:05 +0000 (11:09 +0000)
demo/gpct_pulse_generator.c

index c2366213494f5b3d4ea1f46e327cd7f31525f50f..94bdb7cc8867aaba4c1729acd858e84be3779c26 100644 (file)
@@ -105,11 +105,18 @@ int main(int argc, char *argv[])
        struct parsed_options options;
 
        init_parsed_options(&options);
-       options.value = -1.;
+       options.value = -0.5;
        parse_options(&options, argc, argv);
        period_ns = lrint(1e9 / options.freq);
        if(options.value < 0.)
-               up_time = period_ns / 2;
+       {
+               double duty;
+               if(-options.value < 1.0)
+                       duty = -options.value;
+               else
+                       duty = 1.0 / -options.value;
+               up_time = lrint(duty * period_ns);
+       }
        else
                up_time = lrint(options.value);
        device = comedi_open(options.filename);