GUI design and architecture

Hello fellow DIY creators.
I am new at this forum, and english is not my native language, but I will do my best to explain my question clearly.

I am building an audio source selector (select form multiple sources, include BT and WiFi radio, and set selected on the output), with TFT LCD display and multiple other perypherials (SD card reader, IR control etc).

I have my hardware (ESP32) more or less prepared, concept was testet partially, but it is time for creating scalable, readable and maintainable code for the project.

And here's the clue:

What should be architecture used for this kind of project? Based on Object Oriented programming, or something else?
How to manage changing display of different graphics for different source selected, or setting selected, and how to change the purpose of buttons and encoder?

I know this is vague, but I don't want to write code with 20 layer of if statements, I believe there should be some other, more elegant way to handle these interfaces issues.

Does anybody have some experience with that and would like to share?

Thanks
Adam

Because of the small amount of flash and RAM available on an Arduino, their programs tend to be small and for this reason, don't really need the full rigor of the software engineering toolbox. That's not to say that you should ignore such things and throw goto statements all over the place, but you're not going to be building a huge system where good architecture is critical.

I'd start with the cleanest code I could manage, even if it does need twenty if statements and look to refactoring it as I understood the problem better.

That said, you might consider building an abstract class AudioSource and inherit concrete sources from that. You might use dependency injection to provide a graphics handler object and a controls handler too. I wouldn't bother, but those are patterns that would be useful if you want an OO design.

hello wildbill, thank you for response

I'd love to use the OO solution, however I don't have good enough skills in programming in OO, so I am not sure how would that work:

wildbill:
Because of the small amount of flash and RAM available on an Arduino, their programs tend to be small You might use dependency injection to provide a graphics handler object and a controls handler too.

Do you mind sharing an example or where to learn more about OO in Arduino IDE?

I think that the title is misleading - or do you really want to implement a GUI on an Arduino?

Selection of an audio source is not a question of complicated code or OO, more a matter of reliable analog hardware.

DrDiettrich:
I think that the title is misleading - or do you really want to implement a GUI on an Arduino?

Yes, GUI stands for Graphical User Interface, and with the TFT LCD display I want to interact with user using graphics and text. Maby title shoudl be “programming guidelines with desinging and inplementing GUI”?

DrDiettrich:
Selection of an audio source is not a question of complicated code or OO, more a matter of reliable analog hardware.

I’ve got this covered with PT2314 chip

aaddaas:
hello wildbill, thank you for response

I'd love to use the OO solution, however I don't have good enough skills in programming in OO, so I am not sure how would that work:

Do you mind sharing an example or where to learn more about OO in Arduino IDE?

It's not really anything Arduino specific. What you need is a C++ tutorial and perhaps then something about design patterns in C++. Since you lack OO experience, I'd suggest that you start with something simple: pick one or two obvious objects in your system and make classes for them. Forget dependency injection and all those other trendy patterns until you've got the basics down.

Did you already study the library and sample codes for your display?

aaddaas:
Maby title shoudl be “programming guidelines with desinging and inplementing GUI”?

The very first thing is to get some paper and pencil and draw the proposed screen layouts - then show them to a few people and ask them if they understand them and could use them. Get them to pretend they are operating a real screen.

I had two good books, they seem to still be available :-

  • User Interface Design for Programmers by Joel Spolsky
  • Don’t make me think by Steve Krug

…R

DrDiettrich:
Did you already study the library and sample codes for your display?

Yes, I know how to use it, and tried different stuff

Robin2:
The very first thing is to get some paper and pencil and draw the proposed screen layouts - then show them to a few people and ask them if they understand them and could use them. Get them to pretend they are operating a real screen.

That's done already, I am now ready to code the full project, hence this topic

Robin2:
I had two good books, they seem to still be available :-

  • User Interface Design for Programmers by Joel Spolsky
  • Don't make me think by Steve Krug

...R

Thank you for this list, I sure will check it.