Skip to content

Commit c12fc5e

Browse files
Riksu9000JF002
authored andcommitted
Improvements to Apps.md and Intro.md
1 parent d158303 commit c12fc5e

2 files changed

Lines changed: 19 additions & 26 deletions

File tree

doc/code/Apps.md

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Apps
22
This page will teach you:
3-
- what apps in InfiniTime are
3+
- what screens and apps are in InfiniTime
44
- how to implement your own app
55

66
## Theory
7-
Apps are the things you can launch from the app selection you get by swiping up.
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.
7+
8+
The user interface of InfiniTime is made up of **screens**
9+
Screens that are opened from the app launcher are considered **apps**
910
Every app in InfiniTime is it's own class.
1011
An instance of the class is created when the app is launched and destroyed when the user exits the app.
1112
They run inside the "displayapp" task (briefly discussed [here](./Intro.md)).
@@ -23,27 +24,21 @@ it does not need to override any of these functions, as LVGL can also handle tou
2324
If you have any doubts, you can always look at how the other apps are doing things.
2425

2526
### Continuous updating
26-
If your app needs to be updated continuously, yo can do so by overriding the `Refresh()` function in your class
27+
If your app needs to be updated continuously, you can do so by overriding the `Refresh()` function in your class
2728
and calling `lv_task_create` inside the constructor.
28-
An example call could look like this: <br>
29-
`taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);` <br>
30-
With `taskRefresh` being a member variable of your class and of type `lv_task_t*`.
31-
Remember to delete the task again using `lv_task_del`.
32-
The function `RefreshTaskCallback` is inherited from screen and just calls your `Refresh` function.
3329

34-
### Apps with multiple screens
35-
InfiniTime provides a mini-library in [displayapp/screens/ScreenList.h](/src/displayapp/screens/ScreenList.h)
36-
which makes it relatively easy to add multiple screens to your app.
37-
To use it, #include it in the header file of your app and add a ScreenList member to your class.
38-
The template argument should be the number of screens you need.
39-
You will also need to add `CreateScreen` functions that return `std::unique_ptr<Screen>`
40-
to your class, one for every screen you have.
41-
There are still some things left to to that I won't cover here.
42-
To figure them out, have a look at the "apps" ApplicationList, Settings and SystemInfo.
30+
An example call could look like this:
31+
```cpp
32+
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
33+
```
4334

35+
With `taskRefresh` being a member variable of your class and of type `lv_task_t*`.
36+
Remember to delete the task again using `lv_task_del`.
37+
The function `RefreshTaskCallback` is inherited from `Screen` and just calls your `Refresh` function.
4438

4539
## Creating your own app
46-
A minimal app could look like this: <br>
40+
A minimal app could look like this:
41+
4742
MyApp.h:
4843
```cpp
4944
#pragma once
@@ -66,13 +61,13 @@ namespace Pinetime {
6661
6762
MyApp.cpp:
6863
```cpp
69-
#include "MyApp.h"
64+
#include "displayapp/screens/MyApp.h"
7065
#include "displayapp/DisplayApp.h"
7166
7267
using namespace Pinetime::Applications::Screens;
7368
7469
MyApp::MyApp(DisplayApp* app) : Screen(app) {
75-
lv_obj_t* title = lv_label_create(lv_scr_act(), NULL);
70+
lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr);
7671
lv_label_set_text_static(title, "My test application");
7772
lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
7873
lv_obj_align(title, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
@@ -95,12 +90,10 @@ Now, go to the function `DisplayApp::LoadApp` and add another case to the switch
9590
The case will be the id you gave your app earlier.
9691
If your app needs any additional arguments, this is the place to pass them.
9792

98-
If you want your app to be launched from the regular app launcher, go to [displayapp/screens/ApplicationList.cpp](/src/displayapp/screens/ApplicationList.cpp).
99-
Add your app to one of the `CreateScreen` functions, or add another `CreateScreen` function if there are no empty spaces for your app. <br>
100-
If your app is a setting, do the same procedure in [displayapp/screens/settings/Settings.cpp](/src/displayapp/screens/settings/Settings.cpp).
93+
If you want to add your app in the app launcher, add your app in [displayapp/screens/ApplicationList.cpp](/src/displayapp/screens/ApplicationList.cpp) to one of the `CreateScreen` functions, or add another `CreateScreen` function if there are no empty spaces for your app. If your app is a setting, do the same procedure in [displayapp/screens/settings/Settings.cpp](/src/displayapp/screens/settings/Settings.cpp).
10194

10295
You should now be able to [build](../buildAndProgram.md) the firmware
10396
and flash it to your PineTime. Yay!
10497

10598
Please remember to pay attention to the [UI guidelines](../ui_guidelines.md)
106-
when designing an app that you want to include in mainstream InfiniTime.
99+
when designing an app that you want to be included in InfiniTime.

doc/code/Intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Both functions are located inside [systemtask/SystemTask.cpp](/src/systemtask/Sy
2121
It also starts the **task "displayapp"**, which is responsible for launching and running apps, controlling the screen and handling touch events (or forwarding them to the active app).
2222
You can find the "displayapp" task inside [displayapp/DisplayApp.cpp](/src/displayapp/DisplayApp.cpp).
2323
There are also other tasks that are responsible for Bluetooth ("ll" and "ble" inside [libs/mynewt-nimble/porting/npl/freertos/src/nimble_port_freertos.c](/src/libs/mynewt-nimble/porting/npl/freertos/src/nimble_port_freertos.c))
24-
and periodic tasks like heartrate measurements ([heartratetask/HeartRateTask.cpp](/src/heartratetask/HeartRateTask.cpp)). <br>
24+
and periodic tasks like heartrate measurements ([heartratetask/HeartRateTask.cpp](/src/heartratetask/HeartRateTask.cpp)).
2525
While it is possible for you to create your own task when you need it, it is recommended to just add functionality to `SystemTask::Work()` if possible.
2626
If you absolutely need to create another task, try to guess how much [stack space](https://www.freertos.org/FAQMem.html#StackSize) (in words/4-byte packets)
2727
it will need instead of just typing in a large-ish number.

0 commit comments

Comments
 (0)