Skip to content

Generating addon using AI

A ready-made prompt is ready for download in the file addons/ESP_IDE_ADDON_MANUAL_PROMPT.md for generating the add-on using AI.

The .newblk File Format page describes the detailed file structure.

If the AI is creating a display add-on, it must also know the Graphic Designer rules: registration ESPIDE_DISPLAY_TARGETS, variables display, buffer, fbuf, and display.show(). They are described on the Displays and Graphic Designer page and are part of the updated finished prompt.

If you don't want to generate an add-on from scratch, but are converting an existing Arduino library, use the separate tutorial Convert Arduino library to .newblk using AI.

How to proceed

  1. Write down the specification of the add-on: name, purpose, target hardware and the blocks it should contain.
  2. Download the prompt from the file addons/ESP_IDE_ADDON_MANUAL_PROMPT.md.
  3. Complete the placeholders and let the AI generate one file .newblk.
  4. Check the result in the text and in ESP IDE.
  5. Load the add-on via Add-on manager and click on Save changes.

What to prepare before generating

  • the name of the add-on and a short description of its purpose
  • target board or board family
  • list of blocks that the add-on should contain
  • which blocks only read values and which generate code
  • if the add-on needs a button, upload or other callbacks
  • if it should have default pins according to the processor
  • whether it is an add-on for the display, its resolution and any other supported panels
  • whether the driver provides framebuffer, display.show(), buffer and fbuf

What must be in the output

  • just one delimiter <!toolbox!>
  • JavaScript part with definition Blockly.Blocks[...]
  • Python generators Blockly.Python[...]
  • possibly demoWorkspace.registerButtonCallback(...)
  • XML toolbox fragment without <xml> wrapper
  • metadata header is recommended, but not mandatory

Typical errors

  • delimiter <!toolbox!> is in the file more than once
  • the block is in XML, but there is no definition for it in JS
  • block generates code, but Blockly.Python[...] is missing
  • the button in the toolbox has callbackKey, but there is no registered callback
  • AI generates overly generic or incompatible code that needs manual editing

When is a prompt appropriate?

  • when you want to create a new add-on without manually writing the entire structure
  • when the AI does not have direct access to the project's source files
  • when you need to prepare metadata, pin defaults or an upload button right away

Attention

  • Delimiter cannot be multiple times in a file.
  • If the AI generates a block, it must have a matching generator.
  • Always click on Save changes after loading the add-on.