Giter Site home page Giter Site logo

alankrantas / tinybasicplus-mega-vga-keyboard Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 53 KB

Tiny BASIC 8-bit Home Computer on Arduino MEGA 2560 and Uno with VGA and PS/2 Support

License: MIT License

C++ 100.00%
8-bit-computer arduino arduino-mega-2560 arduino-uno basic home-computer ps2-keyboard tinybasic vga

tinybasicplus-mega-vga-keyboard's Introduction

Tiny BASIC 8-bit Home Computer on Arduino with VGA and PS/2 Support

IMG_3193

My version of remaking Rob Cai's Arduino Basic PC With VGA Output, which is to use two Arduino AVR boards to create a 8-bit home computer running the TinyBasic runtime with VGA video output and PS/2 keyboard input.

Unlike Rob uses one Nano as the "VGA chip" and another as the TinyBasic runtime/keyboard controller, I run the VGA driver together with the TinyBasic on a Mega 2560 and use a Uno as the "keyboard adapter". I also tried to write a cleaner code and have the VGA driver to print characters according to their actual width (Rob set all of them with the same size of 5 VGA pixels).

The libraries I used includes:

Hardware

  • An Arduino Mega 2560 (script: TinyBasicPlusMegaVGA)
  • An Arduino Uno or Arduino Nano (script: TinyBasicPlusUnoKeyboard)
  • VGA and PS/2 connector breakout (optional)

There's many ways to connect VGA and PS/2 (see the driver repos for details) but personally I use a Waveshare VGA PS2 Board which already have resistors on pins.

VGA-PS2-Board_l

Wiring

Mega 2560

Pin VGA D-SUB 15 Resistor
GND GND
9 H-SYNC 680 Ω
11 V-SYNC 680 Ω
30 GREEN 470 Ω
31 BLUE 470 Ω

vga

Note: The VGAX driver only uses two colors (you can change them to the combination you like, even connecting multiple colors to one pin).

Uno

Pin PS/2 mini-DIN
5V VCC
GND GND
2 (data) +DATA
3 (irq) +CLK

ps2-pinout-by-rones

Between Mega and Uno

Pin Mega Uno
Serial port 0 (Rx) 1 (Tx)
GNE GND GND

I also power the Uno directly using Mega's 5V pin (while the Mega can be powered by the USB cable) via the Waveshare VGA PS2 Board itself. So actually both the Uno and the PS/2 keyboard are powered from the Mega.

Explanation for the Two-Board Combination

It is simply not possible to run both VGAX and PS/2 drivers together on the same board without rewritting them, for both rely on the same interrupt timers despite not using the same pins. On AVR boards timer0 by default is used by built-in functions like delay and millis, and VGAX uses timer0, timer1 and timer2. While VGAX does provide alternative functions like vga.millis() to avoid issues, and the MEGA does have extra timers, the PS/2 drivers (Rob uses PS2Keyboard which is the predecessor of PS2KeyAdvanced) still calls the original millis and thus break timings for both drivers.

VGA Pixel Offset

The MEGA script has X and Y offset settings you can adjust. As the author of the VGAX driver stated, the "screen" may not align properly to the VGA monitor. Also the only way to change the "resolution" is to modify the value in the VGAX header file.

TinyBasic Memory Usage

By default the TinyBasic script use up all available memories on the board. I change it to use 6K so a little less than 5K would be available for TinyBasic code and variables.

I haven't test if other functionalities (buzzers, SD card, etc) will work. Later I'll try to remove checks for ESP boards since they are not necessary on MEGA.

Supported Input Keys

I have the Uno's keyboard script and the VGAX printing function to only accept the following characters:

  • Enter (ASCII code 13)
  • Space (ASCII code 32)
  • Characters of ASCII code 33~126

The TinyBasic script did support backspace, although it does not appear to work properly. Rob also implemented to use ESC to clear the screen, but I'll have to figure out how to reset the TinyBasic prompt at the same time.

VGAX Colors

The VGAX, in order to save memory on Uno, only uses two colors so there are four colors available:

Color value Binary value Effect
0 00 Black
1 01 Color 1 (pin 30)
2 10 Color 2 (pin 31)
3 11 Both colors

vga.clear and vga.printPROGMEM alike use these color values despite they are in byte type.

The VGAXUA displays only one color but use up significantly more memory due to the resolution is set higher.

tinybasicplus-mega-vga-keyboard's People

Contributors

alankrantas avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.