Close

Project logs are ...?

A project log for sdramThing4.5 "Logic Analyzer"

An AVR, 128MB SDRAM DIMM, old laptop LCD, and a handful of TTL chips -- 30+MS/s 32-channel logic-analyzer interface for an analog 'scope

eric-hertzEric Hertz 02/25/2015 at 05:350 Comments

Much like my project, I keep meandering around the details I intend to work on... ...with my project logs. What my last project-log was *intended* to be about was regarding the irony that I've managed to get this entire crazy thing working to the extent that it does... (sdramThing 1.0, 2.0, 3.0, each of which functioned great for the purpose)...

...and yet, something as simple as the logic/math to move a couple cursors around on a screen eluded me for *hours upon hours*.

Seriously, the concept's pretty simple. There're two cursors, they move up and down, left and right. The "lower" cursor shouldn't cross over the "upper". They shouldn't be allowed outside the limits of the screen. The step-size is variable... 2^n pixels. Not so complicated, really...

...but the actual process... Eluding me.

E.G. the upper cursor is located on line 10, the bottom cursor is located on line 15 (the screen draws Y downward). The step-size is 128, and I try to move the lower cursor upward. A) It shouldn't cross past line 0. B) It shouldn't cross past the upper cursor... Not so difficult. Right?

E.G.2: Both cursors are in the same positions as before; upper is somewhere mid-line on line 10, lower is somewhere mid-line on line 15. But this time both are selected, and I try to move them upward. What should happen? Doesn't really matter to me, at this point, as long as they don't cross 0 and don't cross each other.

E.G.3: Same as above, except the upper cursor is, say, at (10,128), and the lower cursor is at, say, (15, 25)... Now both are moved upward, simultaneously, with a step-size of 128... Now, what should happen? Again, they shouldn't *cross*. The "upper" should stay left of the "lower", if they're on the same line...

Now, it seems a bit more complicated, but not horrendous... But then, I've come up with so many such weird-cases that it's just been overwhelming.

Throw in the mix that the "upper" cursor has to lie in a certain range of pixels, which varies depending on which line it's on... and it's somewhat sporadically-placed along each line... and it's significantly more complicated... (move both cursors right, they're only 10 away from each other when they start, but the left cursor can't be at the requested-position, so must be shifted 20... now they've crossed-over.) So many weird cases.

I've wound up with a while loop that just keeps trying and trying until it gets there... it's horrendous, and huge, and filled with so many steps, and in the end the motion is darn-near unpredictable. Move up, and it ends-up moving up and left. WEE!

It's just funny that something seemingly so simple as moving around a couple cursors is so hard to wrap my head around. Maybe it's still not my month.

Discussions