Skip to content
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

Can't compile with Visual Studio and Platformio #259

Open
LukMas opened this issue Sep 22, 2022 · 4 comments
Open

Can't compile with Visual Studio and Platformio #259

LukMas opened this issue Sep 22, 2022 · 4 comments

Comments

@LukMas
Copy link
Contributor

LukMas commented Sep 22, 2022

Hi!
When I add the code to my simple project (just the start class of the sensor) I can't compile it due to the following error:

[PATH_TO]/ST_Anything/Arduino/libraries/ST_Anything/PS_PulseCounter.cpp:83:72: error: no matching function for call to 'attachInterrupt(byte&, void (&)(), int&)'

As soon I remove the class and its header I can compile the project and it works without any problem.

Could you help me or check why I get this error, please?

Thank you!

@ogiewon
Copy link
Collaborator

ogiewon commented Sep 24, 2022

Have you resolved this compilation error, yet? If not, I recommend you make sure that you're using a current version of the Arduino IDE, and have all of the ST_Anything libraries downloaded and placed in the correct directory per the ReadMe. Also, please be sure you are using one of the supported microcontrollers that supports hardware interrupts, as you're attempting to use the PS_PulseCounter device class.

@ogiewon
Copy link
Collaborator

ogiewon commented Sep 24, 2022

I just saw the title of this issue - Visual Studio and PlatformIO... I have never used those tools to compile ST_Anything. I have only ever used the Arduino IDE.

@LukMas
Copy link
Contributor Author

LukMas commented Sep 24, 2022

No, I also don't have an idea why the problem comes with just this class.
The project is configured in this way:

env:nano_33_iot]
platform = atmelsam
board = nano_33_iot
framework = arduino
lib_deps = 
	arduino-libraries/Servo@^1.1.8
	openenergymonitor/EmonLib@^1.1.0
	arduino-libraries/[email protected]
	adafruit/Adafruit BusIO@^1.12.0

It uses, behind the scenes, the same arduino framework of the Arduino IDE. With Visual Studio and Platformio it just looks more similar to other IDEs.

I have no clue what could cause the error, and just in that class.

@LukMas
Copy link
Contributor Author

LukMas commented Sep 24, 2022

So, I was able to find a way to compile the code. Writing this

	PinStatus status; 
	switch (inttype) {
		case 0:
		status=LOW;
		break;
		case 1:
		status=HIGH;
		break;
		case 2:
		status=CHANGE;
		break;
		case 3:
		status=FALLING;
		break;
		case 4:
		status=RISING;
		break;
	}
	
	attachInterrupt(digitalPinToInterrupt(m_nInputPin), isrPulse, status);

solves the problem. I don't know, but it looks that using directly the int value (inttype) breaks the function call, because the only valid header expects a PinStatus.

Seaching arount about PinStatus and int conversion I've found this: arduino/ArduinoCore-API#25
If the bug is the reason of the error, I don't know. I also don't know if the fix works, except for compiling. I mean, it could compile but change the expected behavior.

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

No branches or pull requests

2 participants