Bluetooth connectivity icon for connectivity on and for connectivity off

Hi, hope it will be the last question here for this watch. I want to make a Bluetooth connectivity update in watch face. I have icons ready for connection On and connection Off.

I looked for a similar questions in this forum but I didn't managed to find any so I tried to make this code by myself.

I thought of making something like 

if (Bluetooth connectivity is On)
{dc.drawBitmap(10, 130, BluetoothOn)
}else {dc.drawBitmap(10, 130, BluetoothOff)
}

but the problem is I don't know what I need to fit in the code that will do the work of "(Bluetooth connectivity is On)" in the monkey C language even after searching in the programmer's guide.

I hope my question was clear. It is the very last thing I want to add to complete the watch!

TY in advance everyone!


  • Unlike native apps / watch faces, you can't tell whether bluetooth connectivity is on or off, per se.

    You can only tell whether a phone is connected by bluetooth (which is subtly different.)

    https://developer.garmin.com/connect-iq/api-docs/Toybox/System/DeviceSettings.html#phoneConnected-var

    using Toybox.System;
    
    var mySettings = System.getDeviceSettings();
    var phone = mySettings.phoneConnected; // <=== true if phone is connected via bluetooth, false otherwise
    

  • Hi Flowstate ty for your answer. I understood your answer and I believe that telling whether a phone is connected by bluetooth or not is what I am looking for.  I understand that I can use the true or false situation to make an If statement like I want using Boolean (correct me if I am wrong here). What I didn't understand tough is how I will get a true or false answer from what you showed in 2 varients definitions here. Sorry if it is a dumb question it is just hard for me to understand how to reach the situation I am looking for from the code above.

    EDIT: I've checked about the lines you used and found an example to this use in https://github.com/antonioasaro/GARMIN-AMD_Watchface and I believe that it's what you have meant. he use those lines as following:

            var BTstatusBitmap;
            var devSettings = Sys.getDeviceSettings();
            if (devSettings.phoneConnected) { 
    	 		BTstatusBitmap = Ui.loadResource(Rez.Drawables.ConnectIcon);
            } else {
    	 		BTstatusBitmap = Ui.loadResource(Rez.Drawables.DisconnectIcon);
    	 	}
    	 	var btstatusView = View.findDrawableById("id_btstatus");
            dc.drawBitmap(btstatusView.locX, btstatusView.locY, BTstatusBitmap);

    I believe that it is what you meant and I didn't understand so ty! I'll try to use it in my project after doing some customization and will let you know!

  • Yup, that's what I meant. I only modified the example code on the linked document page to show which variable to use, I didn't show exactly how to use it. Sorry, my bad.

  • In general, phoneConnected doesn't handle all cases, like WiFi and LTE.

            var sSettings=System.getDeviceSettings();
            var hasConnectionAvail=(sSettings has :connectionAvailable);
        	var comm=(hasConnectionAvail) ? sSettings.connectionAvailable : sSettings.phoneConnected;

  • Another tip. is to use a custom font for icons, and not bitmaps.  For one thing, it makes it very easy to change the color of the icons. For example, based on the background color so things don't disappear.

    if(connected) {
        dc.setColor(iconOnColor,Graphics.COLOR_TRANSPARENT);
        dc.drawText(x,y,iconFont,"C",Graphics.TEXT_JUSTIFY_CENTER);
    } else {
        dc.setColor(iconOffColor,Graphics.COLOR_TRANSPARENT);
        dc.drawText(x,y,iconFont,"c",Graphics.TEXT_JUSTIFY_CENTER);
    }