I recently got my hands on a SMART Response XE, which is a defunct education device based on a ATMega128RFA1. It's basically a beefy arduino with a keyboard and screen.
The device that I bought came preloaded with a fork of Arduino BASIC. It took me an hour or two to get the basic control flow down, but its simpler than I expected.
The REPL flow is quite nice.
You can swap between 9 banks of memory using mload {slot}
and msave {slot}
where slot
is between 0 and 9.
You can immediately execute an expression by typing it and hitting enter.
You add code to your program by prefixing an expression with a line number.
To delete a line, type the line number without any extra characters.
Use list
to see your source and run
to run your program.
These take a line number as an argument so you can skip around.
In a modern language like Python, you're given more control over execution flow of the program.
In particular, IF
expressions are limited to a single expression.
If you want to run multiple lines in a branch of code, you must jump to a line to continue execution in that code block.
The result of this is that line numbering becomes something that you need to mindful of during development.
There are observations or minor improvements that I would make on the implementation of BASIC on this device.
- I would set
enter
to be the down or right key. I keep wanting to use thebackspace
key for it's intended purpose, and it's a little annoying to have to change it. A dynamic setting could be cool, built into the environment as a function. - When running
LIST
, hitting enter or down skips the last line in the entry, which means I can't see all the code I've written. This is a small off-by-one error. I think this is related to setting the position to the 7th row; if I do this and print a value, then we'll automatically scroll the buffer forward. - Hitting
q
when listing code should put me back into the the main interpreter. It would also be nice to see a pager of some kind at the bottom of the screen (like less), but it's by no mean necessary. - I would like a way to edit the current line using direction keys, without having to delete everything that I just wrote.
- I would also like a buffer for history. Pressing
up
should bring up the previous statement, like sh/bash. - Hitting any of the buttons for math (=,+,-,x,/) is awkward. I need to have both fingers on the left-hand side of the keyboard. The bottom two keys of the display would be useful as extra modifier keys, since they're currently not doing anything.
meta+shift+v
makes for a very unintuitive underscore. This should probably be under-
. Actuallyshift+space
is probably supposed to be the combo.- A
HELP
function might to start programming without having to dive into various docs. Alternatively, having a canonical reference with some examples would be cool. I'll try to include some useful examples in this doc, but it would be nice to have it built into the system. - The
POSITION
function takes column, then row. Which in retrospect make sense, given that origin is the top left and the arguments arex, y
- There aren't any trigonomic functions to play with e.g.
sin
,cos
, ortan
, nor functions likesqrt
. Implementing these from scratch seem little tedious when they can be wrapped from the c standard library. But I suppose implementing cosine from scratch might not be the worst thing to do.
- https://www.tindie.com/products/subsystems/smart-response-xe-with-arduino-basic/
- https://www.tindie.com/products/bradanlane/smart-response-xe-developer-kit/
- https://hackaday.com/tag/smart-response-xe/
- https://github.com/robinhedwards/ArduinoBASIC
- https://github.com/Subsystems-us/SMART-Response-XE-Tiny-Basic-Port
- https://gitlab.com/bradanlane/srxecore
- https://simba-os.readthedocs.io/en/latest/
- http://www.ulisp.com/
- https://www.bigmessowires.com/2016/05/06/fc8-faster-68k-decompression/
Went through some grief trying to figure out why srxecore printing is slow slow.
I'm trying to figure out timing issues on redrawing the screen. The original port loops over 100 iterations of printing a variable with 138.04ms per loop. The new library loops over 10 iterations with 1005.5 ms per loops. This is significant, so refactoring we go...
_lcd_set_active_area
It turns out quite a bit of this testing was limited by platformio not updating the library after it's changed.
It'll pull the library once, and won't change it afterward.
I'll have to pin the library to specific versions at some point.
I went into some rabbit holes trying to figure out how to profile the code to get a sense where its slow.
The one that stuck out to me most was printing out the location of the program counter and counting that against the map of the compiled code.
This one would be cool if I only had serial access...
I also decided that I wanted to add a few more features to the basic implementation.
https://github.com/slviajero/tinybasic/blob/main/MANUAL.md
I dived into adding a filesystem into the device.
I spent about two days trying to figure out how to use littlefs.
When I added my original implementation into basic, there seemed to be some weird things going on that would cause it to hang during runtime.
I tried it again using a bare platformio configuration.
Debugging was taking a significant amount of effort, so with the help of a friend I got the ICSP interface soldered up so I don't have press down on the development board.
I put together a program to debug littlefs by defining my own
LFS_TRACE
macro that prints to the screen.The srxecore library was causing issues here because all of the code is defined in headers causing functions to be declared multiple times.
I went through the process of rewriting the library to separate out the function definitions and static variables into code files so these wouldn't be recompiled every time it got included.
I also had to change my program so it was compiling c and not c++, which apparently mattered to littlefs functioning or not.
I managed to format the flash, create a file, read a file, and delete a file.
With this, I can start moving on to some other projects that build on these components.