]> sigrok.org Git - libsigrok.git/commitdiff
demo: Fixed glitching in increment signal
authorJoel Holdsworth <redacted>
Sat, 13 Apr 2013 15:08:52 +0000 (16:08 +0100)
committerBert Vermeulen <redacted>
Sun, 14 Apr 2013 21:39:15 +0000 (23:39 +0200)
hardware/demo/demo.c

index 7d97bf798f558e9b205f734c23ba1a0a0f9dae79..0da3fd58b4659f75aeaa2216a105222f288af6b6 100644 (file)
@@ -347,9 +347,8 @@ static void samples_generator(uint8_t *buf, uint64_t size,
        switch (devc->sample_generator) {
        case PATTERN_SIGROK: /* sigrok pattern */
                for (i = 0; i < size; i++) {
-                       *(buf + i) = ~(pattern_sigrok[p] >> 1);
-                       if (++p == 64)
-                               p = 0;
+                       *(buf + i) = ~(pattern_sigrok[
+                               p++ % sizeof(pattern_sigrok)] >> 1);
                }
                break;
        case PATTERN_RANDOM: /* Random */
@@ -358,7 +357,7 @@ static void samples_generator(uint8_t *buf, uint64_t size,
                break;
        case PATTERN_INC: /* Simple increment */
                for (i = 0; i < size; i++)
-                       *(buf + i) = i;
+                       *(buf + i) = p++;
                break;
        case PATTERN_ALL_LOW: /* All probes are low */
                memset(buf, 0x00, size);