Skip to content

Conversation

@Panky-codes
Copy link
Contributor

Hello,
I am using Platformio to write my Arduino sketches. Platformio, by default creates a main.cpp file to have advanced options in the IDE. So I copied the example sketch into my main.cpp and the code was not building. I noticed that there were function declarations after loop() function but the function definitions were missing. So once I added the definitions, the code started compiling.
Later I discovered that if I compile it as *.ino file, arduino framework does this behind the scenes (link: https://community.platformio.org/t/order-of-function-declaration/4546/1)
In order to avoid compilation error when compiling it as *.c or *.cpp, I added a function definitions in all the example sketches. Now the code is compatible for *.ino, *.c and *.cpp files.

@lewispg228
Copy link
Contributor

Hi Panky-codes,
Thank you for your pull request! I will be verifying your changes with hardware later this week. Sorry for the delay here, but we are currently out of stock of the LSM9DS1, and production is cranking away to build more as I type this.

Thanks again and I'll update this asap,
-Pete

@Panky-codes
Copy link
Contributor Author

Hi Pete,
Thanks a lot for the reply. I also found one possible improvement in the LSM9DS1_Basic_I2C.ino file.

In the setup function, the code is trying to do a begin operation only once. Because of that, the first few times my module did not just connect to the microcontroller. Hence I had to restart manually the microcontroller to make it work (which I found after half an hour of debugging :P ).

I did some digging for a while and found that it works if we retry to establish I2C by calling the begin function again in our setup. I think this change can help people who are just starting out with the board without having to debug the board right away.

I wanted to know if I can also push that commit along with this change or create a separate PR for that.

Cheers,
Pankaj

@lewispg228
Copy link
Contributor

Hi Pankaj,
I just verified this works on my setup, so I will merge in here shortly. Thanks!!

About your request to add in a redundant begin operation. I didn't experience this issue with my setup just now. I am using a Redboard Qwiic. What hardware are you using? I'm wondering if it is a problem only surfacing on certain hardware platforms.

Either way, I would like to keep it on a separate pull request, so if you wouldn't mind opening up another that would be great.

Thanks again and I look forward to hearing from you.

On a side note, I am fairly new to platformio, and I did have a big of learning to do to get up and running with this library and examples.

I had a bit of trouble learning how to adjust the baud rate on the monitor to 115200 (for serial debug) on these examples. I ended up modifying the platformio.ini file within my project file. Is this the best place to do this? let me know and thanks!

@lewispg228 lewispg228 merged commit 8811368 into sparkfun:master Aug 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants