Composite video in Forth
I've been working on a project using Mecrisp Forth and a bunch of the embello Forth libraries, somewhat tweaked along the way. My project (at https://madnessinthedarkness.transsys.com/projects:fluke8050a:start ) is yet another graphical LCD replacement for an older Fluke 8050A multimeter. On aspect of this is having to watch some control signals from the existing microprocessor to capture data being strobed on to a bus. The timing is a bit tight here, and I ended up using the "bit-banding" capability on the STM32F103 part to quickly sample a number of signals.
Mecrisp Forth can generate from fairly tight code here, and just doing a simple memory reference happens pretty quickly. Here, I'm just reading the appropriate bit out of a GPIO register; no masking required.
See https://github.com/lmamakos/fluke8050a-forth/blob/master/fluke8050a/10_always.fs#L56 as an example of some defining words to help with this. This really speed up these operations quite a bit.
Perhaps also of interest is augmenting some of the LCD graphic display code. Since I was only doing SPI writes to the display, I modified the SPI I/O words to not both write and read. By doing so (and not waiting for the write to complete), I was able to considerably increase the performance of the drawing routines. The Forth code would compute the next byte to be written in many cases (like rendering a bitmap) while the previous byte was being clocked out. Coupling this improvement with changing the font rendering to use a new "render a bitmap" primitive (see https://github.com/lmamakos/fluke8050a-forth/blob/master/fluke8050a/tft-ili9341.fs#L248 ) was a large improvement over setting individual pixels.
Forth sure made it great fun to try out this stuff incrementally! Thanks for providing a wonderful foundation that I could build upon.
RE: Composite video in Forth - Added by jcw 4 months ago
Great to see soem of the Embello code going places - and thanks for sharing.
I like the idea of the SPI speed-up. There are probably tons of opportunities for further refinement.
Have been doing quite a bit of Forth recently... I'm happy that you like it as well!