Extension development: working with arguments received from a block


#1

Hello all,

As a few people around here, i’m trying to develop an extension so my students can program easily neopixel type of rgb ledstrip. The concept is simple: create block corresponding to the main functions available in FastLED.io. So far, I have a working basic extension that can init a ledstrip, prepare leds and apply changes to the strip.

I would like to make that extension a bit more versatile, step one making it possible to use different types of ledstrip.

I am trying to pass an argument received from a block to a function used in setup:
“setup”:“FastLED.addLeds<{2}, {1}, RGB>(strip_{0}, {3});\n”,

{2} is holding a ledstrip type, lets say “WS2812B”. When mblock create the sketch, it adds double quote, so I end up with
FastLED.addLeds<“WS2812B”, 6, RGB>(strip_0, 36);
instead of
FastLED.addLeds<WS2812B, 6, RGB>(strip_0, 36);
So I cannot pass this argument directly…

Does anyone as an idea that would be simpler than writing an external function? Just trying to drop the double quotes.

A long time ago I used to code, trying to get back at it.

Maxime


#2

Hi cayenm,
Think I may be one of those you refer to as trying to write an extension to mBlock, so I may not be of much help :grin: but here goes!

What do you have in the “values” section of your .s2e file?

From what I understand your block should have a drop down menu with all the ledstrip types, once you select the ledstrip type the .s2e file “values” field should substitute the correct argument.

“values”:{
“WS2812B”:strip_0,

}

Hope this helps