How to change a "Label" (or other) when Bluetooth is activated?

Hey !
I create an app to control my robot with Arduino. This is how I do it:

  • First, when the program starts, I test if the Bluetooth is activated on the smartphone, if it is, I display in my label "Activé"(activated). If the bluetooth is not activated, I display "Désactivé" (Not activated).
  • Then, if the bluetooth is not activated, the user can activate it from a button (KIO4_Bluetooth extension). I would then like the label change to "Activé" (activated) at that point (or when the user activates it while the application is running).

That's the problem, I don't know how to make the app continuously detect if the bluetooth is activated or not.

Thanks a lot.
DeepL Traduction helps me to translate because I'm french.
TheAlistairs

Dear @TheAlistairs,
I suppose you need to fire a clock with an appropriate tick (1000 ms for example) and when it fires you can check whether the BT is activated or not, Like you do in you screen1.initialize.
What are you thought on it ?
Meilleures salutations.
(et bonne chance :slight_smile: )

2 Likes

@TheAlistairs I'd rather use initialization blocks like this:

But I can be wrong.
Note that I also change the color of the text on the label.

1 Like

Merci uskiara ! J'imagine que je peux te parler en français puisque ta réponse est en partie en français. Je pense que c'est la solution à mon problème mais je débute sur le site et je ne sais pas comment mettre une horloge avec un "tick". Peux-tu me donner une piste ? Merci de ton aide.

Salut @TheAlistairs,
je suis Italien, mai je parle Français un petit (très petit) peu :smirk: .
Donc, si tu veux mettre un horloge, tu dois le mettre sur la page du dessin: il est un composant de la section des "sensors" (capteurs?), puis sur la page des blocks tu dois mettre les actions dans le block du "tick".
En pièce jointe tu peux trouver un fichier .aia avec un très simple example: juste une etiquette qui change de couleur chaque second. Je l'ai essayé sur mon phone et il marche. J'espère qu'il puisse t'aider. Si non, n'hexite pas à écrire encore.
Encore bonne chance !!!
:hugs:
Ugo.
Alistairs.aia (2.1 KB)

1 Like

J'essaye ça et je te tiens au courant.

J'ai réussi. Merci encore ! :heart:

Très bien!!!
Maintenant tu est pret pour etre un "master" di AI2...
A+
Ugo

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.