Giter VIP home page Giter VIP logo

Comments (10)

campagnola avatar campagnola commented on May 29, 2024

I do not think this is in the scope of the Timer object, but it could certainly be added to Canvas.

from vispy.

rougier avatar rougier commented on May 29, 2024

We could provide at least the dt since last tick (it is quite useful and it saves the user the manipulation of time).

Nicolas

On Aug 25, 2013, at 2:45 PM, Luke Campagnola [email protected] wrote:

I do not think this is in the scope of the Timer object, but it could certainly be added to Canvas.


Reply to this email directly or view it on GitHub:
#28 (comment)

from vispy.

campagnola avatar campagnola commented on May 29, 2024

That's true.. there's a complication in that the timer can have multiple callbacks. Generally, each callback will want to know the time elapsed since that callback was last invoked (if one callback takes a variable amount of time, then subsequent callbacks would have an inaccurate measure of timestep). This would not be too difficult to implement, but the timer would need to keep track of the timing for each callback, probably with a subclass of EventEmitter.

from vispy.

almarklein avatar almarklein commented on May 29, 2024

Can we not assume (and document) that in a situation where timing is crucial, a custom timer will be used with just one callback?

From a look on the code, it seems that keeping track of time per callback is quite complicated (and hackish), while keeping track of the last tick is trivial.

from vispy.

rougier avatar rougier commented on May 29, 2024

That's not good. Getting elapsed time since last call is a very basic feature and if the current app architecture doesn't allow to implement this, we may want to reconsider the whole thing.

Again, pyglet is doing just that and quite precisely (even taking account clock over/under shoot) and thus, we might just to exract the clock.py object from pyglet.

from vispy.

almarklein avatar almarklein commented on May 29, 2024

I don't think this is due to the design of our event system. It is inherit to each design that supports multiple event handlers on a timer. So as long as a user in need of precise timings just adds a single handlers, all should be well.

Perhaps we should add some sort feature that can ensure that there is a single handler? For instance via an argument to the Timer class?

from vispy.

rougier avatar rougier commented on May 29, 2024

Not sure I understand.

Let's say I want a timer with 1/50 frequency and a second one with 1/20 frequency, how would I write that ? Maybe an example in app would be good. And of course, I would like to get dt in args/event since last tick in each timer, ~1/50 in first one, ~1/20 in second.

On Sep 1, 2013, at 8:12 PM, Almar Klein [email protected] wrote:

I don't think this is due to the design of our event system. It is inherit to each design that supports multiple event handlers on a timer. So as long as a user in need of precise timings just adds a single handlers, all should be well.

Perhaps we should add some sort feature that can ensure that there is a single handler? For instance via an argument to the Timer class?


Reply to this email directly or view it on GitHub:
#28 (comment)

from vispy.

almarklein avatar almarklein commented on May 29, 2024

Like this?

def callback1(event):
    timesincelastcall = event.dt  # This does not yet work, but we might do it like this
timer1 = app.Timer(1.0/50)
timer2 - app.Timer(1.0/20)
timer1.connect(callback1)
timer2.connect(callback2)

from vispy.

rougier avatar rougier commented on May 29, 2024

Yep exactly. Also dt should be time since last calling each callback (around 1/50 for callback1 and 1/20 for callback2)

On Sep 1, 2013, at 8:36 PM, Almar Klein [email protected] wrote:

Like this?

def callback1(event):
timesincelastcall = event.dt # This does not yet work, but we might do it like this
timer1 = app.Timer(1.0/50)
timer2 - app.Timer(1.0/20)
timer1.connect(callback1)
timer2.connect(callback2)


Reply to this email directly or view it on GitHub:
#28 (comment)

from vispy.

campagnola avatar campagnola commented on May 29, 2024

Timer events now have .dt attribute.

from vispy.

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.