KRYONOS

JavaScript & Duktape API

Reference manual for the native JavaScript runtime, GUI widgets, and hardware I/O bindings in KryonOS.

Documentation on this site is currently a work in progress. For complete guides, visit the KryonOS GitHub Wiki.

JavaScript & Duktape API Reference

KryonOS embeds a lightweight, high-performance Duktape 2.7 JavaScript Virtual Machine. User applications are written in JavaScript and have direct access to graphics, sensors, file storage, and network sockets.


1. System & Console

// Output to hardware serial monitor & on-screen debug console
print("Hello from KryonOS!");
console.log("Memory Free:", System.getFreeHeap(), "bytes");

// System reboot and uptime
var uptimeSec = System.getUptime();

2. Display & 2D/3D Drawing API

// Clear screen with Hex or RGB color
Display.clear(0x000000);

// Draw shapes and text
Display.drawRect(20, 20, 100, 60, 0x00FFC2); // Cyan rectangle
Display.fillRect(30, 30, 80, 40, 0x1E293B);  // Filled box
Display.drawText("KryonOS v1.4", 35, 45, 0xFFFFFF, 2);

// 3D Wireframe Cube Renderer
var cube = new Graphics3D.Cube({
  size: 40,
  x: 120,
  y: 160,
  wireColor: 0x0DA2E7
});

cube.rotate(15, 30, 45);
cube.render();

3. Hardware GPIO & Sensors

// Configure GPIO pin
var LED_PIN = 2;
GPIO.pinMode(LED_PIN, GPIO.OUTPUT);

// Toggle pin high / low
GPIO.digitalWrite(LED_PIN, 1);

// Read ADC Analog sensor
var adcValue = GPIO.analogRead(34);
print("Sensor Reading:", adcValue);

4. KryonDrive File I/O

// Read and write files to flash storage
Storage.writeFile("/apps/my_app.js", "print('Saved app!');");

var content = Storage.readFile("/apps/my_app.js");
print("File content:", content);

// List directory contents
var files = Storage.listDir("/apps");
files.forEach(function(file) {
  print("- " + file.name + " (" + file.size + " bytes)");
});

On this page