From 8a29362cd45d2cee02e254f6f86114e2ada250ef Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 13 Aug 2009 11:09:05 +0000 Subject: [PATCH] Use negative options.value to set up time as a duty cycle. --- demo/gpct_pulse_generator.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/demo/gpct_pulse_generator.c b/demo/gpct_pulse_generator.c index c236621..94bdb7c 100644 --- a/demo/gpct_pulse_generator.c +++ b/demo/gpct_pulse_generator.c @@ -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); -- 2.26.2