System, Console & Notifications
Global System API, Console debugging, and floating System.notify banners.
2. Global Object: System
The System object provides low-level hardware-accelerated bindings to the ESP32 OS.
Display Properties
System.screenWidth() / System.width()
- Returns:
Integer(e.g.320on T-Deck Plus,240on portrait devices). - Description: Returns the live physical width of the TFT display according to the board's configured orientation. Both
System.screenWidth()and the aliasSystem.width()are supported.
System.screenHeight() / System.height()
- Returns:
Integer(e.g.240on T-Deck Plus,320on portrait devices). - Description: Returns the live physical height of the TFT display according to the board's configured orientation. Both
System.screenHeight()and the aliasSystem.height()are supported.
OS Utilities
System.getOSVersion()
- Returns:
String(e.g.,"3.0.0") - Description: Returns the current OS version string.
System.getAPILevel()
- Returns:
Integer(e.g.,3) - Description: Returns the OS API Level integer.
System.millis()
- Returns:
Integer - Description: Returns the total uptime of the ESP32 hardware in milliseconds since the device booted. Used for delta-time physics and loop timing.
System.micros()
- Returns:
Integer - Description: Returns the total uptime of the ESP32 hardware in microseconds since the device booted. Essential for extreme high-resolution timing (e.g., custom bit-banged protocols). Note that the 32-bit integer rolls over every ~71 minutes.
System.getTemperature()
- Returns:
Float - Description: Reads the ESP32's internal core temperature sensor and returns the value in Celsius.
System.hasTemperatureSensor()
- Returns:
Boolean - Description: Checks if the currently installed ESP32 hardware revision actually supports the internal temperature sensor (some newer chips remove it). Returns
trueif supported.
System.delay(ms)
- Parameters:
ms(Integer) - The amount of milliseconds to pause execution. - Returns:
undefined - Description: Pauses JavaScript execution. CRITICAL: This function commands the C++ kernel to perform Garbage Collection in the background. If you have an infinite
while(true)loop, you MUST include aSystem.delay(10)call to prevent the OS from crashing due to heap exhaustion.
System.delayMicroseconds(us)
- Parameters:
us(Integer) - The amount of microseconds to pause execution. - Returns:
undefined - Description: Provides highly accurate sub-millisecond delays natively. This blocks the CPU execution cleanly, without triggering Garbage Collection.
System.print(str)
- Parameters:
str(String) - Returns:
undefined - Description: Prints a message to the physical USB Serial Monitor on a connected computer (Baud rate 115200). Useful for debugging variables when the screen is rendering frames.
System.getTouch()
- Returns:
Object->{ x: Integer, y: Integer, touched: Boolean } - Description: Polls the SPI Touch Controller.
touchedistrueif a finger/stylus is pressing the screen.xandyrepresent pixel coordinates. Iftouchedisfalse,xandydefault to 0.
- Hidden Exit Trigger: If a user touches
x >= 200andy <= 40(Top-Right corner), the C++ Kernel will instantly abort the JS Engine and force-close the app to prevent users from getting permanently locked out of the OS.
System.getInfo()
- Returns:
Object->{ totalRAM: Integer, freeRAM: Integer, minFreeRAM: Integer, maxAllocRAM: Integer, cpuFreqMHz: Integer, chipModel: String, deviceName: String, boardModel: String, chipCores: Integer, chipRevision: Integer, flashSize: Integer, uptimeMs: Integer } - Description: Returns an object containing the current state of the ESP32 hardware, including memory usage, CPU speed, and hardware specifications. Useful for debugging memory leaks and checking uptime.
deviceName: Human-readable board target name (e.g.,"T-Deck Plus","T-Deck").boardModel: Alias todeviceName.minFreeRAM: The lowest free RAM amount recorded since boot.maxAllocRAM: The largest single contiguous block of RAM you can allocate.
System.getIPAddress()
- Returns: String
- Description: Returns the current local IP address of the ESP32 (e.g. "192.168.1.11") if WiFi is connected.
System.isWiFiActive()
- Returns: Boolean
- Description: Returns
trueif the ESP32 is currently connected to a WiFi network.
System.restart()
- Returns: None
- Description: Instantly reboots the ESP32 hardware.
System.getTime()
- Returns:
String(e.g.,"14:30"or"02:30 PM") - Description: Returns the OS-formatted current local time, automatically respecting the user's 12-hour or 24-hour preference setting.
System.getSeconds()
- Returns:
Integer(0-59) - Description: Returns the current local second directly from the RTC.
System.getDate()
- Returns:
String(e.g.,"15/06/2026") - Description: Returns the current local date formatted as DD/MM/YYYY.
System.getYear()
- Returns:
Integer(e.g.,2026) - Description: Returns the current local 4-digit year.
System.getMonth()
- Returns:
Integer(1-12) - Description: Returns the current local month.
System.getDay()
- Returns:
Integer(1-31) - Description: Returns the current local day of the month.
System.getTimezone()
- Returns:
String(e.g.,"UTC-8") - Description: Returns the user's currently configured timezone offset region.
System.prompt(promptMsg, initialText)
- Parameters:
promptMsg(String) - Header text displayed above the keyboard.initialText(String) - Text pre-filled into the keyboard input box.
- Returns:
String - Description: Completely suspends JavaScript execution and opens the native C++ Full-Screen Touch Keyboard. Once the user clicks "Enter", execution resumes and the typed string is returned. Returns an empty string
""if the user clicks "Cancel".
10. Console API & App Debugging in Serial Monitor
KryonOS routes JavaScript exceptions, syntax errors, and standard console output directly to the USB Serial Monitor (115200 baud) with rich diagnostic formatting and immediate hardware FIFO flushing (Serial.flush()).
10.1 Global console Object
All standard JavaScript logging functions are globally available:
console.log("App initialized successfully", { version: "1.0", fps: 60 });
console.info("Connecting to remote endpoint:", "http://192.168.1.8:8080");
console.warn("Low memory warning, clearing cache");
console.error("Failed to parse response payload:", err);
console.debug("Raw payload bytes:", [0x01, 0xFF, 0x42]);
Serial Output Format:
Each console level prepends a severity tag in the serial stream:
console.log(...)→[JS LOG] <message>console.info(...)→[JS INFO] <message>console.warn(...)→[JS WARN] <message>console.error(...)→[JS ERROR] <message>console.debug(...)→[JS DEBUG] <message>
Multi-Argument & Complex Type Serialization:
- Supports variable number of arguments separated by spaces (e.g.,
console.log("A", 123, true)). - Objects & Dictionaries: Automatically formatted via safe
JSON.stringify. - Primitives: Numbers, booleans, strings,
null, andundefinedare accurately stringified.
10.2 Global print & println Stream
For raw serial output without [JS ...] tag prefixes, use:
print("Starting sequence...");
println("Done.");
You can also use the System object aliases: System.log(...), System.info(...), System.warn(...), System.error(...), System.debug(), System.print(...), and System.println(...).
10.3 Diagnostic Test App
The official diagnostic test app is located at test-js-apps/com.kryonos.consoletest/ to test and benchmark all serial logging features.
10.4 Serial Monitor Error Output
When a JavaScript runtime exception, syntax error, or uncaught callback error occurs, KryonOS outputs a formatted diagnostic box to the serial monitor:
================================================================================
[KryonOS JS Exception] TypeError
--------------------------------------------------------------------------------
File : /sd/apps/com.myapp.demo/main.js
Line : 42
Message : cannot read property 'connect' of undefined
Stack Trace:
at initializeNetwork (/sd/apps/com.myapp.demo/main.js:42)
at main (/sd/apps/com.myapp.demo/main.js:12)
================================================================================
15. Floating System Notifications (System.notify / Notification)
KryonOS features an OS-level floating notification compositor. Notifications are stored in a fixed-size ring buffer in RAM (zero heap fragmentation) and rendered as non-blocking glass pill cards with cubic easing animations (SLIDE_IN → DISPLAYING → SLIDE_OUT) and optional audio chimes.
15.1 Posting a Notification
System.notify(options)
- Parameters:
options(Object or String)title: String (max 24 chars) - Title displayed at the top of the toast card.message: String (max 48 chars) - Detail message or subtitle.icon: String (Optional, default:"info") - Badge style:"info"(Cyan),"success"(Green),"warning"(Yellow),"error"(Red).duration: Number (Optional, default:3000) - Display duration in milliseconds (500..15000).sound: Boolean (Optional, default:false) - Whentrue, plays a brief piezo/PWM chime upon appearance.
- Returns:
Integer- Notification ID (-1if ring buffer queue is full). - Description: Queues and immediately animates a floating top banner over the current display.
// Post a success toast with sound chime
var notifId = System.notify({
title: "Download Complete",
message: "Photo saved to /local/photos/cat.bmp",
icon: "success",
duration: 3500,
sound: true
});
15.2 Managing Notifications
System.notify.dismiss(id)
- Parameters:
id(Integer) - The notification ID returned bySystem.notify(). - Returns:
Boolean-trueif found and dismissed,falseotherwise. - Description: Immediately transitions the specified toast into its exit slide-out animation.
System.notify.clearAll()
- Returns:
undefined - Description: Flushes and dismisses all active and queued floating notifications.
System.notify.isActive() / System.notify.hasActive()
- Returns:
Boolean-trueif a floating notification is currently animating or displayed on screen,falseotherwise. - Description: Checks if a toast banner is currently active on the display.
Automatic Zero-Flicker Background Restoration: KryonOS maintains an internal shadow display compositor buffer in high-speed PSRAM. When a notification appears, the OS automatically captures the covered region and restores the exact original header, text, icons, and colors in real-time as the toast slides away. Developers do not need to write any manual redraw boilerplate in their applications.