Love UECIDE? Why not consider supporting the development?

User registrations are now disabled on this site.

We have a new forum system

>> Click here to try it out. <<

Problem with library MenuBackend

Problem with library MenuBackend

Postby maxid » Fri Oct 24, 2014 7:03 pm

I'm testing a library for handling menus.
[url] https://github.com/WiringProject/Wiring ... enuBackend [/ url]
In arduino 1.05 compiles normally but fails uecide

Compiling ...
Compiling Sketch ...
C: \ Users \ Maxi \ Documents \ UECIDE \ pruebaMenu \ pruebaMenu.ino: 21: error: 'menuUseEvent' was not declared in scope This
C: \ Users \ Maxi \ Documents \ UECIDE \ pruebaMenu \ pruebaMenu.ino: 21: error: 'menuChangeEvent' was not declared in scope This
Failed compiling sketch
maxid
 
Posts: 22
Joined: Sat Jul 26, 2014 3:09 am
 

Re: Problem with library MenuBackend

Postby matt » Fri Oct 24, 2014 10:04 pm

Which version of UECIDE?
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".
matt
Site Admin
 
Posts: 1318
Joined: Sun Jul 07, 2013 11:37 am
I use UECIDE on: Linux
 

Re: Problem with library MenuBackend

Postby maxid » Sat Oct 25, 2014 2:09 am

If compile this example with ide Standard. That xompile ok.
Arduino 1.0.5
Uecide 8.7j
maxid
 
Posts: 22
Joined: Sat Jul 26, 2014 3:09 am
 

Re: Problem with library MenuBackend

Postby matt » Sat Oct 25, 2014 10:43 am

Ah yes, this is all to do with function prototypes, and how Arduino lures you into bad practices and habits.

All functions need to be defined before they are used, either by having the function further up the file than its first usage, or by having a "function prototype" to define a function that is further defined later on in the file.

The Arduino IDE and UECIDE add function prototypes for you when it compiles the sketch, so you can put your functions in any order you choose. They both use different methods though.

Arduino places the function prototypes just before the first non-command and non #include line. UECIDE places them just before the first function in the file.

The Arduino way breaks a lot of things, the UECIDE way only breaks a few things - neither are perfect, and I frown on the whole practice anyway (there's an option in UECIDE to completely disable it).

All you need to do is place your own function prototypes for the functions that are referenced in the MenuBackend constructor (menuUseEvent and menuChangeEvent), which is basically the first line of the function followed by a semi-colon, before said constructor:

Code: Select all
//this controls the menu backend and the event generation
void menuChangeEvent(MenuChangeEvent changed);
void menuUseEvent(MenuUseEvent used);
MenuBackend menu = MenuBackend(menuUseEvent, menuChangeEvent);


It should compile fine on both systems then.
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".
matt
Site Admin
 
Posts: 1318
Joined: Sun Jul 07, 2013 11:37 am
I use UECIDE on: Linux
 

Re: Problem with library MenuBackend

Postby maxid » Mon Oct 27, 2014 2:09 pm

Thanks I really appreciate your help, the ide is superior.
I'm a C ++ programmer rusty, I'm using Pascal and object-Pascal
maxid
 
Posts: 22
Joined: Sat Jul 26, 2014 3:09 am
 

Re: Problem with library MenuBackend

Postby matt » Mon Oct 27, 2014 3:12 pm

maxid wrote:I'm using Pascal and object-Pascal

Well, I can't help you with that problem I'm afraid - maybe you should seek counselling? :twisted:
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".
matt
Site Admin
 
Posts: 1318
Joined: Sun Jul 07, 2013 11:37 am
I use UECIDE on: Linux
 

Re: Problem with library MenuBackend

Postby maxid » Mon Oct 27, 2014 3:29 pm

No, I just need dusting and study C ++
maxid
 
Posts: 22
Joined: Sat Jul 26, 2014 3:09 am
 

Re: Problem with library MenuBackend

Postby maxid » Thu Oct 30, 2014 3:48 pm

I think something is wrong, I want to use any library that have problems.
try using the timer https://github.com/JChristensen/Timer and there is no way to compile.
Using the example in uecide not work and arduino yes.
Put the function prototype as mensionaste and nothing.

What is wrong? :oops:


Original code
Code: Select all
#include "Timer.h"

Timer t;

int ledEvent;

void setup()
{
  Serial.begin(9600);
  int tickEvent = t.every(2000, doSomething);
  Serial.print("2 second tick started id=");
  Serial.println(tickEvent);
 
  pinMode(13, OUTPUT);
  ledEvent = t.oscillate(13, 50, HIGH);
  Serial.print("LED event started id=");
  Serial.println(ledEvent);
 
  int afterEvent = t.after(10000, doAfter);
  Serial.print("After event started id=");
  Serial.println(afterEvent);
 
}

void loop()
{
  t.update();
}

void doSomething()
{
  Serial.print("2 second tick: millis()=");
  Serial.println(millis());
}


void doAfter()
{
  Serial.println("stop the led event");
  t.stop(ledEvent);
  t.oscillate(13, 500, HIGH, 5);
}
maxid
 
Posts: 22
Joined: Sat Jul 26, 2014 3:09 am
 

Re: Problem with library MenuBackend

Postby maxid » Thu Oct 30, 2014 4:22 pm

Well, I found something that may help.
if I use the arduino core fails, but if I use the arduino-0023 core, yes compiles :idea:
maxid
 
Posts: 22
Joined: Sat Jul 26, 2014 3:09 am
 

Re: Problem with library MenuBackend

Postby matt » Thu Oct 30, 2014 11:10 pm

I think this may now be because you're on version J - on my beta version that code compiled first time no problems.

There were some issues with finding libraries in the release version IIRC which have been solved in the later beta - especially when you have multiple libraries for different cores in different locations - it gets confused as to which is which.
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".
matt
Site Admin
 
Posts: 1318
Joined: Sun Jul 07, 2013 11:37 am
I use UECIDE on: Linux
 
 
Next

Return to Arduino / AVR

Who is online

Users browsing this forum: No registered users and 2 guests

cron