The first error was "WProgram.h" which I had to change to Arduino.h. But now I get :
multithreaded_lcd_code:90: error: 'incrementNumber' was not declared in this scope
TimedAction numberThread = TimedAction(700,incrementNumber);
multithreaded_lcd_code:91: error: 'changeText' was not declared in this scope
TimedAction textThread = TimedAction(3000,changeText);
What is changed in the compiler so that this would not work anymore?
Or what do I have to change to get it compiled again? A bit annoying
that demo codes don't work...
//create a couple timers that will fire repeatedly every x ms
TimedAction numberThread = TimedAction(700,incrementNumber);
TimedAction textThread = TimedAction(3000,changeText);
//this is our first task, print an incrementing number to the LCD
void incrementNumber(){
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// add one to the counter, then display it.
timerCounter = timerCounter + 1;
lcd.print(timerCounter);
The other option would be to manually add function prototypes for incrementNumber() and changeText() before these lines or to move the definitions of these functions before these lines.
Proxxima:
What is changed in the compiler so that this would not work anymore?
The Arduino IDE automatically generates function prototypes to make writing code a bit more beginner friendly. It has to be pretty smart to make sure these prototypes are placed at the correct location in the code. In Arduino IDE 1.6.6 and newer the sketch preprocessing system was completely rewritten in order to improve this process. It has taken a while to get the new system working well but in recent versions it is definitely better. Unfortunately there are still some rare cases where the new system breaks code that used to work, which you have encountered. You can find information on this here:
Hi, I'm the author of the original post. Looks like they changed how function prototypes are built or how function references are passed in a later version. This was written prior to 1.6.6 I believe. I'll edit the post to simply move the functions north of where they are used and that should fix the issue. If you could drop a note in the comments on Hackster next time I'll see it sooner. Thanks for looking into it Pert, and for the reply on Hackster
reanimationxp:
Looks like they changed how function prototypes are built or how function references are passed in a later version. This was written prior to 1.6.6 I believe.
It's the placement of the function prototype. arduino-builder is putting those prototypes after the creation of the timers. Here's what the preprocessed code looks like using Arduino IDE 1.8.3:
//create a couple timers that will fire repeatedly every x ms
TimedAction numberThread = TimedAction(700,incrementNumber);
TimedAction textThread = TimedAction(3000,changeText);
//this is our first task, print an incrementing number to the LCD
#line 94 "C:\\Users\\per\\AppData\\Local\\Temp\\arduino_modified_sketch_18441\\sketch_aug18b.ino"
void incrementNumber();
#line 104 "C:\\Users\\per\\AppData\\Local\\Temp\\arduino_modified_sketch_18441\\sketch_aug18b.ino"
void changeText();
#line 125 "C:\\Users\\per\\AppData\\Local\\Temp\\arduino_modified_sketch_18441\\sketch_aug18b.ino"
void setup();
#line 133 "C:\\Users\\per\\AppData\\Local\\Temp\\arduino_modified_sketch_18441\\sketch_aug18b.ino"
void loop();
#line 94 "C:\\Users\\per\\AppData\\Local\\Temp\\arduino_modified_sketch_18441\\sketch_aug18b.ino"
reanimationxp:
I'll edit the post to simply move the functions north of where they are used and that should fix the issue.
I think that's probably the best solution as long as it's possible to do so. The first solution I posted above, while the most simple, is not backwards compatible with the IDE versions between 1.6.6 and the release after I submitted that issue report. Your solution will be compatible with all IDE versions.
Way cool that you're so responsive to fixing this! You might also add a note about the WProgram.h thing, though that problem's so common that it's easy enough for users to find the solution to that error.
pert:
You might also add a note about the WProgram.h thing, though that problem's so common that it's easy enough for users to find the solution to that error.
I'd actually already done so Corrected the code by moving that block, mentioned that issue, and removed an unnecessary library as well. Should be good now.