[Demo]TTB TinyBasic (USBSerial)


#1

com-crop

This demo shows a TinyBasic interpreter running on Pokitto.

When Pokitto starts, the program establishes a USB Serial port on the PC

You can “talk” to the BASIC by using a terminal program, such as PuTTY. Baud settings can be anything (9600 for example), because on virtual serial ports it has no relevance.

Typical BASIC commands work.

Source code has been uploaded to PokittoLib repository.

The point of the demo is to show how USBSerial connections between Pokitto and the PC are made.

This demo should work out of the box on a Windows PC, no need for drivers.

binary

basic.bin (60.1 KB)


#2

As always, feedback (“It works/does not work on xx”) greatly appreciated

… because this is just the first step to something else


#3

So the “basic.bin” part is the serial terminal program that runs on Pokitto?

And there’s another program that runs under windows and provides the basic interpreter that the Pokitto talks to?

Where do we get that part?


#4

basic.bin is Basic interpreter running on Pokitto. You connect and write to it using the keyboard of your computer.

In short:

  1. put binary on Pokitto (you can also load it from SD card)
  2. download & install a “terminal program”, for example TeraTerm or PuTTY. You can also use the serial monitor of Arduino IDE. Note: this is on the PC, not Pokitto
  3. Connect Pokitto to PC
  4. A new COM port should appear (Windows) or a new serial device (Linux/Mac) on the Pc
  5. Run terminal program on PC and connect to the COM port
  6. You can now control the Pokitto as if it was a traditional Basic computer (like C64 or ZX Spectrum)

#5

I’ve been wondering about how to do this for a while but never got round to asking.

Perhaps I’ll have to add Serial to my list of Arduino/Arduboy2 features to implement?


#6

You can do it. Its dead simple.

Just create a USBSerial object and you’re pretty much done.

#include "USBSerial.h"

USBSerial pc; // that's it

#7

I have just tested it and it works but not entirely correct (I think?):

  • a program like 10 PRINT "TEST runs without giving a syntax error
  • also when the line of code reaches the right part of the pokitto screen, nothing additional can be added:
    for example 10 PRINT "The line is too long cannot be entered, I get 10 PRINT "The line is too (however this runs without a problem
  • backspace does not work

#8

What OS and did you need drivers?


#9

I ran it on Windows 10, I did not need any drivers.


#10

Works on Ubuntu also, shows up as /dev/ttyACM0 , no issues using puTTY for Linux


#11

Oh no. A thought came to my mind.

Zork

… there is no return now


#12

If we could plug in a keyboard without using a computer in between now that would get me excited… As it is I am not sure of the point playing for example Zork on the pokitto while in front of a computer… Did I miss something? J must have :sweat_smile: right?


#13

Sounds like a challenge


#14

if been working a lot with ps2 keyboards and the lib for arduino
there are examples for tiny basic with display(check) and ps2 keyboard.
i build such structures and its easy and great. if you use ps2 keyboard you can make an hardware adapter from ps2(pins) to usb female port…like a hat. cheap keyboard controllers often work.
here a video


maybe this could be a way… i like this basic things
imagine if we could save programs to sd or auto run or…:slight_smile:
thanks for the work


#15

Wikipedia says that:

Tiny BASIC is a dialect of the BASIC programming language that can fit into as little as 2 or 3 KB of memory…

https://en.wikipedia.org/wiki/Tiny_BASIC

So how come the Pokitto version is 60.1 K? That doesn’t sound so tiny. Is it because of all the libraries it includes? Is this actually an “extra-large” tiny basic?

Maybe “tiny” doesn’t mean what it used to mean. :yum:


#16

Pokitto binary includes things like display, buttons, petitfs Sd card handling, USB Serial + USB CDC protocol

USB frame handling alone is probably quite a large part of that

… in addition to which the binary was built with -O3 switch (max speed), not -Os (minimum size)


#17

Wikipedia’s statement isn’t very useful.
2 or 3 KB on what? x86? ARM? Windows? DOS? ZX Spectrum?


#18

You’re correct. The statement doesn’t really mean anything without mentioning the target architecture.


#19

The first tiny basics were written for early home computers, which had 8 bit processors and 4 kilobytes or less of ram.

These computers were used with terminals or teletypes, so they didn’t need memory for fonts or graphics.

Microsoft basic ran in 4k but there was little memory left for the basic program and Bill Gates was angry that people were pirating his basic interpreter, so people wrote tiny basics that occupied minimal memory and could be shared.


#20

In theory, one of those xbox 360 keyboards that plug onto the controller should be simple to use, I think they’re just 3v serial.