OpenCircuits / OpenCircuits

A free, open source, online digital circuit/logic designer.
https://www.opencircuits.io/
GNU General Public License v3.0
295 stars 74 forks source link

Delayer/repeater #191

Open nprisament opened 5 years ago

nprisament commented 5 years ago

When making a complex clocked system, users should be able to add a delay to the propagation of signals through a given wire. The component would behave like a buffer gate but it would have an adjustable time delay to the signal changes by making an asynchronous promise to change the state whenever it is activated.

LeonMontealegre commented 5 years ago

Lmao - also not paying attention in physics I see.

But yeah - that seems like a feasible and somewhat easy change. But requires a bit of UI and some internal changes so I wouldn't mark it as small

nprisament commented 5 years ago

The internals can function the same as any other component with the activate function making a promise and then returning. The UI would be the same as the clock, so it is just a matter of that UI being finished.

LeonMontealegre commented 5 years ago

It would require passing a variable to the Propagation request and also storing that variable somewhere. Thinking about it - it wouldn't be very easy because the way propagations are eventually executed is that it collects requests over time and sends a bunch at once so that things don't go out of sync so the custom delay would have to be some large amount. I guess it could multiply to the default propagation time. Yeah actually that would work I think.

Honestly, we're mostly just waiting on the Popup UI. And this is pretty low priority but a good idea.

nprisament commented 5 years ago

couldn't it work something like:

public activate() { setTimeout(function(){ super.activate(this.inputs[0].getIsOn()); }.bind(this), this.delay); }

LeonMontealegre commented 5 years ago

It would be a terrible idea to have each component do their own setTimeout. That would lead to small inconsistencies in thread sleeping and having propagations all out of sync. I think I know how to do it and I'll get to it eventually.

OwenMcGee commented 2 years ago

I would suggest rather than adding a new component to do this, simply adding a variable "delay time" input to BUF gates.