Kaluma
Search…
Global
The objects are available in a global scope. The objects in the Global are not need to have a require function call before using it.

Object: global

require(module_name)

  • module_name <string>Module Name which would be used in the script.
  • Returns: <any> Return exports object of the loaded module.
1
var graphics = require('graphics') // Load a builtin module
Copied!
  • ...data <any>Data which is shown in the console.
Print out data to the console. The main difference from console.log() is that it do not print a carriage return and a new line character (\r\n) in the end.
1
// print out "100 string value true 1,2,3"
2
var number = 100;
3
var result = true;
4
var arr = [1, 2, 3];
5
print (number, "string value", result, arr);
Copied!

seed(seed)

  • seed <number> A seed number to initialize.
Initializes the pseudo-random number generator. When you use Math.random(), it generate always the same random sequence. If you want to generate different random number sequence, you need to provide different seed number.
1
// Seeding by millisecond time
2
seed(millis());
3
4
// Seeding by analog input
5
seed(analogRead(26) * 10000); // GPIO26 = ADC0
Copied!

btoa(data)

  • data <Uint8Array|string> Binary data to encode.
  • Returns: <string> Base64 encoded string.
Returns a base64 encoded string from binary data.

atob(encodedData)

  • encodedData <string> Base64 encoded string data.
  • Returns: <Uint8Array> Decoded binary data.
Returns a decoded binary data from a base64 encoded string.

encodeURIComponent

  • data <string> Data to encode.
  • Returns: <string> Encoded data.
Encodes URI (Uniform Resource Identifier) component using percent-encoding. This function escapes all characters excepts A-Z a-z 0-9 - _ . ! ~ * ' ( ).

decodeURIComponent

  • data <string> Data to decode.
  • Returns: <string> Decoded data.
Decodes URI (Uniform Resource Identifier) component using percent-encoding.

LOW

  • <number> = 0

HIGH

  • <number> = 1

INPUT

  • <number> = 0

OUTPUT

  • <number> = 1

INPUT_PULLUP

  • <number> = 2

INPUT_PULLDOWN

  • <number> = 3

LOW_LEVEL

  • <number> = 1

HIGH_LEVEL

  • <number> = 2

FALLING

  • <number> = 4

RISING

  • <number> = 8

CHANGE

  • <number> = 12

Digital I/O Functions

All the functions in the Digital I/O are in the global scope.

Analog I/O Functions

All the functions in the Analog I/O are in the global scope.

Timers Functions

All the functions in the Timers are in the global scope.

Interrupt Functions

All the functions in the Interrupts are in the global scope.

console

  • <Object>
Console object is a global object.

process

  • <Object>
process object is a global object.

board object

  • <Object>
board object is a global object.

storage object

  • <Object>
storage object is a global.

Class: TextEncoder

new TextEncoder([label])

  • label <string> Encoding type. Default: 'utf-8'. Currently supported encoding types are 'ascii' and 'utf-8'.

textEncoder.encode(input)

  • input <string>
  • Returns: <Uint8Array>
Encodes the input string and returns the encoded buffer.
1
var encoder = new TextEncoder();
2
var buf = encoder.encode('abc'); // [97, 98, 99]
Copied!

textEncoder.encoding

  • <string>
Encoding type.

Class: TextDecoder

new TextDecoder([label])

  • label <string> Encoding type. Default: 'utf-8'. Currently supported encoding types are 'ascii' and 'utf-8'.

textDecoder.decode(input)

  • input <Uint8Array>
  • Returns: <string>
Decodes the input buffer and returns the decoded string.

textDecoder.encoding

  • <string>
Encoding type.

Class: SystemError

  • Extends: {Error}
Represents internal system error.
Last modified 2mo ago