r/ArduinoHelp • • 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

15 comments sorted by

View all comments

Show parent comment

1

u/gm310509 18d ago

Unfortunately I am not going to research each of those libraries to find out what they do (assuming I even could find the exact same ones that you are using) and try to figure out what your program is doing....

.... But I will hazard a guess that the answer is most of them.

You need to work out what libraries you actually need and include just those headers files that pertain to that library. Usually there is just one or two and they will include th le needed dependencies.

By listing that many, all you are probably doing is just slowing down the compilation process because the compiler has to examine all of that, including any files that the ones you have listed include and figure out what it relevant and what is not.

But assuming everything else is correct, the compiler will likely be able to manage that process and produce the "correct" result. Note that "correct" means a program that does what you told it to do - which is absolutely definitely not necessarily the same as what you want it to do, unless your instructions are aligned with what you want.

To use an analogy you have given someone a very large stack of paper and told them to find the page with the heading that says "XYZ". You know that that page is right in the middle, but you don't tell them that, you just give them the whole gigantic stack and expect them to figure it out. That is what you are doing by listing all of those include files. The job can still be done, it is just requires more effort.

1

u/Cosplay_Pappy 18d ago

You don’t need to be rude. I’m new to this, and thought I’d ask for help. Most of these popped up when I tried to include ONE library and it brought its buddies along with it. I don’t know how many of them are actually needed.

I know I forgot to mention what it’s supposed to do, and for that, I am sorry. It’s supposed to connect with a ps5 controller, and use its chosen inputs to control four servos, and play a randomly selected sound or a preselected sound from an SD card.

1

u/gm310509 18d ago

I'm sorry that you feel I am being rude. Also I don't understand why you would feel that way.

Perhaps if you could clarify where you feel I am being rude I can explain that part more clearly.

But for now, you have provided some code. I don't know what it does and I don't have spare time to read through it to figure it out. I did note that there are a lot of includes and that that is unusual, and likely unnecessary. As a result the answer to your question is that you could probably remove most of them.

I also went on to explain how the compiler works and tried to use an analogy as to share why all those includes just creates overheads.

I'm sorry that you feel I was being rude. That was not my intent.

But since you do feel that way, hopefully someone else will help you.

1

u/Cosplay_Pappy 18d ago

The last paragraph in your previous comment came off as a bit condescending to me. I apologize since you didn’t mean it that way. I clearly misread the tone.

I did add what the code does in my previous comment, but I’ll restate it here with a bit more detail. The code is for a regular esp32 to connect with a ps5 controller over Bluetooth. It then takes specific inputs from the controller (cross, square, and circle buttons and analog sticks) and plays either a random audio from a list on a connected SD card (cross button) or a preselected audio (square and circle buttons). The analog stick inputs control four servos that are controlling what is essentially a robot arm with no grip.

I hope this helps, and I’m sorry again for misunderstanding your tone. Thank you!

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.

1

u/Cosplay_Pappy 16d ago

Thank you so much for your time! I was finally able to get the SD card to mount, but I’m not sure what I did to fix it. I’ve been fixing/ altering code all day today. Most of what is commented out can be deleted, but I held onto it so I could see my process. I looked at the libraries again, and the massive chunk of them at the top weren’t needed as they were for a different board (esp8266?). I have gotten it to compile and upload, but now my controller won’t connect, so I’m working on that. I’m using Google’s AI to get an idea of what to do with mixed, but mostly positive, results. It doesn’t have my entire code, though.