Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 08:57 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2 Mandelbrot Explorer

     Page 1 of 3    
Author Message
Sasquatch

Guru

Joined: 08/05/2020
Location: United States
Posts: 377
Posted: 04:14pm 03 Sep 2020
Copy link to clipboard 
Print this post

Here is a first pass at an interactive Mandelbrot Explorer.
Should run under MMBasic 5.05.04 Release (not tested) or later.

Constructive feedback would be appreciated.

The 'C' source code for the Mandelbrot CSUB has not changed since the original thread
https://www.thebackshed.com/forum/ViewTopic.php?TID=12306&PID=149589#149589#149552

Press H or ? for help screen.


Still on the ToDo list:

Support for Nunchuk and Classic Controllers
File Menu to allow coordinates to be Saved/Loaded
Zoom to frame (drawn box)



MandelbrotExp.zip
Edited 2020-09-04 02:36 by Sasquatch
-Carl
 
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 10:20pm 03 Sep 2020
Copy link to clipboard 
Print this post

Locks up on mine after plotting the set, running 5.05.05...but perhaps not the latest 5.05.05. I did a sanity check by running some other games, they work as before. Something to do with keyboard input perhaps...

P.S. I will probably do this same program, but when and how long it will take....this is hobby #3 of 3 :-)
Should learn a lot studying this!!

Steve
 
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 12:13am 04 Sep 2020
Copy link to clipboard 
Print this post

After some experimentation, I got it to work by pressing a cursor key to continue from the help screen. Cursor keys work as expected, but it's very odd otherwise. After moving the cursor, pressing 'i' results in repeated zooming in. If 'o' is pressed after moving the cursor, it appears to act normally, but pressing 'i' again at first works, then reverts to a loop of zooming in. I'm not seeing anything in the code to account for this.
 
Sasquatch

Guru

Joined: 08/05/2020
Location: United States
Posts: 377
Posted: 02:54am 04 Sep 2020
Copy link to clipboard 
Print this post

  yock1960 said  After some experimentation, I got it to work by pressing a cursor key to continue from the help screen. Cursor keys work as expected, but it's very odd otherwise. After moving the cursor, pressing 'i' results in repeated zooming in. If 'o' is pressed after moving the cursor, it appears to act normally, but pressing 'i' again at first works, then reverts to a loop of zooming in. I'm not seeing anything in the code to account for this.


Thanks for the feedback!

The CSUB interferes with the normal Keyboard functions when it takes over the system for a few seconds to render the image.  I thought I had worked around the problem, but apparently not well enough.  I'll work on this some more to see what I can come up with.

Does anyone else have the same problem?  Does anyone have it working OK?  I was able to get it to work reliably on my system so it's interesting that others may be having problems with the keyboard commands.
Edited 2020-09-04 12:55 by Sasquatch
-Carl
 
Sasquatch

Guru

Joined: 08/05/2020
Location: United States
Posts: 377
Posted: 03:54am 04 Sep 2020
Copy link to clipboard 
Print this post

  yock1960 said  After some experimentation, I got it to work by pressing a cursor key to continue from the help screen. Cursor keys work as expected, but it's very odd otherwise. After moving the cursor, pressing 'i' results in repeated zooming in. If 'o' is pressed after moving the cursor, it appears to act normally, but pressing 'i' again at first works, then reverts to a loop of zooming in. I'm not seeing anything in the code to account for this.


Please try this version and let me know what you find.  I eliminated the Inkey$ function from the keyboard reading loop and added a small delay after rendering the image to give MMBasic some time to do it's background processing.



MandelbrotExp.zip
-Carl
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 04:30am 04 Sep 2020
Copy link to clipboard 
Print this post

Your latest version works well for me. I like the multi-key aware cursor movement. Diagonal moves work nicely. Centering the cursor after a new zoom is nice logical behavior.  

About the only thing I don't like is not knowing what I am zooming in on. I think that requires a selection box. A quick look at the code shows that scaling goes by a factor of 2.

Also, I wonder if the [List Current Coordinates] should track the cursor, not just the center of the screen.

Looking good!
Visit Vegipete's *Mite Library for cool programs.
 
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 10:26am 04 Sep 2020
Copy link to clipboard 
Print this post

Vegipete, what revision firmware are you running? Last night I updated to the 8/31 dated 5.05.05 (versus the 8/30 release) just to see if it made any difference...no. Anyway, the new version of Mandelbrot explorer has the same issues for me. So, it's either firmware or keyboard or a bit of both. On the original version, I tried playing with option keyboard repeat settings and adding pauses in the code....just broke it in other interesting ways, some 'crashing' the system rather than just freezing. The new, cheap USB keyboard I'm using has been working flawlessly otherwise as far as I can tell.

Steve
 
Sasquatch

Guru

Joined: 08/05/2020
Location: United States
Posts: 377
Posted: 02:41pm 04 Sep 2020
Copy link to clipboard 
Print this post

  yock1960 said  Vegipete, what revision firmware are you running? Last night I updated to the 8/31 dated 5.05.05 (versus the 8/30 release) just to see if it made any difference...no. Anyway, the new version of Mandelbrot explorer has the same issues for me. So, it's either firmware or keyboard or a bit of both. On the original version, I tried playing with option keyboard repeat settings and adding pauses in the code....just broke it in other interesting ways, some 'crashing' the system rather than just freezing. The new, cheap USB keyboard I'm using has been working flawlessly otherwise as far as I can tell.

Steve


Thanks for trying it Steve, at this point I am at a loss as to what could be causing your issues?  I hope we can get some more feedback from other users to help narrow it down.  I can't tell at this point if it's some flaw in my approach or if it's a unique issue with your setup somehow.  If we can improve the code to work better I'm all for that.  I'm willing to keep trying a few things as I get more info or new ideas. If you can beg, borrow or steal a different keyboard to test that seems like a good first step at this point.

Also if you could try the "Mouse" demo from the "Graphics Programming" manual it uses similar key reading techniques.  You can download the mouse.zip file here:

https://www.thebackshed.com/forum/ViewTopic.php?TID=12125&PID=147076#147076#147076


  vegipete said  

Your latest version works well for me. I like the multi-key aware cursor movement. Diagonal moves work nicely. Centering the cursor after a new zoom is nice logical behavior.  

About the only thing I don't like is not knowing what I am zooming in on. I think that requires a selection box. A quick look at the code shows that scaling goes by a factor of 2.

Also, I wonder if the [List Current Coordinates] should track the cursor, not just the center of the screen.

Looking good!



Thanks VegiPete!  Yes, the zoom factor is fixed at 2 for now so try to imagine a frame that fills half the screen centered on the cursor is what you will be zooming in on.  I think an option to set the zoom In/Out factor will be a good addition.  Eventually I plan to pursue the "drawn box" zooming as we discussed but I think Nunchuk support comes first.  

I had also thought about having the coordinates track the cursor movement but I didn't necessarily want it on screen all the time.  I think maybe the option to toggle it on/off would be good.  Also the idea was to provide the coordinates of the current view so that you could return to the view using the 'E' command.  I also plan to allow Load/Save of the current coordinates to files.

My early testing has shown that it's a little awkward to try to "draw" a box or frame on the screen with the keyboard, it's super easy and intuitive with a mouse but a keyboard is another matter.  Maybe a joystick will be better, I'll do more testing.  Also, the aspect ratio of the "zoom box" is basically fixed so it's just the size and position of the "zoom box" that needs to change.  I think the "zoom box" will need to be able to be partially off-screen if you want to zoom in on something near the edge of the current view.  Lots to think about.
-Carl
 
Sasquatch

Guru

Joined: 08/05/2020
Location: United States
Posts: 377
Posted: 10:11pm 04 Sep 2020
Copy link to clipboard 
Print this post

Based on user feedback (and a big thanks to you both!) Here is Mandelbrot Explorer V0.96

I have made the following enhancements:

Now using page buffer to eliminate redundant rendering.

L - command key now toggles coordinate list on/off and hides cursor until moved when first toggled off.

Coordinate list now updates with cursor movement.

Z - command key allows entry of Zoom factor (multiplier). (coming soon graphical box cursor to show zoom frame)

Many other tweaks to improve user interface and timing etc.

And it all comes with the Sasquatch "Bug Free Seal of Approval"  What's that...  I sense a disturbance in the Cosmos... As though someone just found an error in my programming



MandelbrotEXP.zip
Edited 2020-09-05 08:27 by Sasquatch
-Carl
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 10:45pm 04 Sep 2020
Copy link to clipboard 
Print this post

I'm running the release version 5.05.05
A constant zooming in sounds like the 'i' key auto-repeating. I've had regular occurrences of keys repeating after being pressed and released while using my CMM2, not specific to any one program. I'm trying a different keyboard now to see if something changes.

======
I wouldn't try to draw an arbitrary box. Instead, offer a box 1/2 the size of the screen, centered on the cursor, and allow the box to be resized by factors of 2.

The numerical description of a given view contains very little actual data, so an undo stack held in an array should be easy to maintain.

My suspicion is that joystick or nunchuk control will be clunky and imprecise, largely because the CMM2 is nowhere near fast enough. My Falfus game implements a nunchuk joystick controlled 'mouse' and it is hard to use with any precision.
Visit Vegipete's *Mite Library for cool programs.
 
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 11:25pm 04 Sep 2020
Copy link to clipboard 
Print this post

Well, good news first, using several different keyboards, it works. These keyboards however, are not perfectly useable, since they probably contain hubs. One is wireless with mouse support and the other is wired, but has a builtin track pad. They can be used, but both drop keystrokes if typing is fast...err moderately fast. Original keyboard still exhibits the same...no, not the same, I no longer need to hold down a cursor key to be able to 'play', but zooming in still repeats.

As far as the interface, the rolling colors are a bit fast...minor issue, I would like a bounding box for zooming in, maybe the box appears only when the cursor is stationary. I'm not sure if it's the color scheme or my monitor, but it seems like finer detailed areas are not as crisp as I would expect at this resolution. I do have another monitor I can try at some point.

Overall a good effort. Eventuality, I will try my hand at the CSUB stuff and if successful, try some things here and on some other stuff.

The keyboard issue is still weird. I'm still a raw newbie here, but I would appreciate any thoughts you'd be willing to share.

Steve
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 07:01am 05 Sep 2020
Copy link to clipboard 
Print this post

If these comments on keyboards relate specifically to this program it is probably because the CSUB does not call the keyboard polling routine. The CSUB should call the routine RoutineChecks() at least once every millisecond by putting it somewhere in one of the loop structures
 
Sasquatch

Guru

Joined: 08/05/2020
Location: United States
Posts: 377
Posted: 02:21pm 05 Sep 2020
Copy link to clipboard 
Print this post

  matherp said  If these comments on keyboards relate specifically to this program it is probably because the CSUB does not call the keyboard polling routine. The CSUB should call the routine RoutineChecks() at least once every millisecond by putting it somewhere in one of the loop structures


Good to know Peter, I was aware anything that was not a hardware interrupt was not being serviced for a few seconds while the CSUB rendered it's image but I didn't know there was a facility for letting MMBasic service the background stuff from a CSUB!  What I found with the Barnsley Fern CSUB was that letting MMBasic run about every 10mS made a huge difference.  I'll do some testing with RoutineChecks() in the Mandelbrot CSUB.

It is interesting that I grabbed a cheap USB keyboard I had in the junk box and it has never given me any trouble at all used with the CMM2 while others seem to have issues with various keyboards.  I think some of this has been found to be related to power supply or USB cable issues.  I am wondering if some keyboard chipsets don't play well with the ST implementation of USB for the keyboard.  I have several other cheap keyboards I want to test.
Edited 2020-09-06 00:27 by Sasquatch
-Carl
 
Sasquatch

Guru

Joined: 08/05/2020
Location: United States
Posts: 377
Posted: 03:14pm 05 Sep 2020
Copy link to clipboard 
Print this post

Ok, Here is Mandelbrot Explorer V0.97


I fixed a couple of "issues" introduced in V0.96
I got a little overzealous with the cut-n-paste implementing page buffering

I implemented RoutineChecks() in the CSUB as Peter recommended.  
yock1960 - this MAY help with some of your keyboard problems.

The updated 'C' source code is included in the .zip file.


MandelbrotEXP.zip
-Carl
 
Sasquatch

Guru

Joined: 08/05/2020
Location: United States
Posts: 377
Posted: 03:22pm 05 Sep 2020
Copy link to clipboard 
Print this post

  vegipete said  
I wouldn't try to draw an arbitrary box. Instead, offer a box 1/2 the size of the screen, centered on the cursor, and allow the box to be resized by factors of 2.

The numerical description of a given view contains very little actual data, so an undo stack held in an array should be easy to maintain.

My suspicion is that joystick or nunchuk control will be clunky and imprecise, largely because the CMM2 is nowhere near fast enough. My Falfus game implements a nunchuk joystick controlled 'mouse' and it is hard to use with any precision.



Yes, the zoom box needs to have it's aspect ratio (Width : Height) fixed to match the screen aspect ratio.  So only size and position need to be adjusted.  I think I'll leave the bullseye cursor on as well so that the center is well marked.

I like the Undo idea and the 'U' key isn't doing anything yet!  It will likely not be a highly used feature, but it will round out the program nicely.

I have some ideas about the Nunchuk that I hope will work great!  I likely won't have time to work on this until tomorrow but I hope to get things mostly wrapped up then.  We'll see how much I can get done.
-Carl
 
Sasquatch

Guru

Joined: 08/05/2020
Location: United States
Posts: 377
Posted: 03:53pm 05 Sep 2020
Copy link to clipboard 
Print this post

  yock1960 said  Well, good news first, using several different keyboards, it works. These keyboards however, are not perfectly useable, since they probably contain hubs. One is wireless with mouse support and the other is wired, but has a builtin track pad. They can be used, but both drop keystrokes if typing is fast...err moderately fast. Original keyboard still exhibits the same...no, not the same, I no longer need to hold down a cursor key to be able to 'play', but zooming in still repeats.

As far as the interface, the rolling colors are a bit fast...minor issue, I would like a bounding box for zooming in, maybe the box appears only when the cursor is stationary. I'm not sure if it's the color scheme or my monitor, but it seems like finer detailed areas are not as crisp as I would expect at this resolution. I do have another monitor I can try at some point.

Overall a good effort. Eventuality, I will try my hand at the CSUB stuff and if successful, try some things here and on some other stuff.

The keyboard issue is still weird. I'm still a raw newbie here, but I would appreciate any thoughts you'd be willing to share.

Steve


Try the latest version V0.97, I enabled some background function processing in the CSUB that may help your keyboard issues (fingers crossed)  Some users have reported strange keyboard issues related to the power supply or cable used to supply power to the CMM2.  Make sure you have a good power supply and that the cable is able to provide ample current.  It might be good to try a different power brick and cable just to eliminate the possibility.

I also slowed down the color roll by 50% in the latest version 0.97

The "zoom to box" feature is in the works, stay tuned.

I think the color mapping could use some improvement to me it looks a little "cartoonish" or something.  My plan was to get everything working and then re-visit aesthetics.  I'm partly color-blind so I'm not the best person to work with the colors but I can likely get it to look better where it fades into colored speckles.

Also if you have Firmware release version 5.05.05 or later, you can try running in the new higher resolution mode.  Just edit the lines near the top of the program to un-comment the Mode 9,8 line.  The rendering is a bit slower at higher resolution
Edited 2020-09-06 01:59 by Sasquatch
-Carl
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 07:25pm 05 Sep 2020
Copy link to clipboard 
Print this post

Mostly works great. I did manage to get the auto-repeat-i happening. Rapidly hitting left/up/right arrow keys as page rendering finished managed to stop the zoom in. (The image goes to pot once you hit the machine's numerical resolution - no surprise there.)

Any chance of changing the c-sub rendering to work from the center out instead of line by line from bottom to top? Perhaps a square spiral pattern? Add to this the ability to end a rendering early and start the next one and deep zooms could happen much faster.

==============
Years, nay, decades ago, on a slower computer I crafted a Mandelbrot algorithm that worked around the perimeter of a box. If the perimeter was unchanging, then the box was filled with the perimeter colour. If the perimeter did change, the box was quartered and each quarter was recursively processed, until solid or a single pixel was left.

Later, I had access to a mainframe at the university, so used it to generate data files that I could plot at home. The numerical precision of the Fortran compiler showed up soon enough. Great fun transfering files from mainframe to mac to apple//...
Visit Vegipete's *Mite Library for cool programs.
 
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 12:45am 06 Sep 2020
Copy link to clipboard 
Print this post

I thought it was going to work with the 'compatible' keyboard this time! The first zoom in was okay, 2nd one went into a loop though. I will see if I can come up with a different PS, maybe a powered hub? Right now I'm using this goofy 2 by ac mains plugs with 2 usb port adapter thingy...maybe not 'beefy' enough?

Steve
 
Sasquatch

Guru

Joined: 08/05/2020
Location: United States
Posts: 377
Posted: 03:41pm 06 Sep 2020
Copy link to clipboard 
Print this post

  yock1960 said  I thought it was going to work with the 'compatible' keyboard this time! The first zoom in was okay, 2nd one went into a loop though. I will see if I can come up with a different PS, maybe a powered hub? Right now I'm using this goofy 2 by ac mains plugs with 2 usb port adapter thingy...maybe not 'beefy' enough?

Steve



Here is a special test version (V0.97T)  Please try if you have had keyboard-repeat issues.  If you havnen't had problems with keyboard commands repeating, probably no need to try this version.

The CSUB calls RoutineChecks() excessively

I increased delays after each keyboard operation.  It may seem a bit "laggy" after each keyboard command

These changes may be a bit extreme, but if it helps we can try backing off a bit.


Mandelbrottest.zip


I plan to test a few other USB keyboards I have on hand.  If I can re-produce the problem it would be easier to track down.  In the meantime, I need to finish the program features.
-Carl
 
Sasquatch

Guru

Joined: 08/05/2020
Location: United States
Posts: 377
Posted: 03:49pm 06 Sep 2020
Copy link to clipboard 
Print this post

  vegipete said  Mostly works great. I did manage to get the auto-repeat-i happening. Rapidly hitting left/up/right arrow keys as page rendering finished managed to stop the zoom in. (The image goes to pot once you hit the machine's numerical resolution - no surprise there.)

Any chance of changing the c-sub rendering to work from the center out instead of line by line from bottom to top? Perhaps a square spiral pattern? Add to this the ability to end a rendering early and start the next one and deep zooms could happen much faster.


Later, I had access to a mainframe at the university, so used it to generate data files that I could plot at home. The numerical precision of the Fortran compiler showed up soon enough. Great fun transfering files from mainframe to mac to apple//...


WOW, do you really think you are reaching the numerical resolution of the double-precision math???  When you zoom in until things stop looking interesting, try changing the depth to 128.  There is nearly infinite detail available if you set the depth high enough but it also increases the rendering time.

As for the rendering order, it's not to difficult to change,  we can work on this later.  I need to get this thing done and I keep getting side-tracked on other issues.
-Carl
 
     Page 1 of 3    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025