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()

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:")

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"])

Notes

Note Description Types
Colors The colors used in the display module are defined as follows:
  • 1: White color
  • 0: Black color

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)

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:")

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()

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")

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()

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()

Lua

Function Version Description Parameters Returns Example

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\"}")

Serial

Core

Function Version Description Parameters Returns Example
serial.print Not specified expect => V1.0.0 Prints a string to the serial port. String: str None serial.print("Hello World!")
serial.println Not specified expect => V1.0.0 Prints a string followed by a newline to the serial port. String: str None serial.println("Hello World!")

Reading

Function Version Description Parameters Returns Example
serial.available Not specified expect => V1.0.0 Returns the number of bytes available for reading from the serial port. None Int: bytes available local avail = serial.available()
serial.read Not specified expect => V1.0.0 Reads a single byte from the serial port. None Int: byte value local byte = serial.read()
serial.readString Not specified expect => V1.0.0 Reads all available data from the serial port as a string. None String: data local str = serial.readString()
serial.readStringUntil Not specified expect => V1.0.0 Reads data from the serial port until a specified terminator character. String: terminator (single character) String: data local str = serial.readStringUntil("\n")
serial.readUntil Not specified expect => V1.0.0 Reads data from the serial port until a specified terminator character. String: terminator (single character) String: data local str = serial.readUntil("\n")
serial.peek Not specified expect => V1.0.0 Returns the next byte from the serial port without removing it from the buffer. None Int: byte value local byte = serial.peek()

Writing

Function Version Description Parameters Returns Example
serial.write Not specified expect => V1.0.0 Writes data to the serial port. String: data None serial.write("Hello")

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. (needs main() before 1.3.0 STABLE) 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|