-
-
Notifications
You must be signed in to change notification settings - Fork 795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Treatment of multi-file sketches not match Arduino build process #130
Comments
Could you provide me an example which works in Arduino IDE, but doesn't work in PlatformIO? |
Here's a short example that demonstrates a difference. There are two source files:
void blink() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// Pin 11 has the LED on Teensy 2.0
// Pin 6 has the LED on Teensy++ 2.0
// Pin 13 has the LED on Teensy 3.0
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
blink();
} The Arduino compiles and builds this just fine, but PlatformIO gives an error:
The problem here is PlatformIO compiles I'm not suggesting for a moment that this is a nice way to organise code, but I suspect that people would expect PlatformIO to behave the same way as the Arduino IDE. Do tell me if you need any more info. I'm working on a very rough prototype to emulate the Arduino IDE's concatenation step at the moment. |
Thanks, I got you. I will resolve this issue today and ask you to test! |
Thanks! Here's the rough-and-ready standalone script that seems to Do The Right Thing(tm): |
Tom, thanks for your script. However, this issue is more interesting:
See how I've fixed it 7f43df4 Could I ask you to test it using PlatformIO Development version? |
Nice work guys. I'm running latest V2.9.4, should this fix be included? I'm trying to migrate an existing project with multiple .ino files to platformio: There are 6 files, I have renamed e.g. These files compile fine with Arduino IDE 1.6.8. What can I do to make these files compile on platfomio? I would very much like to switch to using platormio, it's super nice. Good work 👍
|
Hi @twpayne extern void emonPi_startup();
extern void send_emonpi_serial();
extern byte check_for_DS18B20();
#include <JeeLib.h> |
Thanks, that did the trick 👍 |
@glynhudson This is a bug. Please open a separate issue. |
@glynhudson I've just looked into this issue and found the problem. Please place comments for the prototypes above the declaration. For example, please replace https://github.com/openenergymonitor/emonpi/blob/master/firmware/firmware/startup.ino#L2 to //Used in emonPi startup to detect presence of AC wavefrom and estimate VRMS voltage
double calc_rms(int pin, int samples) { PlatformIO |
Nice, this did the trick 👍 Thanks a lot, I have now migrated my project to platformio, with travisCI build testing :-D https://github.com/openenergymonitor/emonpi/tree/master/firmware |
Added header file. Renamed to .ino because PlatformIO will then work with multiple files (platformio/platformio-core#130)
Background: I'm porting an existing multi-file Arduino sketch to PlatformIO. It does not currently work because PlatformIO's conversion of multi-file sketches to C++ is different to the Arduino IDE's.
The Arduino IDE's process is described in the Arduino Build Process, section "Multi-file sketches" and "Transformations to the main sketch file".
PlatformIO's conversion is in ConvertInoToCpp.
Notable differences are:
.ino
files, whereas PlatformIO creates one per.ino
file.Would you like a patch to change PlatformIO's behaviour to more closely match Arduino's?
The text was updated successfully, but these errors were encountered: