Klaus3d3 / XdripWidgetForAmazfit-Klaus

Springboard Widget to show blood glucose levels provided by xDrip+
20 stars 23 forks source link

Watchface #7

Open GreatApo opened 6 years ago

GreatApo commented 6 years ago

This project can also include a watchface.

The data must be saved in a system value (and be updated) and then the watchface can show them. The only problem is the update interval (the locked screen updates in specific cases). A work around could be updating the watchface every time calories,heart rate or weather is updated...

Klaus3d3 commented 6 years ago

Thats good to hear. Sadly beside copying all files from your Greatfit Watchface into my project, i don't know where to start.

GreatApo commented 6 years ago

I am already working on the documentation...

If you want to experiment a little, edit the following file, this is where AM/PM is shown (wifi/BT status are in development too): java/com/dinodevs/greatfitwatchface/widget/GreatWidget.java

"init" runs once when the watchface is selected and then screen-on is constantly refreshed through the "draw" function. On the other hand, screen-off is made through "buildSlptViewComponent". Data are refreshed in "onDataUpdate" (when screen is on "draw" is constantly refreshed but when screen is off the refresh is not constant).

There are 2 ways to show your data. You either save them through your widget somewhere (for example in Settings.System, if possible and then you load them like on line 63) and you just get them and show them OR you directly connect to your phone through the watchface (like your widget does). I recomend the first option.

So, you somehow get the data you want to display in a variable and then in "draw" function you just draw them on the canvas, ex:

canvas.drawText("my data", 10, 10, textPaint); //numbers are left and top positions, leave textPaint or define a new font-size etc

In order for your data to be updated, you have to re-save the new data (if any) in the variable they are saved through "onDataUpdate" function.

Screen off is a little more complicated. Start with the screen-on and i can help you then with the locked screen.

Klaus3d3 commented 6 years ago

Ha, even copying your files seems to be very complicate :-(

Klaus3d3 commented 6 years ago

atm i'm trying to write and read from settings