Updated: Making a WatchFace for my Garmin 945

I wanted a clean watch face with a font of my liking and the date and battery status in the format I use in day to day life, still have to figure out some bugs (features?!) to make it better.

I removed the seconds, however you can add a function onPartialUpdate(dc) for an update every second but to keep the updates to a minimum I removed it.

WhatsApp Image 2019-06-13 at 09.59.38

Here is the code in case any one would like to have a look.

//navtaz 2019.06.14 Consolas basic watchface


using Toybox.WatchUi as Ui;
using Toybox.Graphics as Gfx;
using Toybox.System as Sys;
using Toybox.Lang as Lang;
using Toybox.Application as App;
using Toybox.Time as Tim;
using Toybox.Time.Gregorian as Gre;

class watchface_10View extends Ui.WatchFace {

   function initialize() {
        WatchFace.initialize();
    }

	var roboto95 = null;
 	var roboto30 = null;
 
  	function onLayout(dc) {
		roboto95  = Ui.loadResource(Rez.Fonts.roboto95);
		roboto30 = Ui.loadResource(Rez.Fonts.roboto30);
	}
 
 	function onUpdate(dc) {
        
        dc.setColor (Gfx.COLOR_BLACK, Gfx.COLOR_BLACK);
        dc.clear();

 //date
   	var today_MED = Gre.info(Tim.now(), Tim.FORMAT_MEDIUM);
   	var dateString = Lang.format("$1$ $2$ $3$",[today_MED.day_of_week, today_MED.day.format("%02d"), today_MED.month]);
   	var clockTime = System.getClockTime();
 	
 //battery  
	var myBatt = Sys.getSystemStats().battery;
	var battstring = Lang.format(" $1$$2$", [myBatt.format("%02d"),"%"]);

 //time
	var hour = clockTime.hour;
	 	if (!Sys.getDeviceSettings().is24Hour){
	 		hour = hour % 12;
	 		if (hour == 0){
	 			hour = 12;
	 		}
	 	}
   
    var hourdig = hour.format("%02d");
    var mindig = clockTime.min.format("%02d");
    var timeString = Lang.format("$1$$2$", [hourdig.toString(), mindig.toString()]);
    
 //print time
  		
 		dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_BLACK);
 		dc.drawText(dc.getWidth()/2, 29, roboto30, dateString, Gfx.TEXT_JUSTIFY_CENTER);
 		
		dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_BLACK);
 		dc.drawText(dc.getWidth()/2, 61, roboto95,timeString , Gfx.TEXT_JUSTIFY_CENTER);

       	dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_BLACK);
 		dc.drawText(dc.getWidth()/2, 183, roboto30,battstring , Gfx.TEXT_JUSTIFY_CENTER);
        
    }
 
    function onShow() {
    }

    function onHide() {
    }

    function onExitSleep() {
    }

    function onEnterSleep() {
    }

}

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s