SmallBASIC
Mickster
Posts: 2,689
Not to be confused with the MS product
Just a heads up:
Much of my FlexBasic programming, I want to do/prove on the PC where I can graphically output to the screen and I want to edit/run instantly.
I just came across SmallBasic and I have to say that I'm darned impressed.
First impression of the IDE made me seriously consider uninstalling because it's very sparse but once you get familiar with it....well it works. I tend to do serious editing in Notepad++ but after loading into SmallBasic, tweaking is no problem. Hit F9 and instantly Run (interpreter)
The default "theme" didn't suit me but [Alt-t] will index through a few alternatives.
Craig
Comments
Thanks, Craig, for the heads up!
I sometimes think, that it seems to be forgotten, that a PC can indeed be programmed in just a few lines of source code and that this can be fun. Basic is a great way to make this possible, even if you don't do it very often.
These days I wanted to try some graphics fun project and ended in doing it with freeBasic.
Christof
Only in BASIC can I edit/run(instantly) on the PC where I can verify correct motion trajectory (6 CNC axes) by plotting the paths on the screen and then transfer to a compiler (FlexBasic) on the P2, making only minor syntax changes. Progress just got a major boost
Loving this obscure interpreter
Craig
Add a screen to a P2, make graphics directly in FlexBasic.
I actually don't need graphics in the end-product (I do that stuff on my Android HMI), I am working with muti-axis motion profiling and trajectory generation and plotting to the screen is much more convenient than driving actual motors. Furthermore, FlexBasic compile/download, as fast as it is, still is not as fast as simply hitting F9 to execute the SmallBASIC code.
However, I'd like to look at adding video output to my P2 at some point but I haven't been following too closely. In summary, what capabilities do we have, using FlexBasic and what hardware is required (I had planned to ask you this question at some time in the future) ?
It depends on the board used.
If using P2-EC32MB, we can display up to 1920x1080 at 8 bpp VGA or up to 1024x600 at 50 Hz and 32 bpp HDMI
For a HDMI output, a clock speed is the limiter as the pixel clock has to be CPU clock/10
For a VGA output, the PSRAM clock limits the bpp to 8 at FullHD, and the CPU clock limits the resolution. I tried to display 2560x1440 using VGA. I finally got a picture but this required searching for a stable combination of clocks and timings. Not usable.
If using non-PSRAM based solution, the HUB RAM size is the main limiter. We can display up to 1920x1080 at 1 bpp on VGA or 1024x600 at 4 bpp HDMI, while both options eat over a half of available HUB RAM for a framebuffer
As we have
class using
in FlexBasic , any graphics driver written for a P2 will work. There are a lot of them available for a P2, but I use what I wrote myself, so I know what is inside and then I can change what I want.I have a display list based HDMI driver that can use HUB RAM or PSRAM for its frame buffer. The display list allows to define the display memory address, text or graphic mode, repeating lines, horizontal zoom and bpp (up to 8) for every line, so it is possible to have for example a 1 bpp B/W screen with some 8bpp color lines or graphics mixed with text. This driver, however, doesn't support mouse pointer/sprites: the cog ram is full.
For the P2-EC32, I wrote another 3 drivers that are much simpler. They still have a display list, but it only controls the memory start address and repeating. No multiple graphic modes/horizontal zoom. Instead, these drivers allow to define up to 16 sprites. One driver is 8 bpp HDMI, another is 32 bpp HDMI and there is a version that displays 8bpp 1920x1080 using VGA. The maximum available resolution using HDMI is 1024x600@50 Hz at 336 MHz - this clock is near the limit for the EC32.
These drivers have graphics procedures (lines, circles, pixels, rectangles, text) inside. An example of what can be done (the main program is written in FlexBasic):
There are more examples on my YT channel, including the multiformat audio player, that was also written in FlexBasic.
I used a modified version of my HDMI driver in the air disinfecting robot. The robot displays information on a 5" 800x480 HDMI touch screen. The new Wuerfel21's USB drivers can read data from the touch panel (!) so the new version of the robot firmware (if it will be ever written... ) may allow the touch screen user interface for this robot.
@pik33
OK, now this is getting really exciting, especially the fact that we also have a guru who uses FlexBasic
Craig
which of course is ... https://www.youtube.com/@pik33100/videos
Dave
@pik33
I don't suppose you have a high-res text example? Can we load fonts?
Craig
You can see the text on the YT clip attached to the post #6.
I use 8x16 or 8x8 font in my drivers. I have 2 font styles defined - PC and Atari ST mono.
There are 2 procedures that draw characters on the screen - "slow" and "fast". A slow version calls putpixel to set every pixel of the character. That's why it is slow, but it can draw the character at any position on the screen.
The fast version uses inlined asm and operates on longs. One long is 4 pixels at 8 bpp, so the horizontal position of the character is limited to every 4 pixels, but it is much faster.
The font definitions are placed in HUB RAM so every character can be redefined. And you can always open a file and reload the definitions while the program is running. One of last addition to the flexprop is a flash based file system, so the font can be loaded from the flash.
The first and most complex version of the driver has text modes in it. In this mode one character needs one long in the frame buffer. This long defines the character at byte #0, byte #1 is unused, bytes 2 and 3 select background and foreground color. This saves a lot of place in the frame buffer while still using 8-bit color space.
Of course I don't know how it is solved in other drivers, but I think it is done in similar way: the font definition is located somewhere in the hub and there is a procedure that draw a character on a screen.
My P2 related stuff/mess is here: https://gitlab.com/pik33/P2-retromachine
The player. Here you can see the text The title bar and the scroller at the bottom of the screen uses ST style font while the rest of the player uses PC style font. 1024x576x8bpp, HDMI