Transcode Settings for Arduino C libraries and headers


#1

I’m working on an extension for an Arduino Uno robot. mBlock5. In the Transcode Settings tab of the block, I have added, for example, the files from the Adafruit_NeoPixel library.

The generated C code works, if I copy it from the Arduino C side window of mBlock to the Arduino IDE, and upload it from there. If I try to upload it from mBlock, compile errors.

I’ve found that if I look at the downloaded unzipped extension code, in the src/arduinosources.js file, some .cpp and .h files parse to valid JSON, and some don’t. The ones that don’t are the ones that won’t compile.

One guess is that sources that don’t transcode to valid JSON have characters that are special characters in JSON? If so, I haven’t figured it out yet. I’ll keep looking at it.

Any ideas? Anyone have a more robust ArduinoC generator?

Is there a way to include libs without making JSON out of them?

Thanks.


#2

Update:
Original lib source code says:

asm volatile(
“head40:” “\n\t”

After including it in mBlock extension it looks like:

asm volatile(
“head40:” "
"

So it’s possible to edit the original source, replace \n with \\n and \t with \\t, and make it work. More of a crude hack than a fix, but it looks like it might work.

Also, for the accelStepper.h library, removing from each /// to the end of the line makes it appear to work with mBlock.

Disclaimer… I’m yet to solder up the LED strip or stepper motor.


#3

Neopixels work! Really though, the ArduinoC code generator should be fixed. I’ll put it on my list of things to do, but no promises about when I’ll take a look at it.


#4

Hey Martin!! You’re a genius!!!
I was trying to make this work for weeks!!
Thank you!!!