Schemascii ± 1
I spent the last two days fooling around with my half-idea of a diagramming program, Schemascii. What it’s supposed to do is be able to make a diagram of a circuit (like the ones you might make in Eagle or KiCad before you plan a circuit board) out of a messy ASCII-art representation.
So far, I have implemented the routines that scan the file first for the components, and second for the connecting wires. The wires are also able to be rendered, but it’s a little buggy.
For testing I have been using this diagram of a 555-timer charge-pump polarity inverter:
So far, my program is able to run around and grab all of the components off the diagram, and also grab the “BOM data” that I placed at the bottom. It ends up in this big dictionary:
Note on the complex numbers
I am (ab)using Python’s complex
number as a point or vector, but this kind of makes sense – think the complex plane. The rationale for this is a lot of the mathematical operations I need to do with points are already built-in on complex
objects, such as finding the midpoint ((p1 + p2) / 2
), finding the length (abs(pt)
), finding the angle (cmath.phase(pt)
), etc. svgpathtools
takes the same approach.
The code for the wire finding is also able to render the wires to SVG, and produces this output on the same circuit:
When put into a <svg>
and styled, it reveals a crapload of bugs:
You can mouse over the wires here to see what is connected to what…
…and this reveals the length-2 parts of the wires are getting yanked weirdly to the side, and the length-1 wires aren’t getting rendered at all. This is a cause of great frustration for me, because it doesn’t make sense that it doesn’t render length-1 wires at all. They need to be rendered!
I’m guessing half of the bugs here in my code are caused by stupid off-by-one errors in the search loops, and the rest are just bad algorithms on my part. I really hope I can get these fixed!
Related Posts
- Now Fully Two-Dimensional
- Schemascii ± 0
- In Defense Of Eval
- Perhaps It Was Too Complicated
- Zero-Thickness Tree