Application Programming Interface (API)

All computer systems have something called API (Application Programming Interface) which defines how to “interface” to the device. For example, Windows operating system has an API that coders use to create Windows applications. The API for the BrainPad is lean and simple, yet powerful and flexible.

API Methods

The control methods are handy and easy to remember: Print, Wait(), Out(), In() and OutIn().

Print

Outputs whatever it is given to the screen. On the BrainPad Pulse, the output shows on the screen like a text window.

Tip: Print is a special statement, and it does not require adding ( ) symbols. Print(5) and Print 5 are exactly the same.

Print Hello
Print 5
Print ("Hello");
Print (5);
Print Hello
Print 5

 

In the case of BrainPad Tick, the text will scroll across the LEDs. If the text being printed is a single character, then that one character will just show on the LEDs.

Print 5
Print (5);
Print 5

Print BrainPad
Print ("BrainPad");
Print BrainPad

Wait()

This one should explain itself. Wait() forces the BrainPad to “wait” for some time. The following code will Print 1 and then “wait” one second then Print 2, then “wait” another second and finally Print 3.

Print 1
Wait(1)
Print 2
Wait(1)
Print 3
Print ("1");
Wait (1);
Print ("2");
Wait (1);
Print ("3");
Print 1
Wait 1
Print 2
Wait 1
Print 3

In() & Out()

All physical elements surrounding the brain (the processor) are controlled using In() or Out() methods. They are covered in the In & Out elements lesson.

OutIn()

This is an advance use method that is very similar to In() and Out(). It is detailed in the OutIn() lesson.

Drawing() Methods

There are several advanced drawing methods to give you better control over the display or LED-matrix. They are covered in the Drawing Methods lesson.


BrainStorm

As a human communicating with another human, can we think of a standard API for communication? How do we handle trust and security? Think of layers of control in a financial institution or military. How do we insure commands flow nicely.

What about you as a person? What senses feed info into your brain? And what actions are you taking? Can you think of priority commands that take over non-priority? What happened when you are very hungry and you hold a piece of very hot chicken? Does your brain continue to command your muscles to eat that piece of chicken or will it will stop you? What about controlling your heartrate voluntarily? Or holding your breath?