wokwi-docs icon indicating copy to clipboard operation
wokwi-docs copied to clipboard

WokWi part features and arguments

Open kvapehe opened this issue 2 years ago • 2 comments

WokWi part features and arguments

The title on this was a bit difficult to make, as of 2023-05 the title tries to reflect information to put inside the diagram.json However it may also include parameters to the WokWi editor in order to create a specific project. And if there are issues with the .ino or cpp-files the same issue wokwi/wokwi-docs#176 may be used.

The page is not organized for now. It try to list moments, issues and ideas as it comes to my mind. It will be irregularly updated as new issues and ideas arise or comments from others are made. Not even sure if the belongs on this location on github, but for now this is the location.

To reference ore explain some elements late a section to examples will be included. Hopefully the examples are as general to benefit others, if not, own projects may be included, or even test projects focusing on the issue. The idea is that test projects will have a README.md, a commented .ino, and a crafted diagram.json

When comments or notes are available to the WokWi editor, those will be used as well. And when ea project selection, or search page is later available to both logged in users and others, the plan it to add some tags to information thet may be helpful for users. I also hope a beta-page and unsupported/not fully implemented page will be available to users. For now I try to make it here.

TOC

Manually created TOC, no links and not verified it is always updated

  • diagram.json
  • The esp and FastLED.
  • ...
  • Several links that may help me or others

diagram.json

Example showing the pixelate attribute

"parts": [
    {  
      "type": "wokwi-neopixel-canvas",      "id": "neopixels1",      "top": 950.07,      "left": 0,  
      "rotate": 0.000001,  
      "attrs": { "rows": "1", "cols": "60", "matrixBrightness": "10", "pixelate": "circle" }  
    },

some attributes and keys

  • Example to show key, flip and transperent wires in the drawing window. Note the ... is inserted to cut some lines, making the json-code invalid if you simply copy paste it.
"parts": [ ...
    {
      "type": "wokwi-pushbutton",      "id": "btn1", ...
      "rotate": -90,       "attrs": { "color": "red", "key": "t" }

      "id": "led1",      "attrs": { "color": "cyan", "flip": "" }
  ],
  "connections": [ ...
    [ "btn1:2.l", "uno:3", "goldTransp", [ "h0" ] ],
    [ "btn1:1.r", "uno:GND.1", "blackTransp", [ "v0" ] ],
    [ "Sec1:1", "Sec1:2", "Section1Transp", [ "*" ] ],
    [ "uno:5", "neopixels16:DIN", "orangeTransp", [ "v-14", "*", "v-8" ] ], ...

esp advanced keys and attributes 01

The esp is simulated in different was for esp, s2, s3 and c3. bootloader is not included with ordinary esp If you like to use this feature then modify the attrs:-key. See example below

...
  "parts": [
    { "type": "wokwi-esp32-devkit-v1", "id": "esp", "top": 0, "left": 0, "attrs": { "fullBoot": "1" } },

The esp and FastLED.

Note no solutions, only information and some help Also see this page for information: https://docs.wokwi.com/guides/esp32#simulation-features

.ino or c++ or cpp

#define FASTLED_FORCE_SOFTWARE_SPI
#include <FastLED.h>
// Message: /libraries/FastLED/src/fastspi.h:145: 
//    #pragma message: No hardware SPI pins defined.  All SPI access will default to bitbanged output

/** links to FastLED.
https://github.com/FastLED/FastLED/wiki/SPI-Hardware-or-Bit-banging
https://github.com/marmilicious/FastLED_2_Processing
*/
/* Info
  For the code to run as expected you may need to be careful with the pin-selections and prepare pins for SPI-use
*/
// ...
void fastledsetuo() {
  // Assuming all constants and variables are available tho the function
  // LED1 can only be an int literals constant. (unigned, int, long, byte, etc. is ok) 
  // creating an array like so:
  int LEDARRY[] = { 5, 6, 7}; // and referencin like so 
    LEDARRY[0] // is not the same as
  const int LED1 = 5; // or #define LED1 5
  FastLED.addLeds<LED_TYPE, LED1, COLOR_ORDER>(leds[0], NUM_LEDS).setCorrection( TypicalLEDStrip );
}
// Link to example is not included for now.

Several links that may help me or others

Some related to WokWi on github or othere WokWi related locations

https://github.com/wokwi/wokwi-boards https://github.com/wokwi/wokwi-boards/tree/main/boards https://github.com/wokwi/wokwi-elements https://github.com/wokwi/wokwi-elements/tree/master/src https://github.com/wokwi/splendida https://elements.wokwi.com/?path=/story/resistor--470%CF%89 Issue: ESP32S3 Servo https://github.com/wokwi/wokwi-features/issues/570 https://docs.wokwi.com/guides/esp32

Some projects

No explanation or information for now. Simply a list of projects https://wokwi.com/projects/312460386125218368 https://wokwi.com/projects/342634722692694610 https://wokwi.com/projects/363419673189621761

Others

https://docs.github.com/en/get-started/writing-on-github https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/ https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet

kvapehe avatar May 07 '23 08:05 kvapehe

Wrapping up this page, and may move some information to another repository, when I know how to reference between them.

kvapehe avatar May 07 '23 10:05 kvapehe

Moved it for you :)

urish avatar May 07 '23 10:05 urish