r/ArduinoHelp • u/Cosplay_Pappy • 22d ago
Bluepad32 end curly bracket error
/r/esp32projects/comments/1xp1ubo/bluepad32_end_curly_bracket_error/I hope someone can help with this. I’ve been trying to use Bluepad32 to pair a ps5 controller with my esp32-s3. I need it to control a music player and four servos. My code is fine and has all closed curly brackets, but the verify output keeps telling me I need an ending curly brackets after input at the very end of my code. I think it has to do with the FreeRTOS file.
I have no idea how to fix this. Please help! I’ve been trying to fix this for several days. If I add the curly bracket to the FreeRTOS file, it just breaks more.
1
Upvotes
View all comments
Show parent comment
1
u/gm310509 16d ago
No worries, sometimes it is difficult to communicate effectively in a forum like this. Everybody is different and has different experience levels and current state of mind and interpret things differently.
With that in mind, the following is about trying to share with you the magnitude of the task you are requesting - while it might come across badly, it is not intended that way it is intended to share with you the effort required to pick up somebody elses code, understand it (beyond you are doing some PS5 stuff) and make suggestions.
I spent about 10 minutes skimming through your code, I noticed one thing - which i mention below. To check what I am about to say, I had to extract your code (thanks for posting it as text BTW, it made it much easier - many people just post screen shots and it is much harder to do the following). All of this took the 10 minutes - and does not include the time to report just this one thing back to you.
So, the one thing is, I noted you do a sprintf into messageString at line 131 in the notify function. But, I didn't see that you are doing anything with it (i.e. not printing it).
I further noticed that you commented out the declaration of messageString in the notify function and thought, "Oh, maybe you are declaring it as a global variable and using it somewhere else". This is when I needed to copy the code out into a proper editor so I could check for all the occurrences of messageString. As I suspected, you are using it at line 161 in a "improperly declared partial function" in a Serial.println().
Upon further investigation, it appears that your commenting out of the messageString also commented out the first line of the sprintf, but left the remaining parameters as executeable code starting with the
ps5.LStickX(),line - which presumably is meant to be the first value to be passed to the sprintf control string (which is commented out).Following the sprintf is a closing brace which ends the notify function.
But following the closing brace, there is a commented out if statement (containing the Serial.println). If uncommented, this block of code would be outside of any function declaration and thus not valid (it would likely cause a mismatched brace error if it was uncommented.
So as a result what you are trying to do with just this one line of code seems very confusing to me. The fact that you are doing some PS/5 stuff doesn't help clarify whatever it is that you are intending to do with the partially commented out sprintf and the following commented out print statement that is outside of a valid function declaration.
So, all of that time to try to follow what is going on with that one variable, working out what is commented out and what isn't, identifying that there is a partial set of executable code following the sprintf that looks like it should be part of the sprintf and not still executebale takes a lot of effort.
A single include file could contain and references hundreds or even thousands of lines of code. Plus without knowing exactly which library you are using, I might not even be looking at the same one you have (the names of files in a library can be reused - and often are - in different versions of similar libraries and thus have different code).
So, to go through it all in any detail, as I mentioned is a huge ask and the one thing that I did comment on (and remember the 10 minutes I spent trying to figure out what was going on with just that one variable) did not include the time it took to write this reply.
As to your original question, you need to work out why you felt the need to include the individual files. If you are unsure, try starting out with a minimal version of your code and work out the absolute minimum number of files to include - as I mentioned there is likely one or two "top level" files you need to include.
By way of example, if you have the IRRemote library installed on your PC (I gave the github link in case you don't have it) you will see that it has lots of includeable files. But you don't include them all - you just include one of the one top level ones as described in the usage section. That file determines what other stuff (if anything) needs to be included.
Reading the documentation of the libraries you are trying to use is important as is refering to the examples.
Maybe, just maybe, you do actually need all of those files, but I suspect that you can remove most of them but you need to identify the main ones.
All thebest with it.