Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Combining Arduino project & PlatformIO project (Newbie) (Read 5537 times)
ided_out
Newbies
*
Offline


Posts: 4
Joined: Nov 26th, 2018
Combining Arduino project & PlatformIO project (Newbie)
Nov 26th, 2018 at 4:30pm
Print Post  
I've just come across VisualMicro and would like some basic guidance please.

I've had reasonable experience the Arduino  IDE and writing sketches using it.  I started with simple programs, like Blink and built them up more and more.  Then used the DCC++ freeware project from GitHub to control a model railway using a Mega256 and Motor Shield.  Most recently, I've started to use ESP32s in particular to control some servos via a simple web page.

I've now come across a PlatformIO package (which uses the Visual Studio front end?) that does the equivalent of the DCC++ app mentioned above but for an ESP32 rather than an Arduino.  But this app is in much more formal C++ which I've never really learnt.

My question is:
Is it feasible/easy to include standard Arduino IDE libraries and my own "Arduino IDE based" code in that PlatformIO project and somehow be able to call my routines from the PlatformIO code?

If it is feasible, could anyone give me a trivial example of what this would look like?  I'm sure I could then go from there.

Many thanks.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12166
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Combining Arduino project & PlatformIO project (Newbie)
Reply #1 - Nov 26th, 2018 at 4:54pm
Print Post  
I am no entirely clear about the question.

My understanding is that DCC++ is simply a standard arduino project that contains c++ code in both .ino and .cpp/h files.

The Arduino IDE supports the esp32 which is installed via Board Manager. It's the same in Visual Micro.

If this is a standard arduino project then you just need to unzip it onto your machine and use "file>open arduino project" in visual micro.

All code that conforms to the arduino standard works the same and support libraries.

What have I missed?
  
Back to top
IP Logged
 
ided_out
Newbies
*
Offline


Posts: 4
Joined: Nov 26th, 2018
Re: Combining Arduino project & PlatformIO project (Newbie)
Reply #2 - Nov 26th, 2018 at 7:16pm
Print Post  
Thanks for the speedy response, Tim.

Perhaps explaining what I've done in the past caused some confusion on what I want to do in the future!  Let me try again...

Using the Arduino IDE, I've written a sketch for the ESP32 to drive some servos.  This sketch and the Arduino IDE uses what I guess is a simple version of c++.  It has at the start some #includes of libraries and has functions with simple syntax like
void moveServo(int servoNo){
  int remainder= servoNo%2;
  int actualServer = (int)servoNo/2;
  servo[actualServer].attach(servoPins[actualServer]);   
  for (int i=iIncreaseLow;i<=iIncreaseHigh;i++){servo[actualServer].write(i);}
  servo[actualServer].detach();
}
, etc...

This style I understand and can write reasonably well using the Arduino IDE.

I now want to include the functionality of my sketch within the product I mentioned earlier from GitHub.  This is an ESP32 version of DCC and I'd be using its Throttle features to drive the trains.  By incorporating my code within it, the servos would be able to switch the track points simply - more simply that DCC would require me to do it.   However, that other package has been written in what seems to me to be a much more strict version of c++ and the recommendation was that it is altered or run through PerformIO (which seems to use Visual Studio,)  That application has .cpp and .h files and the code looks much more formal (like ADA) - possibly this is because it's more low level than my code and much better written!  e.g.
void OutputManager::createOrUpdate(const uint16_t id, const uint8_t pin, const uint8_t flags) {
  for (const auto& output : outputs) {
    if(output->getID() == id) {
      output->update(pin, flags);
      return;
    }
  }
  outputs.add(new Output(id, pin, flags));
}


I'm unclear as to whether I would need to re-write all my own code to be in .cpp files (and in the stricter syntax) or whether I can simply include my functions and #includes as a .ino file into Visual Studio's .src directory and then call one of my functions from within one of the .cpp files 

I hope this makes more sense to you now, Tim.



[As a very blunt 1st attempt, I've just included the whole of my .ino file into the other app and an attempt to build gives 2 fatal problems:
1) #include errors detected. Please update your includePath. IntelliSense features for this translation unit (2018-11-26DCCppESP32-master/src/_18-09-01_ESP_32_Multi_servos_and_wifi.ino) will be provided by the Tag Parser."
2) cannot open source file "Servo.h"]
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12166
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Combining Arduino project & PlatformIO project (Newbie)
Reply #3 - Nov 26th, 2018 at 7:22pm
Print Post  
please give link to the git hub project
  
Back to top
IP Logged
 
ided_out
Newbies
*
Offline


Posts: 4
Joined: Nov 26th, 2018
Re: Combining Arduino project & PlatformIO project (Newbie)
Reply #4 - Nov 26th, 2018 at 7:40pm
Print Post  
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12166
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Combining Arduino project & PlatformIO project (Newbie)
Reply #5 - Nov 26th, 2018 at 8:38pm
Print Post  
Thanks. This code is actually arduino code but confused by platformio. Maybe we will support platformio in the future alongside arduino.

You should be able to add your libraries to the platfomio.ini in the project root then transpose your code into platformio.
  
Back to top
IP Logged
 
ided_out
Newbies
*
Offline


Posts: 4
Joined: Nov 26th, 2018
Re: Combining Arduino project & PlatformIO project (Newbie)
Reply #6 - Nov 26th, 2018 at 8:55pm
Print Post  
I'll give it a go.  Thanks for your time and speedy responses, Tim.  Much appreciated.

I'm away in a short while, but will post an update once I get back in a couple of weeks.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint