cdelker / schemdraw

MIT License
103 stars 20 forks source link

Saving timing diagrams, truth tables and others #42

Open jangenoe opened 2 months ago

jangenoe commented 2 months ago

Please note somewhere in the documentation that:

are all elements. This is excellent, because this enables them to be added inside a schematic, explaining the functionality. But elements cannot be saved as such.

There is however a very easy and convenient way to save them, i.e. by adding them to a drawing using a single element. The example below saves a timing diagram from the tutorial in the file test.png

from schemdraw import logic
import schemdraw

with schemdraw.Drawing(file='test.png'):
       logic.TimingDiagram({'signal': [
        {'name': 'clk', 'wave': 'P......'},
        {'name': 'J', 'wave': '0101', 'async': [0, .8, 1.3, 3.7, 7]},
        {'name': 'K', 'wave': '010101', 'async': [0, 1.2, 2.3, 2.8, 3.2, 3.7, 7]},
        {'name': 'Q', 'wave': '010.101', 'color': 'red', 'lw': 1.5},
        {'name': r'$\overline{Q}$', 'wave': '101.010', 'color': 'blue', 'lw': 1.5}],
         'config': {'hscale': 1.5}}, risetime=.05)