FORTH on the PicoCalc

Hi Travis,

Any chance you (or others) can supply some UF2 files for the standard PicoCalc 2040? I am not familiar with the tool chain yet but would like to try some things out.

Thanks,

Paul

There are two problems with that at the moment. The first is that I’m on vacation, and I didn’t bring along an RP2040 board (and an actual RP2040 needed to build a UF2 for it). The second is the number of possible configurations ─ there is both a graphical and a text-only terminal emulator, and there are three different fonts supported, 5x8, 6x8, and 7x8 pixels. That by itself makes six different configurations.

And that is not including all the desired software (e.g. you may want a bare configuration or you may want FAT32 support for block storage and the SD card, zeptoed, tools to transfer files to and from your computer without removing the SD card, the tool to copy files between filesystems, the appropriate screenshot tool, and, if you are to use the graphical terminal emulator, turtle graphics).

If you are using a Pico 1 W (or Pico 2 W or Pimoroni Pico Plus 2 W) you may also want to have zeptoIP with the CYW43439 driver, which requires using non-free firmware and thus I do not make UF2 files including it. (Note that on the Pico 1 W you will have to use the text-only terminal emulator if you are using zeptoIP or even just the CYW43439 driver, e.g. to blink the LED, because of restrictions on available RAM.)

This is why I do not supply premade UF2 files for zeptoforth on the PicoCalc. Rather, the suggested approach is to use a premade full UF2 file from the latest release, which is currently 1.13.2, and then either use utils/codeload3.sh or zeptocom.js to load the source files per the instructions in USING_THE_PICOCALC.md. If you are not comfortable with the toolchain, I would recommend using Chrome or Chromium on your computer (note that mobile Chrome will not work) with zeptocom.js.

You need to download
zeptoforth-1.13.2.tar.gz

in the git repository
(GitHub - tabemann/zeptoforth: A not-so-small Forth for Cortex-M)
on the top right find the GREEN drop down labeled
<> CODE

This is NOT the one you want, as it gives us
zeptoforth-master.zip

Go down further on the right to find RELEASES

Releases 265

Patch-level release 1.13.2Latest
2 weeks ago
(Release Patch-level release 1.13.2 ¡ tabemann/zeptoforth ¡ GitHub)

+ 264 releases

CLICK ON LATEST

The window that opens shows
zeptoforth-1.13.2.tar.gz

This is the download archive the contains the /BIN folder with the compiled binaries.

Hi Travis,

Ok. I understand completely. I did not realize that it was that complicated. I imagine it is not. So used to being pampered with prebuilt.

I will attempt to build myself.

Thanks,

Paul

Let me know if you need any help with it at all.

I made a fix to the Attention s screenshot combo (it would previously not use a lock when flashing the display when taking a screenshot), so if you use screenshots please update to the latest.

Note that some applications such as my snow/wind example (test/rp_common/picocalc_snow_wind.fs) do not screenshot properly, as they repeatedly draw and erase the screen such that the terminal emulator is unlocked between erasing and drawing, such that the screenshot is taken when the display has been erased.

Edit:

The snow/wind example has been updated so it does screenshot correctly, as shown below:

Another update:

I have changed all references to ili9488 to st7365p, so be mindful of that next time you load the display drivers for the PicoCalc terminal emulators.

1 Like

I am the one who posted that. Zeptoforth runs great on the PicoCalc as I showed in the demo I mentioned. There is a lengthy discussion here on another thread with the author of Zeptoforth and others about it as well.

Some more changes ─ I fixed the read-battery, read-backlight, set-backlight, read-kbd-backlight, and set-kbd-backlight words in the picocalc-term module, which were previously broken. I have also renamed the extra/common/st7365p_spi_*x8_font_all.fs files extra/common/st7365p_spi_8_*x8_font_all.fs, as I accidentally broke the words’ naming convention (and contradicted my own doc).

Edit: It turned out that I had more fixing to do, so if you updated, update again… :frowning:

Here are a few demos on the PicoCalc that I implemented:

A Mandelbrot set:

A Sierpinski triangle:

A Barnsley fern:

Note that the Mandelbrot set and the Barnsley fern require an RP2350 as they use hardware single-precision floating point. Also note that the Barnsley fern implementation is based off a program written in MMBasic that was posted on this forum.

1 Like

I just set up Zeptoforth on my pico 2 w. However, after setting up the fat32 support, I can’t get zeptocom to communicate with the serial console anymore.

serial::serial-console on the PicoCalc disables the keyboard input–but I’m not seeing the “ok” message in zeptocom, and it doesn’t respond to any inputs from zeptocom.

Rebooting, and the PCalc keyboard and screen still work as expected.

This is an issue I have run into that I haven’t yet identified the root cause of. The way out of it is to, when connected to the serial console with zeptocom.js, press the Attention button (equivalent to typing Control-T if using a terminal emulator such as picocom) followed by pressing z (must be lowercase). This will display a main task interrupted message and gain you access to the ok prompt.

Are you perchance using the line editor? Just for the record, the line editor does not work with zeptocom.js except in mass upload mode, because the terminal emulator xterm.js used by zeptocom.js does not properly handle all of the ANSI codes used by the line editor. Also, the line editor should not be necessary with zeptocom.js because it has its own line editor built in.

However, I have seen this behavior when switching from the PicoCalc terminal emulator to the serial console using picocom, but I have always been using the line editor when I have done this, and I wonder whether the switch is messing with the logic of the line editor, where it is hanging waiting forever for a response to reading the current cursor coordinate.

Edit:

I confirmed that the line editor is at fault. There are two workarounds to the general issue of the console hanging when switching to the serial console, though. You only need to do one of these two things. The first is to press F1 at the start of a line to put the line editor into mass upload mode (effectively temporarily disabling it) prior to issuing serial::with-serial-console, and then at the start of the next line of input (without inputting anything before it, even if you delete it) press F2 to take the line editor out of mass upload mode. The second is to have your terminal emulator hooked up to the serial console open before you issue serial::with-serial-console.

However, because you are using zeptocom.js, there is a different issue, which is that zeptocom.js simply does not support the line editor unless it is in mass upload mode prior to connecting zeptocom.js to the serial console, and remains in mass upload mode for the duration of zeptocom.js being connected. Therefore, before issuing serial::with-serial-console press F1 at the start of a line on the keyboard of your PicoCalc and do not press F2 afterwards but instead keep the line editor in mass upload mode until you return control of the console to the PicoCalc terminal emulator.

I’ve got Conway’s Game of Life working on the PicoCalc. The source for the Life engine is at zeptoforth/test/rp_common/picocalc_life.fs at picocalc-devel · tabemann/zeptoforth · GitHub and the source for a small bit of code that instantiates it is at zeptoforth/test/rp_common/picocalc_life_demo.fs at picocalc-devel · tabemann/zeptoforth · GitHub.

Here is a screenshot of it in action:

Note that once the two source files are loaded, in that order, one should execute:

life import life-demo import

and then one can execute things such as:

lrtb 160 160 my-life r-pentomino

to instantiate an R-pentomino with its upper lefthand corner at (160, 160) and:

my-life run-life

to run the life world (which will be exited by pressing a key on the PicoCalc’s keyboard).

1 Like

zeptoforth 1.14.0, which includes optional support for the PicoCalc, is out!

As a result, the picocalc-devel branch has been merged into the devel and master branches and is now considered deprecated.

Also, there is a new build script for building zeptoforth on the PicoCalc from sources, with included support for FAT32 on SDHC cards, zeptoed, transferring files between your board and your PC, and taking screenshots. The script is at zeptoforth/utils/build_picocalc.sh at master ¡ tabemann/zeptoforth ¡ GitHub and the directions for its use are included in USING_THE_PICOCALC.md.

Note that this script requires a bare kernel image to be installed on your board, because it builds a full build on top of it from sources. If you already have an up-to-date kernel installed and you want to return your system to having a bare kernel image, execute erase-all at the console.

After you have executed this script, your PicoCalc will be ready for immediate use!

However, you may want to customize your installation after the fact, e.g. I normally compile to flash code to enable the line editor, import fat32-tools and picocalc-term, enable the audible and visual bells (note that you may not want these enabled, per your taste), select the SDHC card FAT32 filesystem as the default filesystem with sd-fs:, and change the current directory to /TOOLS where I store assorted programs on boot.

I do this with:

compile-to-flash
begin-module init-stuff

  fat32-tools import
  picocalc-term import
  
  : do-init ( -- )
    enable-line
    picocalc-term import
    fat32-tools import
    true audible-bell-enabled!
    true visual-bell-enabled!
    sd-fs:
    s" /tools" change-dir
  ;
  
  initializer do-init

end-module
reboot

Warning, though, if you use the above code verbatim you will need to disable the line editor before switching from the PicoCalc terminal emulator to the serial console to avoid hangs (even though you can get out of these hangs with Break z on the PicoCalc or Control-T z on the serial console).