New DEBUG Crop Feature (Requires v50 -- Updated 16 FEB 25)

I was speaking with Chip yesterday about debugging windows and shared that I really like the crop widget in the Nextion touch displays. We spoke for about 15 minutes and this morning sent me an email that the feature now exists (in PNut).
I think this provides a real opportunity for students and experimenters to make virtual equipment/displays using P2 DEBUG. Of course, this needs to be made cross-platform so that everybody wins.
I'd also like to see the feature use PNG files instead of BMP. I used Inkscape for graphics but it won't export a BMP (which is bigger, anyway). I found that Gimp (also freeware) will let me import the PNGs and export as 24-bit BMPs (32 bits are not necessary as there is no alpha channel used with the BMP).
As I'm a simple guy, so I made a simple demo: An 8-bit LED counter that looks like 5mm LEDs on an aluminum panel. I'm sure the creative types will come up with a lot of neat ways to take advantage of this new debug feature. The updated version alternates between red and green LEDs.
Get version 50 of PNut here:
-- https://obex.parallax.com/obex/pnut-spin2-latest-version/
Comments
As an exercise I added a digital display to the demo.
Note: Updated 16 FEB 25 for PNut v50.
I just tried the demos and PNut49.1 and everything worked great, thanks @cgracey @JonnyMac
Thanks, Jon! I didn't know that you had posted it. Looks good.
I stayed up very late last night working on this -- will talk about it and the object I wrote for my friend Josh during the March Zoom call.
Note: Updated 16 FEB 25 for PNut v50.
I created the graphics using Inkscape (inkscape.org -- freeware). It's one of my favorite tools for creating screens for Nextion displays, tech diagrams for work, and even the outlines and graphics for PCBs. To convert the PNG files created by Inkcape, I open in Gimp (also freeware) and export as a Windows BMP.
This is the kind of idea I had in mind when I originally spoke with Chip about adding the crop feature to debug. This is a simple (not practical) demo, but I hope it inspires others to make neat test/lab interfaces. I like developing UIs for the Nextion touch screen, so I'm happy that with a bit of code I can do similar things in the plot debug window.
You can flip the switches by left-clicking on each. To change the display radix, press the first letter of the base: the program supports decimal, hex, binary, and octal. If you right-click (anywhere) the radix will change to the next in order. Press the spacebar to reset all the switches.
There's probably some efficiency things that could be done -- please post your ideas and suggestions.
Note: Updated 16 FEB 25 for PNut v50.
FYI, Spin Tools IDE, work in progress...
That's very good - I foresee a library of widgets which would get reused for many projects? How about a graphical GUI designer to generate debug statements ;-)
Bob
Excellent, @macca! BTW, I just got an email from Chip. He's changing the crop commands from
to
I think using width and height of a crop zone will make programming the feature a little easier.
As an experiment tonight I created a simple analog meter, then added 7-segment digits with decimal points for grins. The debug window looks like this:
There is still a bug in the CROP feature in v49.1 that @cgracey is working on. I got around it by combining my meter face and the 7-segment digits into a single bitmap.
Note: Updated 16 FEB 25 for PNut v50. Added yellow and white digits to bitmap.
Chip showed me how to use the PRECISE mode of the plot window to get nicer needle movement. The program has been updated to 0.3.0 with a constant to move between precise and normal mode.
Decided to make the digits bigger (the advantage of working with vector graphics when creating) and allow the digit colors to be selectable (via constant: RED, GREEN, or BLUE).
So nice.
What about re-directing the DEBUG output to the video add-on, instead of the PC?
Even if that takes a couple cogs, or later uses another Px as a co-pro, would sure seem like a neat way to build displays.
Thanks.
I've updated all my demos for PNut v50. The layer crop issues I experienced in v49.1 have been corrected and the x, y, w, h format for crop is much easier to code.
Super! Thanks, Jon.