Oxoscript turns into NanoPy - more infos

System functions

setLanguage

  setLanguage(byte lang)

Sets the system language of the device.

Available languages:

C_LANGUAGE_EN
C_LANGUAGE_DE
C_LANGUAGE_FR

getLanguage

  getLanguage()->byte

Returns the currently set system language.

Available languages:

C_LANGUAGE_EN
C_LANGUAGE_DE
C_LANGUAGE_FR

getHardwareType

  getHardwareType()->byte

Returns the type of the currently used oxocard.

C_HW_GALAXY = 0
C_HW_ARTWORK = 1
C_HW_SCIENCE = 2
C_HW_SCIENCE_PLUS = 3
C_HW_CONNECT = 4

textInput

  textInput(title:byte[], text:byte[])->byte[120]

Opens a text input field and returns the entered text as soon as the OK icon is selected and confirmed.

str = textInput("Test", "123")
print(str)

isConnected

  isConnected()->bool

Returns true if the card is connected to the Internet.

runScript

  runScript(path:byte[])

Starts a previously downloaded script or a script saved as a file.

The current script is terminated and replaced with the new script.

If the script does not exist, a “file not found” runtime error is issued.

Downloaded scripts are placed in the “user_scripts” folder. The file name corresponds to the name in the editor, e.g. “My downloaded script” plus “.npy” file ending.

runScript("user_scripts/My downloaded script.npy")

File example:

if fileExists("hello.npy"):
    deleteFile("hello.npy")

open(C_WRITE, "hello.npy")
code = "drawText(35, 10, \"Hello World!\")\nupdate()"
i = 0
ch = code[i]
while ch != 0:
    writeByte(ch)
    i++
    ch = code[i]
close()

runScript("hello.npy")

backlight

  backlight(value:float)

Switches the background light of the TFT display on (value=1) or off (value=0).

With values between 0 and 1 (e.g. 0.1) the TFT display can also be dimmed.

Note: Since the human eye does not perceive light linearly (but logarithmically), you will only notice a striking difference at smaller values.

background(0, 255, 0)
drawText(60, 80, "Test123")
update()
for i in 20:
    backlight(1.0 - 0.05*i)
    delay(500)

ipAddress

  ipAddress()->byte[16]

Returns the current IP address as a string (byte array).
If the card is not connected to the Internet, “0.0.0.0” is returned.

ipAddress() # => "192.168.42.164"

sleep

  sleep(sec:long)

Turns off the Oxocard and restarts it after x seconds.

turnOff

  turnOff()

Turns off the oxocard.

setAutostart

  setAutostart()

If the autostart function has been enabled, the Oxocard will switch directly to the startup program when it is restarted (after connecting to the Internet).

setAutostart(true)
setAutostart(false)

print

  print(str:byte[])

Sends the defined string parameter to the terminal in the NanoPy editor.

print("Hello world!")

If a number or a variable is passed to the print() function, it is automatically converted to a string (respectively a byte[]):

print(123) # "123"
a = 1.23
print(a) # "1.23"

It is even possible to mix texts and numbers or variables:

v = vector(x=5,y=10)
print("x = " + v.x + "; y = " + v.y) # "x = 5.0; y = 10.0"

setPrecision

  setPrecision(val:byte)

Formats the decimal places when outputting float values:

f = 1.23931
setPrecision(2)
print(f) # "1.24"
setPrecision(4)
print(f) # "1.2393"

restart

  restart()

Restarts the card.

returnToMenu

  returnToMenu()->bool

With this function you jump back to the menu.
The return value indicates whether the user has really left the program.

    if getButton():
        if returnToMenu():
            return