How to develop an app?

Introduction to the TWatch builder portal
Post Reply
mchavez
Site Admin
Posts: 79
Joined: Tue Nov 10, 2020 12:12 am

How to develop an app?

Post by mchavez »

If you are a programmer and wants to develop a new app you must follow some simple rules.

Title and Description

To start, you must enter a title and a good description for the app. These allows users to know more about your app.

Code
All the apps are based in three methods: __show, __hide and __loop. Note the "__" before the name, its very important.

These are the details:
  • The __show method is called when the user selects the app. In this method the programmer must instanciate all the global objects needed by the app.
  • The __hide method is called when the user goes back to the menu. In this method the programmer must release all the resources allocated at the app start. Is a very important that all the memory allocated in the __show method is freed to prevent memory leaks
  • The __loop method is called on every processor cycle, like the loop in Arduino. It is used, for example, to update some elements
In the same way as the methods are named, all the global variables must start with the "__" prefix. This prevents to have variable names collisions with other users' projects.

This is a sample of code:

Code: Select all

lv_obj_t* __label1;

void __show() {
  __label1 = lv_label_create(lv_scr_act(), NULL);
  lv_label_set_text(__label1, "HELLO");
  lv_obj_set_style_local_text_color(__label1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
  lv_obj_align(__label1, NULL, LV_ALIGN_CENTER, 0, 0);
}

void __hide() {
  lv_obj_del(__label1);
}

void __loop() {
}
To build your app you must first save the code and the compile it with the editor buttons.

Configuration

The portal offers you four configuration switchs:
  • Clock. If checked, indicates that your app is a watchface and must be considered as a clock. These means that when the user selects it, is remembered that it is shown when the watch wakes up. If not checked, the app is not considered a clock and is not remembered when the watch is activated
  • Sleep. If checked, indicates that the app must "sleep" after a while (defined in "Settings"). If not checked, the app does not sleep
  • Shared. If checked, indicates that the app is shared with the community at the "Store". If not checked, then the app remains private
  • Enabled. If checked, indicates that the app is enabled and must be included when the user press the "Build all" button. If not checked, then the app is excluded from compilation
Note: The Shared and Enabled switchs are exclusives, an app can be shared even if it is not enabled

Icon

The app needs an 72x72 pixels PNG image as icon. This is showed at the Store

Keywords

To be found, you must enter some keywords that describe the main features of the app.

Happy coding !!
pie
Posts: 2
Joined: Sun Mar 14, 2021 10:17 am

Re: How to develop an app?

Post by pie »

Great. Thanks. I have tried to recreate the MQTT demo as a separate app, but the compilation gives an error message.
How can I fix that?

In file included from /var/www/twatchbuilder.com/public_html/tmp/F10521C65A340/source/MyWatch.ino:99:0:
/var/www/twatchbuilder.com/public_html/tmp/F10521C65A340/build/sketch/Apps.h:45:1: sorry, unimplemented: non-trivial designated initializers not supported
};
^
/var/www/twatchbuilder.com/public_html/tmp/F10521C65A340/build/sketch/Apps.h:45:1: sorry, unimplemented: non-trivial designated initializers not supported
mchavez
Site Admin
Posts: 79
Joined: Tue Nov 10, 2020 12:12 am

Re: How to develop an app?

Post by mchavez »

Hi,

This error means that you do not have an icon defined in your application. To resolve, add a 72x72 PNG icon file in the "Settings" section of your application, then compile it again
pie
Posts: 2
Joined: Sun Mar 14, 2021 10:17 am

Re: How to develop an app?

Post by pie »

That works. Thanks.
I thought I had done so, but apparently I had not saved that before the compile.

I am now trying to change the colors, so I can actually read the messages...
Post Reply