FlexC: Cannot include "servo.h" from SimpleIDE lib
AwesomeCronk
Posts: 1,055
I am building a junction controller for my brother's model railroad using those little S51 micro servos, a handful of toggle switches, and a Prop Mini. I decided to use @ersmith 's FlexSpin compiler, but I needed the SimpleIDE library to get the servo.h
file. I cloned https://github.com/parallaxinc/Simple-Libraries to my source folder and gave it a go. I typed up some quick code and tried it out:switch.c
:
#include "servo.h" int main () { servo_set(16, 1500); }
To compile I ran this in PowerShell 7:
flexspin -D_BAUD=115200 "C:\Users\aweso\Documents\Source\C\Prop1\Simple-Libraries\Learn\Simple Libraries\Motor\libservo\servo.h" switch.c -o switch.bin
Only to recieve this error:
Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2021 Total Spectrum Software Inc. Version 5.5.1 Compiled on: Jun 19 2021 servo.h switch.c error: Preprocessor errors: C:/Users/aweso/Documents/Source/C/Prop1/trainSwitchController/switch.c:1: error: Can't open include file "servo.h" #include "servo.h" 1 error in preprocessor.
Is this a side effect of using non-FlexC libraries with FlexSpin or am I missing something? I have verified that it is a valid path because I can open that file in VSCode.
Comments
That's not how you add a header in any compiler.
What you want is
I had tried that with the
-L
variation, to no avail. Here is the error given by the command you posted:You also need to add the implementation file to the command line if it's not a flexspin-aware header
servo.c
?Yes.
@AwesomeCronk, were you successful in using the simpletools lib clone for your project.?
It would be nice to be able too use your concept and be able to have access too all the other drivers in the simpletools lib. Also, since Wuerfel_21 added the "CMM" version, or something close, too FlexProp for the P1, this might be a good reason to give up on SimpleIDE.
If you were successful could you give a more detailed description of how it is done.
Ray
I tried adding the
servo.c
file to the compile command and got this lovely eruption of unhappy compiler noises:@Rsadeika I did not see your post before I put mine up. No I was not successful in attempting to snatch the SimpleIDE lib. I need to figure out where in the FlexProp lib this servo object is...
The "Simple" libraries aren't really so simple, and unfortunately they depend on GCC in some areas. Roy Eltham has done a great job of porting some of them to FlexProp, but he's only one person and can only do so much. @AwesomeCronk : the specific errors you are seeing look like a missing #include <propeller.h> in servo.c, and possibly a missing #include <stdlib.h>, but I can't be sure.
Wuerfel said the same in the Prop Discord. I tried inserting the
#include "propeller.h"
inservo.c
to no avail. I think I'm just going to use thepwm.c
object fom the FlexProp lib instead.It is to bad that Parallax did not give it more thought when they created the simpletools lib. I know that they just have Andy to do the lib, but it could have been done in a way where the lib could be more universally shared. But, I guess it is to late for that now.
Does anybody have any idea as to how you would be able to pull a specific driver out of the simpletools lib? Andy must have used some kind of logic when he created the simpletools lib.
Ray
AFAIK, you mostly pull a header, pull the necessary files, tweak it until it compiles, repeat as desired. I've never done so though, so take my 2 bits with a grain of salt.
I think I tied that one time and got lost very quickly. Would be nice if FlexProp had a similar setup like SimpleIDE, a pick and choose what driver you want added to, either FlexBASIC or FlexC. Oh well, I guess I can dream.
The one that I would like to get a hold of is the servo360 driver for now. I guess a starting point is libservo380.h and go from there. I will give it a shot, again.
Ray