You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/code/Apps.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,13 @@ This page will teach you:
6
6
## Theory
7
7
Apps are the things you can launch from the app selection you get by swiping up.
8
8
At the moment, settings and even the app launcher itself or the clock are implemented very similarly, this might change in the future though.
9
-
Every app in InfiniTime is it's own class. An object of the class is created when the app is launched and destroyed when the user exits the app. They run inside the "displayapp" task (briefly discussed [here](./Intro.md)). They are responsible for everything drawn on the screen when they are running. By default, apps only do something (as in a function is executed) when they are created or when a touch event is detected.
9
+
Every app in InfiniTime is it's own class. An instance of the class is created when the app is launched and destroyed when the user exits the app. They run inside the "displayapp" task (briefly discussed [here](./Intro.md)). They are responsible for everything drawn on the screen when they are running. By default, apps only do something (as in a function is executed) when they are created or when a touch event is detected.
10
10
11
11
## Interface
12
12
Every app class has to be inside the namespace `Pinetime::Applications::Screens` and inherit from `Screen`. The constructor should have at least one parameter `DisplayApp* app`, which it needs for the constructor of its parent class Screen. Other parameters should be references to controllers that the app needs. A deconstructor is needed to clean up LVGL and restore any changes (for example re-enable sleeping). App classes can override `bool OnButtonPushed()`, `bool OnTouchEvent(TouchEvents event)` and `bool OnTouchEvent(uint16_t x, uint16_t y)` to implement their own functionality for those events. If an app only needs to display some text and do something upon a touch screen button press, it does not need to override any of these functions, as LVGL can also handle touch events for you. If you have any doubts, you can always look at how the other apps are doing things.
13
13
14
14
### Continuous updating
15
-
If your app needs to be updated continuously, yo can do so by adding a`Refresh()` function to your class and calling `lv_task_create` inside the constructor. An example call could look like this: <br>
15
+
If your app needs to be updated continuously, yo can do so by overriding the`Refresh()` function in your class and calling `lv_task_create` inside the constructor. An example call could look like this: <br>
With `taskRefresh` being a member variable of your class and of type `lv_task_t*`. Remember to delete the task again using `lv_task_del`. The function `RefreshTaskCallback` is inherited from screen and just calls your `Refresh` function.
18
18
@@ -50,8 +50,8 @@ MyApp.cpp:
50
50
using namespace Pinetime::Applications::Screens;
51
51
52
52
MyApp::MyApp(DisplayApp* app) : Screen(app) {
53
-
lv_obj_t* title = lv_label_create(lv_scr_act(), NULL);
54
-
lv_label_set_text_static(title,"My test application");
53
+
lv_obj_t* title = lv_label_create(lv_scr_act(), NULL);
54
+
lv_label_set_text_static(title,"My test application");
0 commit comments