Seeed-Studio / Seeed_Serial_MP3_Player

MIT License
4 stars 13 forks source link

WT2003S_Player refactoring #5

Closed Aleshus closed 1 year ago

Aleshus commented 2 years ago

Hi guys!

I just refactored WT2003S_Player class for better readibility (ok, from my point of view :)), and I want to share this changes with you. Feel free to comment it too!

Thanks for your work.. A.

Pillar1989 commented 2 years ago

@Aleshus can you talk more about this refactoring ? why do you want to refactor? and what's new ?

Aleshus commented 2 years ago

Yes, its pretty simple. My motivation for this was because I had to read this code during debuging my project.

Everything in this PR is about sendCommand method. Original code uses not so pretty goto construction and some helper flags like is_again which I could thanks to refactoring remove. Second problem that I saw is that sendCommand metod returned integer value - if you pass data parameter, method returns 0 for success and -1 for fail. But when you pass the data parameter (it is not NULL), method just returns value from WT2003S chip (it is not 0 or -1) - that is confusing and it is not corresponding with comment anotation of this method.

So this PR is not adding any new functionality - code is only better readable for now and thus more bug free for the future.

Aleshus commented 1 year ago

it matured like wine :)