WatchFace with use of bottons

Former Member
Former Member
Hi everybody,

I would like to do a WatchFace using the bottons of the Fenix3 to change between the diferentes data of the device without going out of the WatchFace, and use the Chronograph no the WatchFace using bottons of the Fenix3. Is it possible?

Thanks for all and your help
  • No, this is not possible as watch faces cannot respond to user input. You could easily do this with an app though.
  • Former Member
    Former Member over 8 years ago
    No, this is not possible as watch faces cannot respond to user input. You could easily do this with an app though.


    And Which is the code to use the bottons with an app?

    Thanks for all and your help
  • You can look at the "keyboard" sample in the SDK "samples" directory.
  • Former Member
    Former Member over 8 years ago
    You can look at the "keyboard" sample in the SDK "samples" directory.


    Ok, thanks for your help. I'll look that sample for my app.
  • Former Member
    Former Member over 8 years ago
    And Which is the code to use the bottons with an app?

    Thanks for all and your help


    Could you mix a WatchFace and an app?

    Thanks for all and your help
  • I'm just going over this for clarity since the terminology is weird here... Disregard if you already know about this. Everything that you build with ConnectIQ is an app. There are several different types of app that Garmin calls out; Data Field, Watch Face, Watch App, and Widget. So, a Watch Face is already an app, but it isn't a Watch App. Does that make sense?

    It sounds like you want something that looks like a Watch Face, but isn't subject to the restrictions of a Watch Face (you want access to user input). You can do this pretty easily. I believe Jim has done this in the past, and I've got a template for doing it...

    using Toybox.Application as App;
    using Toybox.Graphics as Gfx;
    using Toybox.WatchUi as Ui;
    using Toybox.System as Sys;

    class MyWatchFaceDelegate extends Ui.BehaviorDelegate
    {
    hidden var _view;
    hidden var _timer;

    function initialize(view) {
    BehaviorDelegate.initialize();
    _view = view;

    // allocate a timer
    _timer = new Timer.Timer();

    // pretend a key was just pressed
    onExitSleep();
    }


    function onKey(evt) {
    onExitSleep();
    return false;
    }

    function onTap(evt) {
    onExitSleep();
    return false;
    }

    hidden var _counter;

    function onAwakeTimer() {
    Ui.requestUpdate();

    _counter += 1;
    if (_counter == 10) {
    onEnterSleep();
    }
    }

    function onSleepTimer() {
    Ui.requestUpdate();
    }

    hidden function onEnterSleep() {
    _view.onEnterSleep();
    Ui.requestUpdate();

    _counter = 0;

    _timer.stop();
    _timer.start(method(:onSleepTimer), 60000, true);
    }

    hidden function onExitSleep() {
    _view.onExitSleep();
    Ui.requestUpdate();

    _counter = 0;

    _timer.stop();
    _timer.start(method(:onAwakeTimer), 1000, true);
    }
    }

    class MyWatchFace extends Ui.View
    {
    hidden var _sleeping;

    function initialize() {
    View.initialize();
    _sleeping = true;
    }

    function onEnterSleep() {
    _sleeping = true;
    }

    function onExitSleep() {
    _sleeping = false;
    }

    function onUpdate(dc) {
    dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_BLACK);
    dc.clear();

    var clock = Sys.getClockTime();
    var h = clock.hour;
    var m = clock.min.format("%02d");
    var s = clock.sec.format("%02d");

    var deviceSettings = Sys.getDeviceSettings();
    if (deviceSettings.is24Hour) {
    h = h.format("%02d");
    }
    else {
    h = (1 + (h + 11) % 12).format("%d");
    }

    var fmt;
    if (_sleeping) {
    fmt = "$1$:$2$";
    }
    else {
    fmt = "$1$:$2$:$3$";
    }

    var cx = dc.getWidth() / 2;
    var cy = dc.getHeight() / 2;

    dc.drawText(cx, cy, Gfx.FONT_LARGE, Lang.format(fmt, [ h, m, s ]),
    Gfx.TEXT_JUSTIFY_CENTER | Gfx.TEXT_JUSTIFY_CENTER);
    }
    }

    class MyApp extends App.AppBase
    {
    function initialize() {
    AppBase.initialize();
    }

    function getInitialView() {
    var view = new MyWatchFace();
    var delegate = new MyWatchFaceDelegate(view);

    return [ view, delegate ];
    }
    }
  • Former Member
    Former Member over 8 years ago
    WacthFace without limitations

    I'm just going over this for clarity since the terminology is weird here... Disregard if you already know about this. Everything that you build with ConnectIQ is an app. There are several different types of app that Garmin calls out; Data Field, Watch Face, Watch App, and Widget. So, a Watch Face is already an app, but it isn't a Watch App. Does that make sense?

    It sounds like you want something that looks like a Watch Face, but isn't subject to the restrictions of a Watch Face (you want access to user input). You can do this pretty easily. I believe Jim has done this in the past, and I've got a template for doing it...

    using Toybox.Application as App;
    using Toybox.Graphics as Gfx;
    using Toybox.WatchUi as Ui;
    using Toybox.System as Sys;

    class MyWatchFaceDelegate extends Ui.BehaviorDelegate
    {
    hidden var _view;
    hidden var _timer;

    function initialize(view) {
    BehaviorDelegate.initialize();
    _view = view;

    // allocate a timer
    _timer = new Timer.Timer();

    // pretend a key was just pressed
    onExitSleep();
    }


    function onKey(evt) {
    onExitSleep();
    return false;
    }

    function onTap(evt) {
    onExitSleep();
    return false;
    }

    hidden var _counter;

    function onAwakeTimer() {
    Ui.requestUpdate();

    _counter += 1;
    if (_counter == 10) {
    onEnterSleep();
    }
    }

    function onSleepTimer() {
    Ui.requestUpdate();
    }

    hidden function onEnterSleep() {
    _view.onEnterSleep();
    Ui.requestUpdate();

    _counter = 0;

    _timer.stop();
    _timer.start(method(:onSleepTimer), 60000, true);
    }

    hidden function onExitSleep() {
    _view.onExitSleep();
    Ui.requestUpdate();

    _counter = 0;

    _timer.stop();
    _timer.start(method(:onAwakeTimer), 1000, true);
    }
    }

    class MyWatchFace extends Ui.View
    {
    hidden var _sleeping;

    function initialize() {
    View.initialize();
    _sleeping = true;
    }

    function onEnterSleep() {
    _sleeping = true;
    }

    function onExitSleep() {
    _sleeping = false;
    }

    function onUpdate(dc) {
    dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_BLACK);
    dc.clear();

    var clock = Sys.getClockTime();
    var h = clock.hour;
    var m = clock.min.format("%02d");
    var s = clock.sec.format("%02d");

    var deviceSettings = Sys.getDeviceSettings();
    if (deviceSettings.is24Hour) {
    h = h.format("%02d");
    }
    else {
    h = (1 + (h + 11) % 12).format("%d");
    }

    var fmt;
    if (_sleeping) {
    fmt = "$1$:$2$";
    }
    else {
    fmt = "$1$:$2$:$3$";
    }

    var cx = dc.getWidth() / 2;
    var cy = dc.getHeight() / 2;

    dc.drawText(cx, cy, Gfx.FONT_LARGE, Lang.format(fmt, [ h, m, s ]),
    Gfx.TEXT_JUSTIFY_CENTER | Gfx.TEXT_JUSTIFY_CENTER);
    }
    }

    class MyApp extends App.AppBase
    {
    function initialize() {
    AppBase.initialize();
    }

    function getInitialView() {
    var view = new MyWatchFace();
    var delegate = new MyWatchFaceDelegate(view);

    return [ view, delegate ];
    }
    }


    I'm trying this code to do a watchFace and use the bottons of the Fenix3 to change the settings of the datas which the LCD shows, but I have now this error,

    Failed invoking <symbol>
    Permission Required
    in onEnterSleep (C:\connectiq\Breitling Exospace B-55\source\BreitlingExospaceB55View.mc:59)
    in onAwakeTimer (C:\connectiq\Breitling Exospace B-55\source\BreitlingExospaceB55View.mc:44)
    Error in timer callback
    Connection Finished
    Closing shell and port

    I need permission, which permission, How I can give permission to resolve that error and finish my WatchFace?

    Thanks for all and your help
  • 1) You can't use buttons/taps/swipes in a watchface. No Inputs at all.
    2) you can only have a timer running in a watchface after you get an onExitSleep() and before an onEnterSleep() in a watchface. These two function are called by the system when you exit and enter low-power mode. In lowPower mode, onUpdate() is called for you every minute, . When you're not in low power mode, every second. Watchfaces only drop out of low power mode for about 10 seconds, and it's triggered by a wrist turn gesture.