Hello!
As soon as I submitted my first issue, I realized where to look and fixed it.
Now my blocks show up in the drawer but the code will not populate in the code window.
Adding one of the custom blocks causes all other blocks to break as well.
Any thoughts?
I've included a picture of the problem and here is the code for my generators.ts file.
`import Blockly from 'blockly';
import _ from 'lodash';
Blockly['Arduino']['fastled_setup'] = function (block) {
const numberOfLeds = block.getFieldValue('NUMBER_LEDS');
const pin = block.getFieldValue('PIN');
Blockly['Arduino'].libraries_['define_fastled'] =
'#include <FastLed.h>;\n\n' +
'CRGB leds[NUM_LEDS];';
Blockly['Arduino'].setupCode_['fast_led'] = '\tFastLED.addLeds<WS2811, ' + pin + 'GRB>(leds, ' + numberOfLeds + ');';
return '';
};
Blockly['Arduino']['fastled_set_color'] = function (block) {
Blockly['Arduino'].functionNames_['set_color'] =
'\n\nvoid setNeoPixelColor(double pos, RGB color) {\n' +
'\tpos = pos <= 0 ? 0 : pos;\n' +
'\tpos = pos >= 1 ? pos - 1 : pos;\n' +
'\tpixels.setPixelColor((int)pos, color.red * brightness, color.green * brightness, color.blue * brightness);\n' +
'\tpixels.show();\n' +
'}\n';
let color = Blockly['Arduino'].valueToCode(
block,
'COLOR',
Blockly['Arduino'].ORDER_ATOMIC
);
if (_.isEmpty(color)) {
color = '{ 0, 0, 0 }';
}
const position = Blockly['Arduino'].valueToCode(
block,
'POSITION',
Blockly['Arduino'].ORDER_ATOMIC
);
return '\tsetNeoPixelColor(' + position + ',' + color + ');\n';
};
`