/**
* ESP32 DevKit-C Web Component
*
* Renders an ESP32 DevKit-C board (38 pins) as a custom HTML element.
* Pin layout follows the standard ESP32 DevKit-C pinout.
*/
const ESP32_WIDTH = 280;
const ESP32_HEIGHT = 185;
// ESP32 DevKit-C pinout (left column = GPIO order top-to-bottom, right column = same)
const ESP32_PINS = [
// Left column (top to bottom)
{ name: 'GPIO36', x: 2, y: 18 },
{ name: 'GPIO39', x: 2, y: 29 },
{ name: 'GPIO34', x: 2, y: 40 },
{ name: 'GPIO35', x: 2, y: 51 },
{ name: 'GPIO32', x: 2, y: 62 },
{ name: 'GPIO33', x: 2, y: 73 },
{ name: 'GPIO25', x: 2, y: 84 },
{ name: 'GPIO26', x: 2, y: 95 },
{ name: 'GPIO27', x: 2, y: 106 },
{ name: 'GPIO14', x: 2, y: 117 },
{ name: 'GPIO12', x: 2, y: 128 },
{ name: 'GND', x: 2, y: 139 },
{ name: 'GPIO13', x: 2, y: 150 },
{ name: 'GPIO9', x: 2, y: 161 },
{ name: 'GPIO10', x: 2, y: 172 },
{ name: 'GPIO11', x: 2, y: 183 },
// Right column (top to bottom)
{ name: '3V3', x: 278, y: 18 },
{ name: 'EN', x: 278, y: 29 },
{ name: 'GPIO36', x: 278, y: 40 },
{ name: 'GPIO39', x: 278, y: 51 },
{ name: 'GPIO34', x: 278, y: 62 },
{ name: 'GPIO35', x: 278, y: 73 },
{ name: 'GPIO32', x: 278, y: 84 },
{ name: 'GPIO33', x: 278, y: 95 },
{ name: 'GPIO25', x: 278, y: 106 },
{ name: 'GPIO26', x: 278, y: 117 },
{ name: 'GPIO27', x: 278, y: 128 },
{ name: 'GND', x: 278, y: 139 },
{ name: 'GPIO13', x: 278, y: 150 },
{ name: 'GPIO15', x: 278, y: 161 },
{ name: 'GPIO2', x: 278, y: 172 },
{ name: 'GPIO0', x: 278, y: 183 },
// Bottom row
{ name: 'GND', x: 30, y: 183 },
{ name: '5V', x: 50, y: 183 },
{ name: 'GPIO23', x: 70, y: 183 },
{ name: 'GPIO22', x: 90, y: 183 },
{ name: 'TX', x: 110, y: 183 },
{ name: 'RX', x: 130, y: 183 },
{ name: 'GPIO21', x: 150, y: 183 },
{ name: 'GND', x: 170, y: 183 },
{ name: 'GPIO19', x: 190, y: 183 },
{ name: 'GPIO18', x: 210, y: 183 },
{ name: 'GPIO5', x: 230, y: 183 },
{ name: 'GPIO17', x: 250, y: 183 },
{ name: 'GPIO16', x: 270, y: 183 },
{ name: 'GPIO4', x: 20, y: 183 },
];
class Esp32Element extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
}
connectedCallback() {
this.render();
}
get pinInfo() {
return ESP32_PINS;
}
render() {
if (!this.shadowRoot) return;
this.shadowRoot.innerHTML = `
`;
}
}
if (!customElements.get('wokwi-esp32')) {
customElements.define('wokwi-esp32', Esp32Element);
}