Write your own app - Szybet/InkWatchy GitHub Wiki

Basics

As there were many attempts at writing an arduino based app ecosystem, all of them failed for a simple reason, it limits you (Advanced frameworks like LVGL are overkill and too much resource eating). That's why my system is simple stupid and there is nothing to talk about really.

Your app can (doesn't need to!) consist of three parts (functions):

  • Init - Is executed once at start of your app, can initialize variables etc. I often use it to show all the things on the screen that won't change in the future as we are dealing with eink
  • Loop - The most important function, is executed every classic "arduino" loop, so constantly. This is the most important function, others can be skipped if you don't need them.
  • Exit - Executed when your app exits, for example for the vault it's clearing the key

That's it really, the rest is just an explanation of how to do things properly. If you know enough and don't want to read more, the WiFi debug menu is the perfect example for this, here is the code: https://github.com/Szybet/InkWatchy/blob/master/src/ui/wifiDebug.cpp and here it is executed every loop (in the manager): https://github.com/Szybet/InkWatchy/blob/4dadd069c0bde16c94c55b7167881d694de86aa9/src/ui/manager.cpp#L142-L146 and here it is added to the menu: https://github.com/Szybet/InkWatchy/blob/4dadd069c0bde16c94c55b7167881d694de86aa9/src/ui/managerFunctions.cpp#L89-L93

As you can see, everything launches the manager, the menu is generated dynamically but without memory eating vectors.

Manager what?

Basically a chooser of what needs to launch now, everything you need to know is in manager.cpp. It manages what to launch via a enum (too which you should add you app). It also manages the back button.

Now, how to do things properly (and easier, faster):

  • Use the switch (useButton()) to get button input. This will make sure you never get the back button. The back button goes back
  • Use disUp() and dUChange = true; to refresh the screen (automatic full update management)
  • Use screen writing helper functions like writeLine() or getTextBounds() or drawButton() or writeTextReplaceBack() and many others. The reason for them is that adafruit gfx library is confusing and requires bad code sometimes
  • To add fonts and images, you need to simply add them to the respecting folder (where others are, you will figure it out) then regenerate resources, reflash filesystem and call getImg("cross") for example, and getFont(). Voila, that's so simple, no image2cpp bullshit

That's it, feel free to ask questions

Advanced

Using advanced manager functions, for (very easy, using already integrated "Places") getting input, showing images, showing charts?

I doubt anyone will want to know that, but if so, look up vault and weather code, It's advanced stuff, you basically manipulate placeTree and currentPlace variables via provided functions