Lua API Documentation

Display

Core

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

Text

Function Version Description Parameters Returns Example
display.printCenterText Not specified expect => V1.0.0 Prints centered text. String: text, Int: y None display.printCenterText("Hello World!", 10)
display.printText Not specified expect => V1.0.0 Displays text. String: text, Int: x, Int: y, Int: size None display.printText("Hello World!", 10, 10, 1)
display.displayScrolableText Not specified expect => V1.0.0 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*} None 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
display.showLargeText Not specified expect => V1.0.0 Displays a menu for showing text that wouldnt normally fit on screen. String: text None display.showLargeText("Hello World!")

Shapes

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

Color Control

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

User Input

Function Version Description Parameters Returns Example
display.yesOrNoMenu >= V1.0.0 Stable Displays a yes or no menu. String: prompt Bool: yes display.yesOrNoMenu("Prompt")
display.getString >= V1.0.0 Stable Gets a string from the user. String: prompt String: message display.getString("Enter your name:")
display.sentenceBuilder >= V1.3.0 Stable Shows the sentence builder. None String: message display.sentenceBuilder()
display.sentenceBuilderUpdate >= V1.3.0 Stable Updates the sentence builder with a new url. If the url is 'Default' it will use the default sentences. String: url Bool: success display.sentenceBuilderUpdate("https://example.com/sentences.json")

Item selection

Function Version Description Parameters Returns Example
display.menu >= V1.0.0 Stable 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"])
display.menu2 >= V1.3.0 Stable Shows the menu. (its reccomended to keep the word size smaller than 9 letters menu may break and less than 3 words) Array: options chosen id (0-inf) -1 == no selection USE FOR EXIT !!! WARNING NOT LUA ID C++ ID IS LESS BY 1 display.menu2(["Option 1","Option 2"])
display.menu3 >= V1.3.0 Stable Shows the menu. (slightly altered menu2) (its reccomended to keep the word size smaller than 9 letters menu may break and less than 3 words) Array: options chosen id (0-inf) -1 == no selection USE FOR EXIT !!! WARNING NOT LUA ID C++ ID IS LESS BY 1 display.menu3(["Option 1","Option 2"])
display.defaultMenu >= V1.3.0 Stable Shows the default menu for selecting items. Array: options chosen id (0-inf) -1 == no selection USE FOR EXIT !!! WARNING NOT LUA ID C++ ID IS LESS BY 1 display.defaultMenu(["Option 1","Option 2"])

Notes

Note Description Types
Colors The colors used in the display module are defined as follows:
  • 1: White color
  • 0: Black color
Sentence Builder syntax The sentence builder uses a specific syntax for its sentences. Each sentence can contain words, directories, and loops. The syntax is as follows:
  • General Sentence Builder Example: {"version": "1.0", "fix": "0", "sentences": [{"type": "word", "text": "Hi", "content": "Hi"}, {"type": "dir", "text": "Looping", "loops": true, "content": [{"type": "dir", "text": "Not looping", "content": [{"type": "word", "text": "Hello", "content": "Hello"}, {"type": "word", "text": "World", "content": "World"}]}]}]}
  • word: A word type sentence. It contains a text and content. {"text":"Name on menu","content":"actually output "}
  • dir: A directory type sentence. It can contain other sentences and can be looping. {"text":"Name on menu","loops":true,"content":[{"text":"Name on sub menu","content":[{"text":"Name on sub sub menu","content":"actually output "}]}]}
  • loops: A boolean value that indicates if the directory is looping or not is optional.

wifi

Core

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

Connection

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

Scanning

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

TCP (tls / ssl)

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

TCP (Insecure)

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

TCP server (insecure)

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

Access Point Mode

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

Websockets

Function Version Description Parameters Returns Example
wifi.wsStart >= V1.3.0 Stable Connects to a websocket (supports ws and wss) String: url,Int: port, String: path Int: id,String: Error local id, err = wifi.wsStart(ws_url, ws_port, ws_path)
wifi.wsSend >= V1.3.0 Stable Sends a message through an active websocket connection. Int: id, String: message Bool: success local sent = wifi.wsSend(id, "hi")
wifi.wsReceive >= V1.3.0 Stable Receives a message from an active websocket connection. Returns an empty string if no message is available. Int: id String: message local msg = wifi.wsReceive(id)
wifi.wsConnected >= V1.3.0 Stable Is connected. Int: id Bool: connected local connected = wifi.wsClose(id)
wifi.wsClose >= V1.3.0 Stable Closes an active websocket connection identified by id. Int: id Bool: success local closed = wifi.wsClose(id)

Notes

Note Description Types
Encryption Types The encryption type returned by the `scan` function can be one of the following:
  • OPEN: No encryption
  • WEP: Wired Equivalent Privacy
  • WPA_PSK: Wi-Fi Protected Access with Pre-Shared Key
  • WPA2_PSK: Wi-Fi Protected Access 2 with Pre-Shared Key
  • WPA_WPA2_PSK: Wi-Fi Protected Access and Wi-Fi Protected Access 2 with Pre-Shared Key
  • WPA3_PSK: Wi-Fi Protected Access 3 with Pre-Shared Key
  • WPA2_WPA3_PSK: Wi-Fi Protected Access 2 and Wi-Fi Protected Access 3 with Pre-Shared Key
  • WAPI_PSK: Wi-Fi Protected Access with Pre-Shared Key (China)
  • UNKNOWN: Unknown encryption type

ESP-NOW

Core

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

Atachment

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

Device to device

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

ESP-NOW Socket

Function Version Description Parameters Returns Example
espnow.socketCreate >= V1.3.0 Stable Creates a new ESP-NOW socket connection. String: macStr Bool: success espnow.socketCreate("xx:xx:xx:xx:xx:xx")
espnow.socketDestroy >= V1.3.0 Stable Destroys an existing ESP-NOW socket connection. String: macStr Bool: success espnow.socketDestroy("xx:xx:xx:xx:xx:xx")
espnow.socketWrite >= V1.3.0 Stable Writes data to an ESP-NOW socket connection. String: macStr, String: message Bool: success espnow.socketWrite("xx:xx:xx:xx:xx:xx", "Hello, world!")
espnow.socketReadLine >= V1.3.0 Stable Reads a line of data from an ESP-NOW socket connection. String: macStr String: line espnow.socketReadLine("xx:xx:xx:xx:xx:xx")
espnow.socketReadUntil >= V1.3.0 Stable 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")
espnow.socketRead >= V1.3.0 Stable Reads data from an ESP-NOW socket connection. String: macStr String: data espnow.socketRead("xx:xx:xx:xx:xx:xx")
espnow.socketAvailable >= V1.3.0 Stable 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")
espnow.socketCount >= V1.3.0 Stable Gets the number of active ESP-NOW socket connections. None Int: count espnow.socketCount()
espnow.socketList >= V1.3.0 Stable Gets a list of active ESP-NOW socket connections. None Table: connections espnow.socketList()

Simple

Function Version Description Parameters Returns Example
espnow.simpleCallback >= V1.3.0 Stable Enables the callback (adding to queue) None int: did it succed espnow.simpleCallback()
espnow.simpleSend >= V1.3.0 Stable Sends a message to a peer (first add the peer with addPeer, max message size 250) String: peers mac, String: message None espnow.simpleSend("mac","message")
espnow.simpleReceive >= V1.3.0 Stable Gets the newest message in the queue with a timestamp when it was received (FIRST RUN simpleCallback) None String: message,String: macaddress , Int: year, Int: month , Int: day , Int:hour , Int: minute, Int: second espnow.simpleReceive()

Notes

Note Description Types
ESP-NOW Data structures ESP-NOW uses the following data structures to store data:
  • Device to device: struct espnowdevicetodevice { uint8_t senderMac[6]; char deviceName[32]; char message[64]; char type[20]; };
  • Attachment: struct espnowattachment { uint8_t senderMac[6]; char message[70]; char attachment[20]; char type[20]; };
  • Simple: Its so simple that it just sends the data as char in the packet
  • Builtin chat message struct: typedef struct struct_message { char deviceName[32]; char message[64]; } struct_message;

HTTP

Requests

Function Version Description Parameters Returns Example
http.get Not specified expect => V1.0.0 Sends a GET request. String: url, Int: expectedCode String: the response ("Error" if failed) http.get("url", 200)
http.post Not specified expect => V1.0.0 Sends a POST request. String: url, Int: expectedCode, String: data String: tzhe response ("Error" if failed) http.post("url", 200, "data")
http.unsafeGet Not specified expect => V1.0.0 Sends an insecure GET request. String: url, Int: expectedCode String: the response ("Error" if failed) http.unsafeGet("url", 200)
http.unsafePost Not specified expect => V1.0.0 Sends an insecure POST request. String: url, Int: expectedCode, String: data String: the response ("Error" if failed) http.unsafePost("url", 200, "data")
http.request >= V1.3.0 Stable Sends an HTTP request with support for all methods, headers, and optional body. Supports both HTTP and HTTPS. Table: requestData — A table containing method, url, expected, headers, and body. Table: response — Contains `ok`, `status`, and `raw` fields. JSON parsing must be done manually using `json.parse(response.raw)` if needed. http.request({ method = "POST", url = "https://example.com", expected = 200, headers = { ["Content-Type"] = "application/json" }, body = '{"hello":"world"}' })

Notification

Core

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

System

Time

Function Version Description Parameters Returns Example
system.time Not specified expect => V1.0.0 Gets the system time. None 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()
system.delay Not specified expect => V1.0.0 Delays the system. Int: delayTime None system.delay(1000)
system.millis Not specified expect => V1.0.0 Gets the number of milliseconds since the system started. None Int: milliseconds local ms = system.millis()

Storage

Function Version Description Parameters Returns Example
system.saveData Not specified expect => V1.0.0 Saves data to the storage. String: value None system.saveData("value")
system.loadData Not specified expect => V1.0.0 Loads data from the storage. None String: value system.loadData()
system.dataPublicRamSave >= V1.3.0 Stable Saves data to the public ram. String: key, String: value None system.dataPublicRamSave("key", "value")
system.dataPublicRamLoad >= V1.3.0 Stable Loads data from the public ram. String: key String: value system.dataPublicRamLoad("key")
system.dataPublicRamDelete >= V1.3.0 Stable Deletes data from the public ram. String: key None system.dataPublicRamDelete("key")
system.dataPublicRamClear >= V1.3.0 Stable Clears all data from the public ram. None None system.dataPublicRamClear()
system.getFreeRam >= V1.3.0 Stable Returns the amount of free ram. None Int: free ram local freeRam = system.getFreeRam()
system.getTotalRam >= V1.3.0 Stable Returns the total amount of ram. None Int: total ram local totalRam = system.getTotalRam()
system.getUsedFlash >= V1.3.0 Stable Returns the amount of used flash. None Int: used flash local usedFlash = system.getUsedFlash()
system.getFlashSize >= V1.3.0 Stable Returns the size of the flash. None Int: flash size local flashSize = system.getFlashSize()
system.getFreeFlash >= V1.3.0 Stable Returns the amount of free flash. None Int: free flash local freeFlash = system.getFreeFlash()

Math

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

Operating system

Function Version Description Parameters Returns Example
system.version Not specified expect => V1.0.0 Returns the version of the operating system. None String: version system.version()
system.os_name Not specified expect => V1.0.0 Returns the name of the operating system. None String: os name system.os_name()
system.distro Not specified expect => V1.0.0 Returns the name of the system distribution (Beta , Stable). None String: distro name system.distro()
system.splitVersion >= V1.3.0 Stable Gives a split version of the system. (distro, major, minor, patch, prefix) None String: distro, Int: major, Int: minor, Int: patch, String: prefix local distro, major, minor, patch, prefix = system.splitVersion()
system.isSupported >= V1.3.0 Stable Checks if the current version is higher than the version provided. String: major, String: minor, String: patch, String: prefix (the prefix wont be accounted for stable but still needs to be provided) Bool: is supported local isSupported = system.isSupported("1", "3", "0", "E")

Device

Function Version Description Parameters Returns Example
system.cpuTemp >= V1.3.0 Stable Returns the temerature of the SOC. None Float: TempInC local cpu_c = system.cpuTemp()

Input

Buttons

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

Miscellaneous

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

Logging

Log

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

JSON

Core

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

Algorithms

Symmetric Encryption

Function Version Description Parameters Returns Example
algo.aes >= V1.2.0 Stable 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')
algo.aesKeygen >= V1.2.0 Stable Generates a random AES key of specified length Int: keySize (128, 192, or 256 bits) String: generated key local key = algo.aesKeygen(256)

Hashing

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

Asymmetric Encryption

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

Packetizing

Function Version Description Parameters Returns Example
algo.packetize >= V1.3.0 Stable 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"})
algo.depacketize >= V1.3.0 Stable Takes a packet and outputs a table String: packet Table: data local data = algo.depacketize(packet)

Compression

Function Version Description Parameters Returns Example
algo.tampcompress >= V1.3.0 Stable Compresses a string using the Tamp algorithm. (input string to uint8_t to output string) String: data String: compressed data local compressed = algo.tampcompress('Hello World')
algo.tampdecompress >= V1.3.0 Stable Decompresses a string using the Tamp algorithm. (input string to uint8_t to output string) String: compressedData String: decompressed data local decompressed = algo.tampdecompress(compressed)
algo.deflatedecompress >= V1.3.0 Stable Decompresses a string using the deflate algorithm. String: compresseddata String: decompressed data local decompressed = algo.deflatedecompress(compressed)

Trilateration

Function Version Description Parameters Returns Example
algo.trilaterate3d >= V1.3.0 Stable Calculates the 3D position of a point based on 4 or more anchors and their measured distances using least-squares trilateration. Table: anchors (each anchor must contain pos {x, y, z} and distance) Table: position {x, y, z} local result = algo.trilaterate3d({ {pos={x=0,y=0,z=0},distance=5}, {pos={x=5,y=0,z=0},distance=5}, {pos={x=0,y=5,z=0},distance=5}, {pos={x=0,y=0,z=5},distance=5} }) print(result.x, result.y, result.z)
algo.trilaterate2d >= V1.3.0 Stable Calculates the 2D position of a point based on 3 or more anchors and their measured distances using least-squares trilateration. Table: anchors (each anchor must contain pos {x, y} and distance) Table: position {x, y} local result = algo.trilaterate2d({ {pos={x=0,y=0},distance=5}, {pos={x=5,y=0},distance=5}, {pos={x=0,y=5},distance=5} }) print(result.x, result.y)
algo.trilaterateSpherical >= V1.3.0 Stable Calculates the geographic position (latitude, longitude, and optional altitude) of a point based on 4 or more spherical anchors (latitude, longitude, altitude) and their measured distances using least-squares trilateration on the Earth's surface. Table: anchors (each anchor must contain coord {lat, lon[, alt]} and distance) Table: position {lat, lon, alt} local anchors = { { coord = { lat = 52.5200, lon = 13.4050 }, distance = 1200 }, { coord = { lat = 48.8566, lon = 2.3522 }, distance = 1500 }, { coord = { lat = 51.5074, lon = -0.1278 }, distance = 1300 }, { coord = { lat = 40.7128, lon = -74.0060 }, distance = 5000 } } local result = algo.trilaterateSpherical(anchors) print(result.lat, result.lon, result.alt)
algo.reverseTrilaterate3d >= V1.3.0 Stable Computes distances from a 3D point to each anchor in a list of 3D positions. Table: point {x, y, z}, Table: anchors (array of {x, y, z}) Table: distances (array of numbers) local distances = algo.reverseTrilaterate3d({x=1, y=2, z=3}, {{x=0,y=0,z=0},{x=5,y=5,z=5}})
algo.reverseTrilaterate2d >= V1.3.0 Stable Computes distances from a 2D point to each anchor in a list of 2D positions. Table: point {x, y}, Table: anchors (array of {x, y}) Table: distances (array of numbers) local distances = algo.reverseTrilaterate2d({x=1, y=2}, {{x=0,y=0},{x=5,y=5}})

Mapping

Function Version Description Parameters Returns Example
algo.linearRange >= V1.3.0 Stable Creates a mapping function based on a set of key-value points using linear interpolation. Table: key-value pairs (number keys and number values) Function: mapping function that accepts a number and returns an interpolated number local f = algo.linearRange({ [0]=0, [1]=2, [3]=3 }) local y = f(0.5) -- y == 1
algo.dbmToDistance >= V1.3.0 Stable Estimates the distance in meters from RSSI (dBm) using the log-distance path loss model. Calibrate with RSSI at 1m (A) and environment factor (n). Number: RSSI (dBm), Table (optional): {A, n} Number: Estimated distance (meters) local d = algo.dbmToDistance(-67, { A = -42, n = 2.3 })

Coordinates

Function Version Description Parameters Returns Example
algo.haversineDistance Not specified expect => V1.0.0 Calculates the great-circle distance in meters between two latitude/longitude points using the Haversine formula. Table pointA {lat:number, lon:number}, Table pointB {lat:number, lon:number} Number: distance in meters local dist = algo.haversineDistance({lat=51.5, lon=-0.1}, {lat=40.7, lon=-74.0}) print(dist) -- ~5570000 meters (London to New York)

Polyline

Function Version Description Parameters Returns Example
algo.polylineLength >= V1.3.0 Stable Calculates the total length of a polyline defined by an array of 2D points. Table: points (each point must contain x and y numbers) Number: total length of the polyline local len = algo.polylineLength({ {x=0, y=0}, {x=3, y=4}, {x=6, y=0} }) print(len) -- 10
algo.polylinePointAt >= V1.3.0 Stable Returns the 2D point at a fraction t (0 to 1) along the polyline's length. Table: points (array of points with x and y), Number: t (fraction along polyline, between 0 and 1) Table: position {x, y} at fraction t along the polyline local pt = algo.polylinePointAt({ {x=0, y=0}, {x=3, y=4}, {x=6, y=0} }, 0.5) print(pt.x, pt.y) -- approximately (3, 4)
algo.polylineBoundingBox >= V1.3.0 Stable Computes the bounding box of the polyline points. Table: points (array of points with x and y) Table: bounding box with fields {minX, minY, maxX, maxY} local bbox = algo.polylineBoundingBox({ {x=0, y=0}, {x=3, y=4}, {x=6, y=0} }) print(bbox.minX, bbox.minY, bbox.maxX, bbox.maxY) -- 0 0 6 4

Fft

Function Version Description Parameters Returns Example
algo.fft >= V1.3.0 Stable Performs a Fast Fourier Transform (FFT) on a complex signal array. Input is an array of complex numbers (each with real and imaginary parts). Returns the frequency domain representation. Table: signal (array of complex numbers with {real, imag}) Table: fftResult (array of complex numbers {real, imag}) local signal = { {real=1, imag=0}, {real=0, imag=0}, {real=-1, imag=0}, {real=0, imag=0} } local result = algo.fft(signal) for i, v in ipairs(result) do print(v.real, v.imag) end
algo.ifft >= V1.3.0 Stable Performs an Inverse Fast Fourier Transform (IFFT) on a frequency domain array of complex numbers to reconstruct the original signal. Table: fftData (array of complex numbers {real, imag}) Table: signal (array of complex numbers {real, imag}) local freqData = { {real=0, imag=0}, {real=1, imag=0}, {real=0, imag=0}, {real=1, imag=0} } local signal = algo.ifft(freqData) for i, v in ipairs(signal) do print(v.real, v.imag) end
algo.fftMagnitude >= V1.3.0 Stable Calculates the magnitude spectrum from the FFT result to analyze amplitude at each frequency bin. Table: fftData (array of complex numbers {real, imag}) Table: magnitudes (array of floats) local fftData = algo.fft(signal) local mags = algo.fftMagnitude(fftData) for i, mag in ipairs(mags) do print(mag) end
algo.fftPhase >= V1.3.0 Stable Calculates the phase spectrum (angle in radians) from the FFT result. Table: fftData (array of complex numbers {real, imag}) Table: phases (array of floats in radians) local fftData = algo.fft(signal) local phases = algo.fftPhase(fftData) for i, phase in ipairs(phases) do print(phase) end

Notes

Note Description Types
How to compress Python scripts to compress the data
  • Deflate: python -c "import zlib; import sys; open(sys.argv[2], 'wb').write(zlib.compress(open(sys.argv[1], 'rb').read(), 9))" uncompress_file.bin compressed_file.bin
How to use trilateration To use the trilateration functions, you need to provide a table of anchors with their positions and measured distances.
  • 2D: For 2D trilateration, each anchor should have a position in the form {x, y} and a distance to the point you want to calculate. You need 3 anchors for 2D trilateration.
  • 3D: For 3D trilateration, each anchor should have a position in the form {x, y, z} and a distance to the point you want to calculate. You neeed 4 anchors for 3D trilateration.
How to use reverse trilateration To use the reverse trilateration functions, you need to provide a known point and a list of anchor positions. The function will return the distances from the point to each anchor.
  • 2D: For 2D reverse trilateration, provide a point in the form {x, y} and a list of anchor positions in the same format. The function will return a list of distances.
  • 3D: For 3D reverse trilateration, provide a point in the form {x, y, z} and a list of anchor positions in the same format. The function will return a list of distances.

EasyUI

TextBox

Function Version Description Parameters Returns Example
ezui.textBox >= V1.3.0 Stable Creates a text box. Int: x, Int: y, Int: width, Int: height, String: text None ezui.tbx(10, 10, 100, 50, "Hello World")
ezui.textBoxWithBorder >= V1.3.0 Stable Creates a text box with a border. Int: x, Int: y, Int: width, Int: height, String: text None ezui.tbxb(10, 10, 100, 50, "Hello World")
ezui.textBoxWithBorderAndBackground >= V1.3.0 Stable Creates a text box with a border and a background. Int: x, Int: y, Int: width, Int: height, String: text None ezui.tbxbab(10, 10, 100, 50, "Hello World")

Graphs

Function Version Description Parameters Returns Example
ezui.drawGraph >= V1.3.0 Stable Creates a graph. Table: data (table of numbers),Int: x, Int: y, Int: width, Int: height None ezui.dg(10, 10, 100, 50, {1, 2, 3, 4, 5})

Progress bars

Function Version Description Parameters Returns Example
ezui.progressBar >= V1.3.0 Stable Creates a progress bar. Int: x, Int: y, Int: width, Int: height, Int: progress (0-100) None ezui.pb(10, 10, 100, 50, 50)

Render

Object Management

Function Version Description Parameters Returns Example
render.addObject >= V1.3.0 Stable Adds a 3D object to the render scene. Table: Object3D None render.addObject(obj)
render.clearObjects >= V1.3.0 Stable Clears all objects from the render scene. None None render.clearObjects()

Camera Control

Function Version Description Parameters Returns Example
render.setCameraPosition >= V1.3.0 Stable Sets the camera's position in 3D space. Float: x, Float: y, Float: z None render.setCameraPosition(0, 5, -10)
render.setCameraRotation >= V1.3.0 Stable Sets the camera's rotation in 3D space. Float: x, Float: y, Float: z None render.setCameraRotation(0, 45, 0)
render.cameraLookAt >= V1.3.0 Stable Orients the camera to look at a specific point. Float: x, Float: y, Float: z None render.cameraLookAt(0, 0, 0)
render.setCameraFov >= V1.3.0 Stable Sets the camera's field of view (FOV) in degrees. Float: fov (default 90.0) None render.setCameraFov(60.0)
render.getCameraFov >= V1.3.0 Stable Gets the camera's current field of view (FOV) in degrees. None Float: fov local fov = render.getCameraFov()

Scene Control

Function Version Description Parameters Returns Example
render.render >= V1.3.0 Stable Renders the current scene with all added objects. None None render.render()

Shape Builders

Function Version Description Parameters Returns Example
render.makeCube >= V1.3.0 Stable Creates a cube with optional width, height, and depth. Float: width (default 1.0), Float: height (default 1.0), Float: depth (default 1.0) Table: Object3D cube local cube = render.makeCube(1.0, 1.0, 1.0)
render.makePlane >= V1.3.0 Stable Creates a flat plane with optional width and depth. Float: width (default 1.0), Float: depth (default 1.0) Table: Object3D plane local plane = render.makePlane(2.0, 2.0)
render.makeSphere >= V1.3.0 Stable Creates a sphere with optional radius, segment count, and ring count. Float: radius (default 1.0), Int: segments (default 8), Int: rings (default 6) Table: Object3D sphere local sphere = render.makeSphere(1.0, 12, 8)
render.makePyramid >= V1.3.0 Stable Creates a pyramid with optional width and height. Float: width (default 1.0), Float: height (default 1.0) Table: Object3D pyramid local pyramid = render.makePyramid(1.0, 2.0)

Notes

Note Description Types
Object An Object3D is a table with the following fields: { position, rotation, scale, color } where Position, rotation, and scale are tables with x, y, z fields. Color is a number (0-100).
  • position: A table with x, y, z fields representing the position in 3D space.
  • rotation: A table with x, y, z fields representing the rotation in degrees around each axis.
  • scale: A table with x, y, z fields representing the scale of the object.
  • color: A number representing the color of the object (0-100).
  • vertices: An array of vertices, where each vertex is a table with x, y, z fields at position.
  • edges: An array of edges, where each edge is a table with startIndex and endIndex fields, each being a vertex index.

Pathfinding

Algorithms

Function Version Description Parameters Returns Example
pathfinding.astar Not specified expect => V1.0.0 Finds a path from start to goal using the A* algorithm on a grid map. Table: map (2D array of 0=free,1=blocked), Table: start {x, y}, Table: goal {x, y} Table: path (array of {x, y}), Int: path length local path, cost = pathfinding.astar({{0,0,1},{0,1,0}}, {x=1,y=1}, {x=2,y=2})
pathfinding.dijkstra Not specified expect => V1.0.0 Finds a path from start to goal using Dijkstra's algorithm on a grid map. Table: map (2D array of 0=free,1=blocked), Table: start {x, y}, Table: goal {x, y} Table: path (array of {x, y}), Int: path length local path, cost = pathfinding.dijkstra({{0,0,1},{0,1,0}}, {x=1,y=1}, {x=2,y=2})
pathfinding.dynamic Not specified expect => V1.0.0 Finds a path from start to goal using D* Lite (dynamic pathfinding) on a grid map. Table: map (2D array), Table: start {x, y}, Table: goal {x, y} Table: path (array of {x, y}) local path = pathfinding.dynamic(map, {x=1, y=1}, {x=4, y=4})

Tools

Function Version Description Parameters Returns Example
pathfinding.neighbors Not specified expect => V1.0.0 Returns all walkable neighbor positions for a given position in the map. Table: map (2D array), Table: pos {x, y} Table: neighbors (array of {x, y}) local n = pathfinding.neighbors(map, {x=2, y=2})
pathfinding.withinRadius Not specified expect => V1.0.0 Checks if two points are within a given Manhattan radius. Table: a {x, y}, Table: b {x, y}, Int: radius Bool: true if within radius, false otherwise local ok = pathfinding.withinRadius({x=1,y=1}, {x=2,y=2}, 2)
pathfinding.heuristic Not specified expect => V1.0.0 Returns the Manhattan heuristic distance between two points. Table: a {x, y}, Table: b {x, y} Int: heuristic distance local h = pathfinding.heuristic({x=1,y=1}, {x=2,y=2})

Notes

Note Description Types
Pathfinding Map Format The map for pathfinding algorithms should be a 2D array (table of tables) where 0 means walkable and 1 means blocked. Example: {{0,0,1},{0,1,0}}
Point Format Points for pathfinding functions should be tables with integer fields x and y, e.g. {x=1, y=2}.
Neighbors The neighbors function returns all walkable adjacent cells (up, down, left, right) for a given position.
A* Algorithm The astar function uses the A* algorithm, which finds the shortest path from start to goal using a heuristic (Manhattan distance). It is efficient for grid-based maps and is optimal if the heuristic is admissible.
Dynamic Pathfinding The dynamic function uses D* Lite for pathfinding, which is suitable for environments where the map may change during navigation.
Heuristic The heuristic function returns the Manhattan distance between two points, which is used by A* and other algorithms.
withinRadius The withinRadius function checks if two points are within a given Manhattan distance (radius).

Neural Network

Construction & Serialization

Function Version Description Parameters Returns Example
neuralnetwork.new >= V1.3.0 Stable Creates a new neural network object given a table of layer sizes. Table of integers: layerSizes (e.g. {2,3,1}) userdata: NeuralNetwork object local nn = neuralnetwork.new({2, 3, 1})
neuralnetwork.serialize >= V1.3.0 Stable Serializes the network into a string format suitable for storage or transmission. None String: serialized network data local s = nn:serialize()
neuralnetwork.deserialize >= V1.3.0 Stable Loads network state from a serialization string. String: serialized data Bool: success or failure local ok = nn:deserialize(serializedString)

Training & Prediction

Function Version Description Parameters Returns Example
neuralnetwork.train >= V1.3.0 Stable Trains the neural network using supervised learning. Table of input vectors, Table of target vectors, Number: learningRate, Int: epochs, Bool: logProgress (optional) Float: final loss/error local loss = nn:train(inputs, labels, 0.5, 1000, true)
neuralnetwork.predict >= V1.3.0 Stable Performs a forward pass to generate output given an input vector. Table: input vector Table: output vector local out = nn:predict({1,0})

Preprocessing

Function Version Description Parameters Returns Example
neuralnetwork.preprocess_2d >= V1.3.0 Stable Flattens a 2D table into a 1D vector. Table of tables: 2D array Table: flat 1D vector local flat = nn:preprocess_2d({{1,2},{3,4}})
neuralnetwork.preprocess_3d >= V1.3.0 Stable Flattens a 3D table into a 1D vector. Table of table of tables: 3D array Table: flat 1D vector local flat = nn:preprocess_3d({{{1,2},{3,4}},{{5,6},{7,8}}})
neuralnetwork.preprocess_audio >= V1.3.0 Stable Normalizes and returns a 1D audio data vector. Table: audio sample values Table: normalized audio vector local norm = nn:preprocess_audio({0.1, -0.5, 0.3})

Architecture Inspection

Function Version Description Parameters Returns Example
neuralnetwork.get_num_layers >= V1.3.0 Stable Returns the total number of layers in the network, including input and output layers. None Integer: number of layers local num = nn:get_num_layers()
neuralnetwork.get_layer_sizes >= V1.3.0 Stable Returns the size (number of neurons) of each layer as a Lua table. None Table: {size_layer1, size_layer2, ...} local sizes = nn:get_layer_sizes() -- e.g., {2, 3, 1}

Inflation (Reshaping)

Function Version Description Parameters Returns Example
neuralnetwork.inflate_2d >= V1.3.0 Stable Reshapes a flat vector into a 2D table of given rows and cols. Table: flat vector, Int: rows, Int: cols Table of tables: 2D array local mat = nn:inflate_2d({1,2,3,4}, 2, 2)
neuralnetwork.inflate_3d >= V1.3.0 Stable Reshapes a flat vector into a 3D table with dimensions depth × rows × cols. Table: flat vector, Int: depth, Int: rows, Int: cols 3D array table local tensor = nn:inflate_3d({1,2,3,4,5,6,7,8}, 2, 1, 4)
neuralnetwork.inflate_audio >= V1.3.0 Stable Returns the flat audio vector unchanged. Table: flat audio vector Table: same audio vector local audio = nn:inflate_audio({0.1, 0.2, 0.3})

Neuron Access

Function Version Description Parameters Returns Example
neuralnetwork.get_neuron_output >= V1.3.0 Stable Retrieves the output value of a specific neuron. Int: layerIndex (1‑based), Int: neuronIndex (1‑based) Float: neuron activation local val = nn:get_neuron_output(2, 1)
neuralnetwork.set_neuron_output >= V1.3.0 Stable Manually sets the output value of a specific neuron. Int: layerIndex (1‑based), Int: neuronIndex (1‑based), Float: value Bool: success or failure local ok = nn:set_neuron_output(2, 1, 0.75)

Notes

Note Description Types
Indexing All Lua-facing functions use 1‑based indexing for layers and neurons, while C++ uses 0‑based indexing internally.
Data Format Preprocessing and inflation functions must match dimensions: ensure rows, cols, depth match flat vector length.
Error Logging The 'train' function returns the final loss and optionally logs progress via Serial.print in C++ if enabled.
Serialization Format The network is serialized as a string containing layer sizes, biases, and weights separated by delimiters; see documentation for specific format.

Functions


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

Notes

Note Description Types
Lua interpreter How to use the lua interpreter
  • One line mode: Send the line you want to execute and a newline to execute
  • Multiple line mode: Send the lines but before that |sof| and after that |eof|