Documentation
// open-source libs

Wokwi Libraries

Eidolon uses official Wokwi open-source repositories cloned locally in third-party/. This gives you up-to-date, compatible emulation engines and visual components without npm registry dependencies.

Cloned Repositories

LibraryLocationPurpose
@wokwi/elementsnpm48+ Lit Web Components (LEDs, LCDs, sensors, buttons...)
avr8jsnpmATmega328p / ATmega2560 CPU emulator at 16 MHz
rp2040jsnpmRaspberry Pi Pico (RP2040) emulator

All three libraries are pulled directly from the npm registry by apps/web/package.json. Reference clones may live under third-party/ for credits and offline hacking, but the build does not require them.

Updating the Libraries

Edit the version pins in apps/web/package.json (@wokwi/elements, avr8js, rp2040js) and run npm install in apps/web/.

After bumping wokwi-elements (only when adding new components)

The metadata generator scans the upstream src/, which the npm package doesn't ship. Clone wokwi-elements once into third-party/ and regenerate:

git clone --depth=1 https://github.com/wokwi/wokwi-elements.git \
  third-party/wokwi-elements
cd apps/web && npm run generate:metadata

Available Wokwi Components (48)

CategoryComponents
BoardsArduino Uno, Mega, Nano, ESP32 DevKit
SensorsDHT22, HC-SR04, PIR, Photoresistor, NTC, Joystick
DisplaysLCD 16x2, LCD 20x4, 7-Segment
InputPush button, 6mm button, Slide switch, DIP switch 8, Potentiometer
OutputLED, RGB LED, LED bar graph, Buzzer, NeoPixel
MotorsServo, Stepper motor
PassiveResistor, Slide potentiometer, LED ring, Matrix keypad
OtherIR receiver, DS1307 RTC, breadboards, etc.

How avr8js Powers the Simulation

1import { CPU, avrInstruction, AVRTimer, AVRUSART, AVRADC, AVRIOPort } from 'avr8js';
2
3const cpu   = new CPU(programMemory);          // ATmega328p at 16 MHz
4const portB = new AVRIOPort(cpu, portBConfig); // digital pins 8-13
5const portC = new AVRIOPort(cpu, portCConfig); // analog pins A0-A5
6const portD = new AVRIOPort(cpu, portDConfig); // digital pins 0-7
7
8function runFrame() {
9  const cycles = Math.floor(267_000 * speed);
10  for (let i = 0; i < cycles; i++) {
11    avrInstruction(cpu); // execute one AVR instruction
12    cpu.tick();          // advance timers + peripherals
13  }
14  requestAnimationFrame(runFrame);
15}
Full details: See docs/WOKWI_LIBS.md in the repository.