Hi fellow Arduino-ers,
For a project I am doing, I am making a device that has a screen, some buttons, some sensors, and a battery. The PCB is finally done, and runs a ATmega4809 as a MCU (same as in a Arduino Nano Every), so now it's "officially" time for the software. But before I start randomly Programming, I want a good idea on how to tackle this.
The main function of the device is something that I have a good idea about writing, IF I could just build that in the main-loop, and not have the device do anything else.
The part that I don't know so well about is how to make a good framework for the device so that the user can interact with it: alter some settings, scroll through different menus, turn on the backlight, and of course put the device in "active" mode. I have thought about how to do this, and I came up with some ideas. But I am wondering if there is any sort of "best practice" way to do this, or even if there are some libraries that I can use.
The method that comes to mind for me is using a finite state machine system (e.g. with this library: GitHub - jrullan/StateMachine: State machine library for Arduino ), where the device can be in a couple different states, depending on which menu or mode you are in, and switch states on user interaction. In every state I would write some sort of loop, which will contain whatever the device must do in that state.
Do any of you have any other good ideas, or tips on what I should watch out for?
Thanks