Megapi_firmware - unable to compile


#1

I am unable to update the firmware on my new MegaPi board using my Windows PC using Arduino 1.6.11 IDE. I installed the latest libraries (3.24) from https://github.com/Makeblock-official/Makeblock-Libraries but I’m getting multiple errors (see below).

I’ve selected

  • Board: Arduino/Genuino Mega or Mega 2560
  • Processor: ATMega2560
  • Programmer: AVRISPmkII

I even tried installing using Ubuntu - thinking that it was a Windows thing but no luck. Any idea what might be going on?

======================================================================

Arduino: 1.6.11 (Windows 8.1), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"
C:\Users\npmilani\Documents\Arduino\megapi_firmware\encoders.ino: In function ‘void encodersInit()’:
encoders:7: error: ‘class MeEncoderOnBoard’ has no member named 'GetIntNum’
attachInterrupt(encoders[0].GetIntNum(), isr_process_encoder1, RISING);
^
encoders:7: error: ‘isr_process_encoder1’ was not declared in this scope
attachInterrupt(encoders[0].GetIntNum(), isr_process_encoder1, RISING);
^
encoders:8: error: ‘class MeEncoderOnBoard’ has no member named 'GetIntNum’
attachInterrupt(encoders[1].GetIntNum(), isr_process_encoder2, RISING);
^
encoders:8: error: ‘isr_process_encoder2’ was not declared in this scope
attachInterrupt(encoders[1].GetIntNum(), isr_process_encoder2, RISING);
^
encoders:9: error: ‘class MeEncoderOnBoard’ has no member named 'GetIntNum’
attachInterrupt(encoders[2].GetIntNum(), isr_process_encoder3, RISING);
^
encoders:9: error: ‘isr_process_encoder3’ was not declared in this scope
attachInterrupt(encoders[2].GetIntNum(), isr_process_encoder3, RISING);
^
encoders:10: error: ‘class MeEncoderOnBoard’ has no member named 'GetIntNum’
attachInterrupt(encoders[3].GetIntNum(), isr_process_encoder4, RISING);
^
encoders:10: error: ‘isr_process_encoder4’ was not declared in this scope
attachInterrupt(encoders[3].GetIntNum(), isr_process_encoder4, RISING);
^
encoders:13: error: ‘class MeEncoderOnBoard’ has no member named 'SetPulsePos’
encoders[0].SetPulsePos(0);
^
encoders:14: error: ‘class MeEncoderOnBoard’ has no member named 'SetPulsePos’
encoders[1].SetPulsePos(0);
^
encoders:15: error: ‘class MeEncoderOnBoard’ has no member named 'SetPulsePos’
encoders[2].SetPulsePos(0);
^
encoders:16: error: ‘class MeEncoderOnBoard’ has no member named 'SetPulsePos’
encoders[3].SetPulsePos(0);
^
C:\Users\npmilani\Documents\Arduino\megapi_firmware\encoders.ino: In function ‘void encodersUpdate()’:
encoders:24: error: ‘class MeEncoderOnBoard’ has no member named 'update’
encoders[i].update();
^
C:\Users\npmilani\Documents\Arduino\megapi_firmware\encoders.ino: In function ‘void PWM_Calcu()’:
encoders:40: error: ‘class MeEncoderOnBoard’ has no member named 'GetCurrentSpeed’
speed1 = encoders[0].GetCurrentSpeed();
^
encoders:41: error: ‘class MeEncoderOnBoard’ has no member named 'GetCurrentSpeed’
speed2 = encoders[1].GetCurrentSpeed();
^
C:\Users\npmilani\Documents\Arduino\megapi_firmware\encoders.ino: In function ‘void Forward()’:
encoders:98: error: ‘Encoder_1’ was not declared in this scope
Encoder_1.setMotorPwm(-moveSpeed);
^
encoders:99: error: ‘Encoder_2’ was not declared in this scope
Encoder_2.setMotorPwm(moveSpeed);
^
C:\Users\npmilani\Documents\Arduino\megapi_firmware\excute.ino: In function ‘void runModule(int)’:
excute:44: error: no matching function for call to 'MeEncoderOnBoard::move(long int&, void (&)(int, int), int&)'
encoders[slot-1].move(distance,onEncoderMovingFinish,extId);
^
C:\Users\npmilani\Documents\Arduino\megapi_firmware\excute.ino:44:71: note: candidate is:
In file included from C:\Users\npmilani\Documents\Arduino\libraries\makeblock\src/MeMegaPi.h:70:0,
from C:\Users\npmilani\Documents\Arduino\megapi_firmware\megapi_firmware.ino:15:
C:\Users\npmilani\Documents\Arduino\libraries\makeblock\src/MeEncoderOnBoard.h:481:8: note: void MeEncoderOnBoard::move(long int, float, int16_t, cb)
void move(long position,float speed = 100,int16_t extId=0,cb callback=NULL);
^
C:\Users\npmilani\Documents\Arduino\libraries\makeblock\src/MeEncoderOnBoard.h:481:8: note: no known conversion for argument 2 from ‘void(int, int)’ to 'float’
excute:56: error: no matching function for call to 'MeEncoderOnBoard::moveTo(long int&, void (&)(int, int), int&)'
encoders[slot-1].moveTo(position,onEncoderMovingFinish,extId);
^
C:\Users\npmilani\Documents\Arduino\megapi_firmware\excute.ino:56:73: note: candidate is:
In file included from C:\Users\npmilani\Documents\Arduino\libraries\makeblock\src/MeMegaPi.h:70:0,
from C:\Users\npmilani\Documents\Arduino\megapi_firmware\megapi_firmware.ino:15:
C:\Users\npmilani\Documents\Arduino\libraries\makeblock\src/MeEncoderOnBoard.h:503:8: note: void MeEncoderOnBoard::moveTo(long int, float, int16_t, cb)
void moveTo(long position,float speed = 100,int16_t extId=0,cb callback=NULL);
^
C:\Users\npmilani\Documents\Arduino\libraries\makeblock\src/MeEncoderOnBoard.h:503:8: note: no known conversion for argument 2 from ‘void(int, int)’ to ‘float’
exit status 1
’class MeEncoderOnBoard’ has no member named ‘GetIntNum’


#2

I was able to compile it with no problems using the Arduino 1.6.11 IDE. Here are my steps:

  1. Clone the Makeblock-Libraries into a temp folder.
  2. Zip up the makeblock folder in the Makeblock-Libraries folder.
  3. Add the library from within the Arduino IDE (Sketch->Include Library->Add .ZIP library) using the newly created makeblock.zip file.

You should be able to successfully compile at this point.

Regards,

Chuck


#3

Did you try the mblock app for windows? I didn’t have an issue using it


#4

Adding the library from within the Arduino IDE fixed the problem - thanks very much! First I had to delete the makeblock library directories I added manually - or else the IDE wouldn’t re-import the same libraries. I obviously skipped that step and instead created the makeblock library files in the same directory as the Arduino IDE. As a result, I could select them directly from the IDE dropdown menus but apparently when doing this it didn’t map the path properly.


#5

Yes, I was able to use the mBlock app directly and create a simple servo program that moves servo to a specific angle. But when I selected “Arduino mode” and tried open that same code using “Edit with Arduino IDE” it wouldn’t compile until I compile and download “Firmware_for_MegaPi” first from the Arduino IDE.

This whole question stems from the difficulty in finding any servo-specific examples for MegaPI, I didn’t know the MegaPI servo API’s, include files, configuration code for addressing servos, etc.

I was finally able to get some sample code running for running 6 servos simultaneously on MegaPI on pins A6 to A11 using the following steps:

  • use mBlock app and adding “set servo XX angle YY” block, build, compile and download
  • select “Arduino Mode” and "Edit with Arduino IDE
  • compile and download “Firmware_for_MegaPi”
  • edit code in Arduino IDE, add more logic, add more servos, build, compile and download

#6