swissalpine / GARMIN-xDrip-Spike-Nightscout-Watchface

19 stars 2 forks source link

Understanding widget vs. watchface #9

Closed jeffdoge closed 1 year ago

jeffdoge commented 1 year ago

Hi,

First of all, thank you for all your awesome work in building out this integration. You are literally a lifesaver.

Question for you - how exactly do the widget/watchface work together? I'm using a Epix Pro 2 with a Google Pixel 7. I was using the widget and watchface to test the integration and sometimes I notice the watchface has not updated but the widget does, and sometimes vice versa. Typically the widget refreshes first, then I've noticed that the watchface may take upwards of 10 minutes to refresh.

I attached a photo of the widget being fresh but the watchface being stale.

PXL_20231115_030633602 MP PXL_20231115_030625419 MP

Secondly and unrelated, I notice often when I look at the widget it will give me "No medical use!" even though data was just fetched one minute ago. I noticed the official Dexcom widget persists the value with no issues. Is there any way to get that value to persist for the entirety of five minutes on the widget? Thank you!!!

swissalpine commented 1 year ago

Hi, first of all thank you very much for your generous invitation, now I can have a coffee every day for many days ... But that wasn't necessary! A few words about the background: Watchfaces can, according to a GARMIN limitation, query data at most every 5 minutes by means of a so-called background process. This not only determines the frequency, but also means that I have to let the watch face wait 10 minutes to get as close as possible to the time of measurement. Assuming the time of measurement was two minutes ago at the time of the query, I cannot query again after three minutes, but must query for more than 5 minutes, so the query is after 8 minutes. However, you can define a fixed interval in the settings without adjusting it to the time of measurement, in which case it will simply ask for new values every 5 minutes. Widgets do not have this restriction. A new query is possible here as soon as the old one has been completed. My frequency here is every 20 seconds, if I remember correctly, maybe every 30 seconds. When the Glance View is called, as in your photo, the query starts, which takes a few seconds (depending on the data source) before the answer is available. During this waiting time (for me this is about 1 second for an xDrip+ query) the message "No medical use" is displayed. Widgets (like watchfaces) can also query data every 5 minutes via a background process. If I implement this, a value would be available when called up, similar to the Dexcom widget. The disadvantage is that every background process consumes battery (not only on the watch, but also on the smartphone, because the watch sends the queries via the Garmin Connect mobile app). And I think this is unnecessary with the widget. Unlike the Dexcom widget, my widget does not consume any energy when it is not open. Unfortunately, different Connect IQ apps (widget and watch face in this case) cannot currently exchange data with each other or access the same memory.

With regard to the layout of the watch face, I will try to adapt it a little better to the Epix Pro.

Best regards Andreas

jeffdoge commented 1 year ago

Appreciate the thorough reply. That makes a lot of sense. Thank you, Andreas!

swissalpine commented 1 year ago

Layout update is uploaded. And: Thanks for coming back und your understanding!

swissalpine commented 1 year ago

Two more thoughts: The small clock icon in the watchface indicates that a query adjustment is now in progress and will take up to 10 minutes. Unlike the Dexcom widget, my widget can also display Libre 3 data. These are recorded in one-minute intervals. Here, a background process would also have the disadvantage that an outdated value (for Libre users) is initially displayed, which is then updated after a few seconds.

jeffdoge commented 1 year ago

Thank you for the new layout, it's looking great.

PXL_20231117_084538215 MP

I noticed something interesting and was wondering if you might have experienced anything similar. Today, data was refreshing fine all day, but all of a sudden, at 12:00AM, the watchface stopped updating data, and it just does not want to fetch data anymore. You can see this in the picture I took above. The widget also gets unreliable, but it did successfully fetch data at least a couple of times, other times giving me a -2 error. All the while Dexcom data is still coming through the official Dexcom widget.

I know there are a ton of variables, but the main clue for me is that this is coincidentally when Sleep Mode came on the Garmin. I was wondering if sleep mode somehow affects the widget/watchface to your knowledge? Or perhaps its something else. Either way, literally as I was typing this message data started successfully flowing again, so who knows? But wondering if you might have any thoughts. Thank you!!!

swissalpine commented 1 year ago

I've never seen this behaviour and heard about it. Error -2 is related to your Bluetooth connection: "We timed out waiting for a response from the host." https://developer.garmin.com/connect-iq/api-docs/Toybox/Communications.html II think it might not be a good idea to run both the dexcom widget and my clock in parallel, because they both use background processes that might get in each other's way. But that's just speculation, I don't know for sure.