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(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()->bool
Returns true if the card is connected to the Internet.
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(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()->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(sec:long)
Turns off the Oxocard and restarts it after x seconds.
turnOff()
Turns off the oxocard.
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(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(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()
Restarts the card.
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