Lua API Documentation


Display


Core

Function Description Parameters Returns Example Version
clear Clears the display. display.clear() Not specified expect => V1.0.0
display Updates the display with the newest buffer. display.display() Not specified expect => V1.0.0
loadingLogo Displays the loading logo. display.loadingLogo() Not specified expect => V1.0.0
statusBar Adds the status bar to the buffer. Int: withtime (optional) display.statusBar(1) >= V1.3.0 Stable

Text

Function Description Parameters Returns Example Version
printCenterText Prints centered text. String: text, Int: y display.printCenterText("Hello World!", 10) Not specified expect => V1.0.0
printText Displays text. String: text, Int: x, Int: y, Int: size display.printText("Hello World!", 10, 10, 1) Not specified expect => V1.0.0
displayScrolableText Displays scrollable text. Changes the passed in table. Pass the table in a loop of displaying it it will take care of timings. a table { y:int *the y pos of text* , text: String *text*, scrolled = 0 *do not change*, scrollspeed: int *reccomended is 200 ms* , scrolledon = 0 *do not change*, scrolldirection = false *do not change*, texttoprint = "" *do not change*, maxchars : int *maxchars 20 is all lenght*, x : int *if -1 its going to center*} local scrolabletext = { y = 28, text = "Hello World!", scrolled = 0, scrollspeed = 200, scrolledon = 0, scrolldirection = false, texttoprint = "", maxchars = 20, x = -1} while do display.displayScrolableText("Hello World!") system.delay(100) end Not specified expect => V1.0.0
showLargeText Displays a menu for showing text that wouldnt normally fit on screen. String: text display.showLargeText("Hello World!") Not specified expect => V1.0.0

Shapes

Function Description Parameters Returns Example Version
drawRectangle Draws a rectangle. Int: fromx, Int: tox, Int: fromy, Int: toy, Int: color, Int: filled display.drawRectangle(10, 20, 10, 20, 1, true) Not specified expect => V1.0.0
drawRoundRectangle Draws a rounded rectangle. Int: fromx, Int: tox, Int: fromy, Int: toy, Int: color, Int: filled, Int: round display.drawRoundRectangle(10, 20, 10, 20, 1, true, 5) Not specified expect => V1.0.0
drawCircle Draws a circle. Int: onx, Int: ony, Int: color, Int: filled, Int: radius display.drawCircle(20, 20, 1, true, 10) Not specified expect => V1.0.0
setPixel Sets a pixel. Int: x, Int: y, Int: color display.setPixel(10, 10, 1) Not specified expect => V1.0.0
drawLine Draws a line. Int: fromx, Int: fromy, Int: tox, Int: toy, Int: color display.drawLine(10, 10, 20, 20, 1) Not specified expect => V1.0.0
drawBitmap Draws an icon. Table: icon, Int: x, Int: y, Int: sizex, Int: sizey display.drawBitmap({0xFF,0xFA,0xFA,0xFA,0xFA,0xFF}, 10, 10, 8, 6) Not specified expect => V1.0.0

Color Control

Function Description Parameters Returns Example Version
getWhiteMode Gets the white mode. display.getWhiteMode() Not specified expect => V1.0.0
getWhiteColour Gets the white color. display.getWhiteColour() Not specified expect => V1.0.0
getBlackColour Gets the black color. display.getBlackColour() Not specified expect => V1.0.0
loadWhiteMode Loads the white mode. display.loadWhiteMode() Not specified expect => V1.0.0
autotextcolour Sets the auto text color. display.autotextcolour() >= V1.0.0 Stable
setBackground Sets the background color. display.setBackground() >= V1.0.0 Stable

User Input

Function Description Parameters Returns Example Version
yesOrNoMenu Displays a yes or no menu. String: prompt Bool: yes display.yesOrNoMenu("Prompt") >= V1.0.0 Stable
getString Gets a string from the user. String: prompt String: message display.getString("Enter your name:") >= V1.0.0 Stable
menu Shows the menu. Array: options chosen id (0-inf) -1 == no selection USE FOR EXIT !!! WARNING NOT LUA ID C++ ID IS LESS BY 1 display.menu(["Option 1","Option 2"]) >= V1.0.0 Stable

wifi


Core

Function Description Parameters Returns Example Version
require Asks user to connect to wifi proceeds if connected int: canProceed wifi.require() Not specified expect => V1.0.0

Connection

Function Description Parameters Returns Example Version
connect Connects to a wifi network. String: ssid, String: password int: did it succed wifi.connect("ssid","password") Not specified expect => V1.0.0
connectForgot Connects to a wifi network and doesnt save password and name. String: ssid, String: password int: did it succed wifi.connectForgot("ssid","password") Not specified expect => V1.0.0
displaySavedNetworks Displays all saved wifi networks. And prompts to connect to one int: did it succed wifi.displaySavedNetworks() Not specified expect => V1.0.0
ssid Gets the SSID of the currently connected network. (if the ssid is "" not connected) String: SSID wifi.ssid() Not specified expect => V1.0.0
rssi Gets the RSSI (signal strenght) of the currently connected network. Int: RSSI wifi.rssi() Not specified expect => V1.0.0
autoconnect Connects to the saved network with the highest signal strength. int: did it succed wifi.autoconnect() Not specified expect => V1.0.0

Scanning

Function Description Parameters Returns Example Version
wifiScanMenu Scans for wifi networks. wifi.wifiScanMenu() Not specified expect => V1.0.0
scan Scans for wifi networks and returns a table of SSID, RSSI, and encryption type. table: ssid, table: rssi, table: encryption local ssidTable, rssiTable, encryptionTable = wifi.scan() Not specified expect => V1.0.0

TCP (tls / ssl)

Function Description Parameters Returns Example Version
tcpCreateClient Creates a new TCP client. Bool: success wifi.tcpCreateClient() Not specified expect => V1.0.0
tcpConnect Establishes a secure TCP connection to a server. Int: client ID, String: host, Int: port Bool: success wifi.tcpConnect(client,"example.com", 80) Not specified expect => V1.0.0
tcpSend Sends data over a secure TCP connection. Int: client ID, String: data Bool: success wifi.tcpSend(client,"Hello, world!") Not specified expect => V1.0.0
tcpReceive Receives data over a secure TCP connection. Int: client ID String: data local data = wifi.tcpReceive(client) Not specified expect => V1.0.0
tcpReceiveChar Receives a single character over a secure TCP connection. Int: client ID String: character local character = wifi.tcpReceiveChar(client) Not specified expect => V1.0.0
tcpClose Closes a secure TCP connection. Int: client ID Bool: success wifi.tcpClose(client) Not specified expect => V1.0.0

TCP (Insecure)

Function Description Parameters Returns Example Version
tcpCreateClientUnsafe Creates a new TCP client. Bool: success local client = wifi.tcpCreateClientUnsafe() Not specified expect => V1.0.0
tcpConnectUnsafe Establishes a TCP connection to a server. Int: client ID, String: host, Int: port Bool: success wifi.tcpConnectUnsafe(client,"example.com", 80) Not specified expect => V1.0.0
tcpSendUnsafe Sends data over a TCP connection. Int: client ID, String: data Bool: success wifi.tcpSendUnsafe(client,"Hello, world!") Not specified expect => V1.0.0
tcpReceiveUnsafe Receives data over a secure TCP connection. Int: client ID String: data local data = wifi.tcpReceiveUnsafe(client) Not specified expect => V1.0.0
tcpReceiveCharUnsafe Receives a single character over a secure TCP connection. Int: client ID String: character local character = wifi.tcpReceiveCharUnsafe(client) Not specified expect => V1.0.0
tcpCloseUnsafe Closes a secure TCP connection. Int: client ID Bool: success wifi.tcpCloseUnsafe(client) Not specified expect => V1.0.0

TCP server (insecure)

Function Description Parameters Returns Example Version
tcpCreateServer Creates a new TCP server. Int: server ID local serverID = wifi.tcpCreateServer() >= V1.3.0 Stable
tcpStartServer Starts a TCP server. Int: server ID, Int: port Bool: success local success = wifi.tcpStartServer(serverID, 8080) >= V1.3.0 Stable
tcpAcceptClient Accepts a client connection on a TCP server. Int: server ID Int: client ID local clientID = wifi.tcpAcceptClient(serverID) >= V1.3.0 Stable
tcpSendToClient Sends data to a client connected to a TCP server. Int: client ID, String: data Bool: success local success = wifi.tcpSendToClient(clientID, "Hello, Client!") >= V1.3.0 Stable
tcpReceiveFromClient Receives data from a client connected to a TCP server. Int: client ID, Int: timeout (optional) String: data local data = wifi.tcpReceiveFromClient(clientID, 5000) >= V1.3.0 Stable
tcpReceiveCharFromClient Receives a single character from a client connected to a TCP server. Int: client ID, Int: timeout (optional) String: character local char = wifi.tcpReceiveCharFromClient(clientID, 5000) >= V1.3.0 Stable
tcpReceiveBufferFromClient Receives a buffer of data from a client connected to a TCP server. Int: client ID, Int: timeout (optional), Int: buffer size (optional) String: data local buffer = wifi.tcpReceiveBufferFromClient(clientID, 5000, 1024) >= V1.3.0 Stable
tcpCloseClient Closes a client connection on a TCP server. Int: client ID Bool: success local success = wifi.tcpCloseClient(clientID) >= V1.3.0 Stable
tcpClientConnected Checks if a client is connected to a TCP server. Int: client ID Bool: connected local isConnected = wifi.tcpClientConnected(clientID) >= V1.3.0 Stable
tcpClientPort Gets the port number of a client connected to a TCP server. Int: client ID Int: port local port = wifi.tcpClientPort(clientID) >= V1.3.0 Stable
tcpStopServer Stops a TCP server. Int: server ID Bool: success local success = wifi.tcpStopServer(serverID) >= V1.3.0 Stable
tcpGetClientIP Gets the IP address of a client connected to a TCP server. Int: client ID String: IP address local clientIP = wifi.tcpGetClientIP(clientID) >= V1.3.0 Stable

Access Point Mode

Function Description Parameters Returns Example Version
apStart Starts the access point mode. String: ssid, String: password Bool: success wifi.apStart("MyAP", "password") >= V1.1.0 Stable
apStop Stops the access point mode. Bool: success wifi.apStop() >= V1.1.0 Stable
apNumConnected Returns the number of connected clients. Int: number of connected clients local num = wifi.apNumConnected() >= V1.1.0 Stable
apSSID Returns the current SSID of the access point. String: SSID local ssid = wifi.apSSID() >= V1.1.0 Stable

Notes


ESP-NOW


Core

Function Description Parameters Returns Example Version
require Asks user to enable espnow proceeds if enabled int: canProceed espnow.require() Not specified expect => V1.0.0
addPeer Add a peer to the list of peers String: peers mac int: did it succed espnow.addPeer("peer") Not specified expect => V1.0.0
myMac Returns the Devices MAC address String: mac espnow.myMac() Not specified expect => V1.0.0
getMac Prompts the user to enter a mac adress. SString: prompt String: mac espnow.getMac("Enter mac:") Not specified expect => V1.0.0

Atachment

Function Description Parameters Returns Example Version
CallbackForATT Enables the callback (adding to queue) int: did it succed espnow.CallbackForATT() Not specified expect => V1.0.0
getQueuedATT Gets the newest message in the queue String: macaddress , String: attachment (name of it), String: message, String: type (like you can use it like: on off change) espnow.getQueuedATT() Not specified expect => V1.0.0
sendATT Sends an attachment to a peer String: peers mac, String: message , String: atachment (name of it), String: type (on off change etc.) espnow.sendATT("mac","message","attachment *Car Remote etc.*","type *on off change etc.*") Not specified expect => V1.0.0

Device to device

Function Description Parameters Returns Example Version
CallbackForDTD Enables the callback (adding to queue) int: did it succed espnow.CallbackForDTD() Not specified expect => V1.0.0
sendDTD Sends a message to a peer String: peers mac, String: message, String type espnow.sendDTD("mac","message","type") Not specified expect => V1.0.0
getQueuedDTD Gets the newest message in the queue String: macaddress ,String:deviceName (senders device name), String: message, String: type espnow.getQueuedDTD() Not specified expect => V1.0.0

ESP-NOW Socket

Function Description Parameters Returns Example Version
socketCreate Creates a new ESP-NOW socket connection. String: macStr Bool: success espnow.socketCreate("xx:xx:xx:xx:xx:xx") >= V1.3.0 Stable
socketDestroy Destroys an existing ESP-NOW socket connection. String: macStr Bool: success espnow.socketDestroy("xx:xx:xx:xx:xx:xx") >= V1.3.0 Stable
socketWrite Writes data to an ESP-NOW socket connection. String: macStr, String: message Bool: success espnow.socketWrite("xx:xx:xx:xx:xx:xx", "Hello, world!") >= V1.3.0 Stable
socketReadLine Reads a line of data from an ESP-NOW socket connection. String: macStr String: line espnow.socketReadLine("xx:xx:xx:xx:xx:xx") >= V1.3.0 Stable
socketReadUntil Reads data from an ESP-NOW socket connection until a specified character is encountered. String: macStr, Char: chartoend String: data espnow.socketReadUntil("xx:xx:xx:xx:xx:xx", "\n") >= V1.3.0 Stable
socketRead Reads data from an ESP-NOW socket connection. String: macStr String: data espnow.socketRead("xx:xx:xx:xx:xx:xx") >= V1.3.0 Stable
socketAvailable Checks if there is available data to read from an ESP-NOW socket connection. String: macStr Int: available espnow.socketAvailable("xx:xx:xx:xx:xx:xx") >= V1.3.0 Stable
socketCount Gets the number of active ESP-NOW socket connections. Int: count espnow.socketCount() >= V1.3.0 Stable
socketList Gets a list of active ESP-NOW socket connections. Table: connections espnow.socketList() >= V1.3.0 Stable

Notes


HTTP


Requests

Function Description Parameters Returns Example Version
get Sends a GET request. String: url, Int: expectedCode String: the response ("Error" if failed) http.get("url", 200) Not specified expect => V1.0.0
post Sends a POST request. String: url, Int: expectedCode, String: data String: tzhe response ("Error" if failed) http.post("url", 200, "data") Not specified expect => V1.0.0
unsafeGet Sends an insecure GET request. String: url, Int: expectedCode String: the response ("Error" if failed) http.unsafeGet("url", 200) Not specified expect => V1.0.0
unsafePost Sends an insecure POST request. String: url, Int: expectedCode, String: data String: the response ("Error" if failed) http.unsafePost("url", 200, "data") Not specified expect => V1.0.0

Notification


Core

Function Description Parameters Returns Example Version
add Adds a notification. String: title, String: message, Int: displayTime (ms) notification.add("title", "message", 1000) Not specified expect => V1.0.0

System


Time

Function Description Parameters Returns Example Version
time Gets the system time. bool: succeded, int: year, int: month, int: dayoftheweek 0-7 , int: month day, int: year day, int: hour, int: minute, int: second local succeded, year, month, dayoftheweek, dayofthemonth, dayoftheyear, hour, minute, second = system.time() Not specified expect => V1.0.0
delay Delays the system. Int: delayTime system.delay(1000) Not specified expect => V1.0.0

Storage

Function Description Parameters Returns Example Version
saveData Saves data to the storage. String: value system.saveData("value") Not specified expect => V1.0.0
loadData Loads data from the storage. String: value system.loadData() Not specified expect => V1.0.0

Math

Function Description Parameters Returns Example Version
random Generates a random number. Int: min, Int: max Int: random number system.random(1, 10) Not specified expect => V1.0.0

Operating system

Function Description Parameters Returns Example Version
version Returns the version of the operating system. String: version system.version() Not specified expect => V1.0.0
os_name Returns the name of the operating system. String: os name system.os_name() Not specified expect => V1.0.0
distro Returns the name of the system distribution (Beta , Stable). String: distro name system.distro() Not specified expect => V1.0.0

Input


Buttons

Function Description Parameters Returns Example Version
aBtn Checks if button A is held. bool: is held input.aBtn() Not specified expect => V1.0.0
bBtn Checks if button B is held. bool input.bBtn() Not specified expect => V1.0.0
cBtn Checks if button C is held. bool: is held input.cBtn() Not specified expect => V1.0.0
dBtn Checks if button D is held. bool: is held input.dBtn() Not specified expect => V1.0.0

Miscellaneous

Function Description Parameters Returns Example Version
stopPressing Waits till the user stops pressing the buttons input.stopPressing() Not specified expect => V1.0.0

Logging


Log

Function Description Parameters Returns Example Version
info Sends [INFO]:appname:<text> to the console. String: text log.info("Text") Not specified expect => V1.0.0
debug Sends [DEBUG]:appname:<text> to the console if debug enabled. String: text log.debug("Text") Not specified expect => V1.0.0
error Sends [ERROR]:appname:<text> to the console. String: text log.error("Text") Not specified expect => V1.0.0
warning Sends [WARNING]:appname:<text> to the console. String: text log.warning("Text") Not specified expect => V1.0.0
warn Sends [WARNING]:appname:<text> to the console. String: text log.warn("Text") Not specified expect => V1.0.0
critical Sends [CRITICAL]:appname:<text> to the console. String: text log.critical("Text") Not specified expect => V1.0.0

JSON


Core

Function Description Parameters Returns Example Version
stringify stringifys a table to a JSON string. Table: table String: JSON string json.stringify({"key": "value"}) Not specified expect => V1.0.0
parse parses a JSON string to a table. String: JSON string Table: table json.parse("{\"key\": \"value\"}") Not specified expect => V1.0.0

Cryptography


Symmetric Encryption

Function Description Parameters Returns Example Version
aes Encrypts/decrypts data using AES in ECB or CBC mode Int: mode (0=ECB, 1=CBC), String: key, String: data String: encrypted/decrypted data local encrypted = algo.aes(0, key, 'Secret message') >= V1.2.0 Stable
aesKeygen Generates a random AES key of specified length Int: keySize (128, 192, or 256 bits) String: generated key local key = algo.aesKeygen(256) >= V1.2.0 Stable

Hashing

Function Description Parameters Returns Example Version
sha256 Computes SHA-256 hash of input data String: data String: 64-character hex hash local hash = algo.sha256('data') >= V1.2.0 Stable
sha512 Computes SHA-512 hash of input data String: data String: 128-character hex hash local hash = algo.sha512('data') >= V1.2.0 Stable
sha1 Computes SHA-1 hash of input data String: data String: 40-character hex hash local hash = algo.sha1('data') >= V1.2.0 Stable

Asymmetric Encryption

Function Description Parameters Returns Example Version
rsaKeygen Generates RSA public/private key pair Int: keySize (2048 or higher) String: publicKeyPEM, String: privateKeyPEM local pub, priv = algo.rsaKeygen(2048) >= V1.2.0 Stable
rsaEncrypt Encrypts data using RSA public key String: publicKeyPEM, String: message String: encrypted data local encrypted = algo.rsaEncrypt(pubKey, 'secret') >= V1.2.0 Stable
rsaDecrypt Decrypts data using RSA private key String: privateKeyPEM, String: encryptedData String: decrypted message local decrypted = algo.rsaDecrypt(privKey, encrypted) >= V1.2.0 Stable
rsaSign Signs SHA256 hash using RSA private key String: privateKeyPEM, String: hash String: signature local signature = algo.rsaSign(privKey, hash) >= V1.3.0 Stable
rsaVerify Verifies SHA256 hash signature using RSA public key String: publicKeyPEM, String: hash (SHA256), String: signature Bool: success local success = algo.rsaVerify(pubKey, hash, signature) >= V1.3.0 Stable

Packetizing

Function Description Parameters Returns Example Version
packetize Takes a table and a packetsize and outputs a packet not nested not key pair Int: packetsize,Table: data String: packet local packet = algo.packetize(10, {"value1", "value2"}) >= V1.3.0 Stable
depacketize Takes a packet and outputs a table String: packet Table: data local data = algo.depacketize(packet) >= V1.3.0 Stable

Functions


Function Description Parameters Returns Example
mainmenu Gets called on the main menu if the user enables the startup option in the app manager. function mainmenu() end
widget Gets called repeatedly when a widget is opened. function widget() end
main Gets called if the user runs the app. function main() end