Without the cast non integer frequencies weren't possible (e.g. with a sampling
frequency of 50Hz we would end up with a signal frequency of 2Hz instead of
2.5Hz). The result were signals which had an incorrect number of samples per
period.

BugLink: http://sigrok.org/bugzilla/show_bug.cgi?id=297
---
 hardware/demo/demo.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hardware/demo/demo.c b/hardware/demo/demo.c
index 3d59ae5..433f352 100644
--- a/hardware/demo/demo.c
+++ b/hardware/demo/demo.c
@@ -206,7 +206,7 @@ static void generate_analog_pattern(const struct 
sr_probe_group *probe_group, ui
                break;
 
        case PATTERN_SINE:
-               frequency = sample_rate / ANALOG_SAMPLES_PER_PERIOD;
+               frequency = (double) sample_rate / ANALOG_SAMPLES_PER_PERIOD;
 
                /* Make sure the number of samples we put out is an integer
                 * multiple of our period size */
@@ -225,7 +225,7 @@ static void generate_analog_pattern(const struct 
sr_probe_group *probe_group, ui
                break;
 
        case PATTERN_TRIANGLE:
-               frequency = sample_rate / ANALOG_SAMPLES_PER_PERIOD;
+               frequency = (double) sample_rate / ANALOG_SAMPLES_PER_PERIOD;
 
                while (num_samples % ANALOG_SAMPLES_PER_PERIOD != 0)
                        num_samples--;
@@ -240,7 +240,7 @@ static void generate_analog_pattern(const struct 
sr_probe_group *probe_group, ui
                break;
 
        case PATTERN_SAWTOOTH:
-               frequency = sample_rate / ANALOG_SAMPLES_PER_PERIOD;
+               frequency = (double) sample_rate / ANALOG_SAMPLES_PER_PERIOD;
 
                while (num_samples % ANALOG_SAMPLES_PER_PERIOD != 0)
                        num_samples--;
-- 
1.8.5.3


------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to