wavedrom / wavedrom.github.io

Digital timing diagram editor
https://wavedrom.com
MIT License
915 stars 158 forks source link

property config{hbounds:[tickmin,tickmax]} #13

Closed itsayellow closed 8 years ago

itsayellow commented 8 years ago

This is a feature request.

I like to make big, totally complete timing diagrams, but every once in a while (for a document or presentation) I only want to show a simplified version of a section of interest.

It's easy to comment out signals (reduce y size), but sometimes editing a js file to show a certain xmin xmax bounds (reduce x size) is tricky or cumbersome.

Could a property be added to config{}, that specifies starting and ending tick numbers, so that the area rendered only includes that part of the horizontal span?

I don't have to be set on this particular syntax, but some way of specifying tickmin and tickmax would be cool.

drom commented 8 years ago

@itsayellow Thank you for generating all these great ideas and bug reports. This does sound useful. I just need to find some time for implementation. Do you want to help with code ? PRs are welcome :smile:

itsayellow commented 8 years ago

I'd be happy to try, but I don't know much about javascript, other than what I've cobbled together in the past couple of weeks using wavedrom to make waveforms. Let me start looking through the source and see if I can start to understand what's going on.

I really do appreciate all the good work you've put into this, and I will contribute all the help I'm able to!

itsayellow commented 8 years ago

This isn't a modification to wavedrom, but it works in "user-space" code to do what I wanted. I start by making a wavedrom object, and then run it through my javascript to make it display the hbounds I want. I then pass the resulting waveform out to wavedrom.

There may be a more elegant way to do this with access to wavedrom's innards, but this so far seems to work fine for me.

Attached is a code suitable for putting into wavedrom and some test waveforms. Adjust the arguments to hbounds to alter the start and end points of the displayed waveforms. tick and tock are adjusted to move with waveforms if they exist. If everything is working as I think it is, it should look completely like you cropped the original view of your waveforms.

hbounds.txt

itsayellow commented 8 years ago

I fixed a bunch of bugs. Now it checks your "ticks" property to use when you specify your hbounds. It cleans up (removes) nodes that are off the left of the waveforms (not visible anymore) Also just some bugs squashed. hbounds.txt

itsayellow commented 8 years ago

Yet another update. Now if necessary, I try to up-sample the wave character string (and divide the period) as much as possible to get an equivalent waveform, but be able to make the right edge as non-ragged as possible. (Making use of wavedrom's 0.5 tick resolution.)

This helps for phases that are non-integer, or periods that are > 1.0, or both.

hbounds.txt

itsayellow commented 8 years ago

Another important bugfix for my code. It used to use "splice" to modify "data", which was a problem because it modifies the original array. In one case I was reusing the same array variable for data for multiple waveforms and they were all getting corrupted. I now use "slice" instead which returns a copy of the array, not modifying the original array.

hbounds.txt

Also, should this issue be moved to drom/wavedrom ?

Also, it is important to note, that running waveforms through this code also fixes Issue 142 in drom/wavedrom! :) https://github.com/drom/wavedrom/issues/142

drom commented 8 years ago

Great. fixed in the core wavedrom project.

itsayellow commented 8 years ago

Is the core wavedrom about to get a new release? I'd love to see the native hbounds in the stand-alone editor. :)

drom commented 8 years ago

@itsayellow yes, I am cleaning build process #16 for the app. It will also include your changes.