GithubHelp home page GithubHelp logo

baremetalhack / antbasic Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 18.11 MB

antBASIC is a modernized version of Tiny BASIC, with the addition of I/O control instructions for the Raspberry Pi.

License: Creative Commons Zero v1.0 Universal

BASIC 30.00% Makefile 1.61% Roff 4.95% C 63.43%
gpio raspberry-pi raspberrypi tinybasic basic clanguage

antbasic's Introduction

antBASIC

๐ŸŽ A modern version of Tiny BASIC with enhancements for the Rasberry Pi

antBASIC

antBASIC is a modernized version of Tiny BASIC, with the addition of I/O manipulation instructions specifically designed for the Raspberry Pi. Although the language specification is minimal, beginners can learn the basics of programming, and a wide range of I/O controls through antBASIC.

๐Ÿ˜ Bare Metal Hacking (BMH) on the Breadboard

Breadboard Hacking

antBASIC is a product of the BMH project. BMH is an abbreviation for Bare Metal Hacking, which aims to teach the basics of system programming by controlling bare LEDs, LCDs, ICs, MCUs, etc., on a breadboard. I designed antBASIC as an introductory computer language for I/O control running on the Raspberry Pi. It is the 21st-century version of Tiny BASIC for beginners.

๐Ÿš€ BMH Style GPIO Card

BMH GPIO card

The Raspberry Pi has a 40-pin external header which holds 27 GPIO pins. Since the order of the original PINs (https://pinout.xyz/#) is irregular, it is easy to make mistakes when wiring. From an educational perspective, BMH has assigned new consecutive numbers (BMH1 to BMH14) to the GPIO pins. Although the number of pins is about half, 14, you can enjoy almost any I/O control!

BMH provides an easy-to-understand BMH GPIO card for beginners (bmh-gpio-cards.pdf in the DOCUMENTS ๐Ÿ“‚ directory).

๐Ÿ”ง Build and Install

You need to pre-install libreadline-dev, atp and ghostscript (includes ps2pdf) packages before make std or make max.

Build applications

$ make ๐Ÿ‘‰ antbasic and antcalib

Build applications and PDFs

$ make std ๐Ÿ‘‰ antbasic, antcalib, antbasic.pdf, and src.pdf

Build applications, PDFs, and test applications

$ make max ๐Ÿ‘‰ antbasic, antcalib, antbasic.pdf, src.pdf, test_token, test_bcode, test_prog, test_eval, test_assign

Install applications and man file

You require ROOT privilege

$ sudo make install ๐Ÿ‘‰ ๐Ÿ“‚ /usr/local/bin/antbasic, ๐Ÿ“‚ /usr/local/bin/antcalib, ๐Ÿ“‚ /usr/local/share/man/man1/antbasic.1

Clean applications

$ make clean ๐Ÿ‘‰ delete applications in the source tree

Dist-clean

You require ROOT privilege

$ sudo make dist-clean ๐Ÿ‘‰ purge all created files

๐Ÿ”  Line editing by GNU Readline

Default Makefile builds an antBASIC binary linked with the GNU Readline library. Readline makes editing commands and programs much more effortless. In addition, the filename completion is very powerful. For more information on editing and history functions, see rluserman.pdf in the DOCUMENTS ๐Ÿ“‚ directory.

โณ Adjust ยต-second wait

There are two types of wait functions, MSLEEP() and USLEEP(), in antBASIC. The former is a delay in seconds, while the latter is in micro-seconds. By default, both functions use the usleep system call internally, but a delay in the order of micro-seconds can lead to time variability.

If more precise control in micro-seconds is required, set the ANT_MICROWAIT environment variable. Then the USLEEP() function does not use the usleep system call but uses a simple loop for the number of times specified by ANT_MICROWAIT.

antcalib is a utility for estimating the number of loops required for a ฮผsec delay. The first argument specifies the number of loops, and the second argument specifies the number of loop calls.

$ ./antcalib 220 10000000
Loopcount = 220
Number of loops = 10000000

Elapsed time --> 10 sec 9327 usec
Mean time --> 1.000933 usec/loop

On a Raspberry pi 400, the loop count is around 220. Once the loop count is determined, add the export command to the ~/.bashrc.

export ANT_MICROWAIT=220

๐Ÿ“– man antbasic

man antbasic You can find the usage and grammar of antBASIC in the man file. Enter the command $ man antbasic in a terminal or open antbasic.pdf in the DOCUMENTS ๐Ÿ“‚ directory of the source tree.

๐ŸŽฐ Version

Initial release 1.0.0 released on Apr 26th, 2022 Revised version 1.0.3 released on Nov 27th, 2022

๐Ÿ“ Author

Doctor BMH ๐Ÿ‡ฏ๐Ÿ‡ต
Wataru Nishida, M.D.๐Ÿฉบ, Ph.D. ๐ŸŽ“

๐Ÿ‘€ See Also

๐ŸŒ BMH Home Page
๐Ÿ“‚ antBASIC GitHub Repository ๐Ÿ“บ BMH YouTube Channel ๐Ÿฃ DoctorBMH Twitter

antbasic's People

Contributors

baremetalhack avatar

Stargazers

 avatar

Watchers

 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.