mBlock installs Arduino version 1.6.5 ....Why?


#1

Why does mBlock ship with and install Arduino IDE 1.6.5 only?
The current version of the Arduino IDE is now up to 1.8.1 which has had significant work done on handling and managing libraries.
I am trying to write an mBlock V3.4.6 extension that uses an existing library (Adafruit TCS34725 colour sensor).
I can successfully write simple working extensions for mBlock provided it only has one .H and one .CPP file.
As soon as I include an additional set of .H and .CPP library files the upload to Arduino fails, with lots of multiple definition errors or undefined errors. Note that this upload uses Arduino IDE / compiler version 1.6.5!
If I take the Arduino C source code generated by mBlock V3.4.6 and my extension and place it in a separate Arduino sketch (unmodified) and compile/upload using Arduino V1.8.1 it compiles and works perfectly.

Is there a method to uncouple mBlock and Arduino 1.6.5 and force it to use other Arduino versions like 1.8.1?
I think the older library management of Arduino 1.6.5 is the issue here!

I know that I have discovered a workaround but workarounds are not suitable when teaching school children how to code.

Hope someone can help.
Phil


#2

Hi phil,

Sorry to hear that!
The mBlock is integrated with Arduino 1.6.5 at beginning. Currently, we don’t have a proper way to transfer to the latest version arduino consider various facts. It will cause more important issues once change the integrated arduino version. Hope you can understand, as for your advice, we will add to customer suggestion list for future assessment.


#3

I was able to use new .h and .ccp files (even ones I wrote yourself).
Put the new .h and .ccp files in a folder called “src” and put that folder at the same level as your .s2e file (same level as your “js” folder). Then in your .s2e file be sure to have the “include” statements for your .h files.
The guide on this page(download the pdf) shows an extension with a new “demo.h” and “demo.ccp” files. You can probably handle you missing extensions in the same way this demo.h file was handled in their example.


#4

Hi drew345,
Thank you for your comments. Maybe my first post did not adequately describe my problem. I can write extensions for simple digital reads and writes and simple analog reads and writes and can get them to work perfectly. My problem is the Adafruit TCS34725 colour sensor. This device has an I2C interface and comes with a very nice Arduino library. I can control/read the TCS34725 in the Arduino environment using C/C++ on an Arduino UNO. I would like my STEM students to use mBlock/scratch to control/read the TCS34725. A small problem occurs with mBlock/Scratch and its type ‘double’ and the TCS34725 library type ‘unsigned int’. Arduino does not officially have a separate type called double. Therefore I need to put some code between mBlock/Scratch and the TCS34725 library to sort the casting issue. So I put four files in my “src” folder, namely TCS34725.cpp, TCS34725.h, mylib.cpp and mylib.h. The mylib files contain my intermediary code.This is where it all comes unstuck!! If I just use “mylib” with some code to return a dummy colour value to mBlock it compiles and works perfectly. I then replace the dummy code and call the TCS34725 read function via “mylib” it will not compile under Arduino 1.6.5. If I take the mBlock generated C source code and separately compile it with Arduino 1.6.5. I get multiple definition errors. If I take the mBlock generated C source code and separately compile it with Arduino 1.8.1 it works perfectly. I have tried referencing libraries from libraries just using Arduino 1.6.5 and I get errors, doing the same under Arduino 1.8.1 it works!!

OK I probably should edit the TCS34725 library to return a double or float so that my intermediary library is eliminated altogether and bypass the Arduino 1.6.5 library handling issues, but I fear that my C++ skills or lack of will cause even bigger issues.

Thank, Phil