Giter Club home page Giter Club logo

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on September 18, 2024
Ooops should have checked my code. I think this is OK

static void
Counter_generates(Counter *self) {
    int i;
    MYFLT *in = Stream_getData((Stream *)self->input_stream);

    for (i=0; i<self->bufsize; i++) {
        if (in[i] == 1) {
            if (self->dir == 0) {                
                self->tmp++;
                if (self->tmp >= self->max)
                    self->tmp = self->min;
        self->value = (MYFLT)self->tmp;  // PJL
            }    
            else if (self->dir == 1) {
                self->tmp--;
                if (self->tmp < self->min)
                    self->tmp = self->max - 1;
                self->value = (MYFLT)self->tmp; // PJL
            }    
            else if (self->dir == 2) {
                self->tmp = self->tmp + self->direction;
                if (self->tmp >= self->max) {
                    self->direction = -1;
                    self->tmp = self->max-2;  //PJL
                }    
                else if (self->tmp < self->min) {
                    self->direction = 1;
            self->tmp=self->min+1; //PJL
                }    
                self->value = (MYFLT)self->tmp;  // PJL
            }
        }
        self->data[i] = self->value;
    }
}

Original comment by PaulJohnLeonard on 14 Jun 2012 at 12:19

from pyo.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 18, 2024
Fixed in sources. That was a special case when dir = 2 AND count range = 2...

With your fix, you're always missing the first count. The missing count print 
in your example is caused by the minimum set to 0 (same as buffer 
initialization value) and the Print method set to 1 (print only on new value).

Original comment by [email protected] on 14 Jun 2012 at 1:03

  • Changed state: Fixed

from pyo.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 18, 2024
I am a bit confused.  
My expectation was that the first trigger should change the state from 0 to 1.  
With your version I have to send 2 triggers is this what you want? 

Original comment by PaulJohnLeonard on 14 Jun 2012 at 1:30

from pyo.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 18, 2024
I just looked at the reset(value) to see if I can get what I want this way but 
it appears that it would take 2 triggers to change the counters value after a 
reset()? To make it do what I want I would need to inject an additional trigger 
just after creation. I think intuitively I would expect the counter to start at 
it's minimum value (or maximum if it was a down counter). I would then expect 
it to change on every trigger.  If I understand correctly at present the 
counter starts with 0 even if that is not in the counters range ?   

Original comment by PaulJohnLeonard on 14 Jun 2012 at 2:11

from pyo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.