Shop Learn
Mixed Signal Scope in 1080p (now with C front end) — Parallax Forums

Mixed Signal Scope in 1080p (now with C front end)

RaymanRayman Posts: 11,835
edited 2020-11-30 18:02 in Propeller 2
I've rewritten this 2bpp GUI in C using FlexC. The drivers are all still a mix of Spin2 and PASM2.

The app itself is the same as before (except that the palette has changed):
The app is a oscilloscope with two analog and six digital channels.
The output is VGA and the input is USB mouse.
The trigger can be analog or digital, the analog trigger level is adjustable. There are gain knobs for the analog channels.
The vertical bar in the middle of the traces is the trigger point. It can be moved with the Horizontal Delay slider.
There are two cursors that can be enabled and show up as thin vertical lines on the traces.
Each pin# entry has an "SP" button next to it which can be used to adjust the smartpin settings for that pin.
There is also a another SmartPin interface via the "Configure Smartpins" button on top of screen.
You can view the IN/OUT/DIR status and set OUT/DIR on all pins using the "View/Set Pins" button.
This app is useful for checking out smartpins and testing out analog things.
The app runs Chips DDS "Direct Digital Synthesis" code to generate analog waveforms on pins P12..P15.
The analog channels come set for P10 and P11. I'm using jumpers to connect P10 to P12 and also P11 to P13.
I changed the DDS sine wave to be lower in amplitude in order to test out the gain control.

The palette has been changed to the Microsoft style of 256 color palette with 216 evenly spaced colors, 10 extra grayscale colors and 30 colors free.
This could allow colors to be specified in RGBQuad format when declared and the changed to closed match in palette at run time.
4032 x 3024 - 5M
3024 x 4032 - 3M


  • RaymanRayman Posts: 11,835
    edited 2020-11-30 16:40
    Did this rewrite to test out FlexC and improve my C skills.
    A lot of the Spin2 code is very similar to the C version, but there are some key differences.

    1. Structures are a big improvement for this kind of code. All the GUI elements now have a structure. This makes the code look much cleaner.
    Classes would have been better, but I'm not sure how much of that works.
    2. #Include lets me put each of the various forms and also the form definitions in separate files. That makes things easier to sort out with a big code like this.
    3. printf, sprintf and the like are really wonderful and make numeric output on the screen and in the terminal really easy.

    There are some other things that are better in C, but these are the main things.

    On the flip side, there are some things that are better in Spin2.
    1. The "File" directive is great. There are a lot of graphical bitmap data included in the Spin2 code using it. It's crazy that you have to do data as text in C.
    2. The way you can define binary and hex data to include underscores is really nice. Makes it easier to see what is going on and avoid errors.
    3. They way you can define data is much simpler in Spin2. Things like this are easier and look better: byte 3,+6,4,-2,"D1",3,+5,4,-2,"D2"
    4. Inherent access to things like ports and smartpins and such is part of the language which is a benefit when doing low level things.
    5. I prefer the color coding when doing assembly in Prop Tool. Guess I'm just used to the color scheme.

    Anyway, for now, I'm just going to leave the drivers and access to them in Spin2.
  • RaymanRayman Posts: 11,835
    edited 2020-11-30 16:37
    The VGA driver is a bit complex.
    It's based on P1 style graphics with 16x16 pixel tiles and 2 bits per pixel (four colors per tile).
    But, it's extended to 1080p and also now allows a tiles colors to be any from the 256 color palette.
    There is also a mouse cursor, the video cog splices this in on the fly.

    The driver uses 3 cogs. One outputs the video, one creates video scan lines on the fly from the tile data, the other dynamically alters the palette to allow each tile to have it's own set of colors.
    The color cog also does graphics via an interrupt mechanism. The graphics is almost a direct copy and paste from Chip's P1 code.
    But, this graphics, shared with the color swapping code, is too slow for this particular app.
    So, there's a separate graphics cog used here to update the scope data windows. Other apps without a lot of graphics may not need this.

    The mouse code is from @garryj . I changed it just a bit so that it tracks the absolute mouse position and updates this info in the main cog so it's always up to date.

    The digitizer is fairly straightforward... It just saves INA then INB then the analog channels in a loop using fast writes. The fastest it can go is 24 clocks between points.
    Of course, the P2 can actually capture data at the full clock speed, but this was just the easy way of doing things.
Sign In or Register to comment.