Background changing without user input

Former Member
Former Member
I have following problem.

In my datafield I support changing the background.

I used following code.

var bkgndColor = Ui.DataField.getBackgroundColor();

if( bkgndColor == Gfx.COLOR_BLACK) {
// Set black background
}
else
{
// Set white background
}


The Problem I have is that i have seen on my fenix3 that the color of the background was changed automatically without any user input.

From black to white .. to black ... and so on ...

Does anybody also have this problem? Is there an other way to read the the backgroundcolor?

Thanks and best regards,
ROland
  • When is it changing? I don't know about the f3, but on some devices the background will change based on sunrise/sunset (white during the day, black at night), and on some devices, the user can pick a white or black background for the DF's.
  • Former Member
    Former Member over 8 years ago
    It´s changing during the day without any context with the daytime.
  • It might be worth posting the actual code your running (the beginning of onUpdate() ? )
  • Former Member
    Former Member over 8 years ago
    Does anybody know how to implement writing a file out from a datafield? My idea is to create a logfile for debugging when it changes the color (date, time, value) .
  • Former Member
    Former Member over 8 years ago
    This is the code after onUpdate(dc).

    function onUpdate(dc) {
    var centerX = dc.getWidth() / 2;
    var centerY = dc.getHeight() / 2;

    // Define Layout
    // ....
    var bkgndColor = Ui.DataField.getBackgroundColor();

    if( bkgndColor == Gfx.COLOR_BLACK) {
    colorFontForegroundTop = Gfx.COLOR_BLACK;
    colorFontForegroundMain = Gfx.COLOR_WHITE;
    colorBackgroundTop = Gfx.COLOR_BLACK;
    colorBackgroundMain = Gfx.COLOR_WHITE;
    }
    else
    {
    colorFontForegroundTop = Gfx.COLOR_WHITE;
    colorFontForegroundMain = Gfx.COLOR_BLACK;
    colorBackgroundTop = Gfx.COLOR_WHITE;
    colorBackgroundMain = Gfx.COLOR_BLACK;
    }

    // Set the background color
    dc.setColor(colorBackgroundMain, colorBackgroundMain);
    dc.clear();

    dc.setColor( colorBackgroundTop, Gfx.COLOR_TRANSPARENT );
    // ...


    Thanks for your support!
  • Does anybody know how to implement writing a file out from a datafield? My idea is to create a logfile for debugging when it changes the color (date, time, value) .


    In \garmin\apps\logs create a file called <myprg>.txt, where your DF is called <myprg>.prg

    Then use Sys.println() to write what you want.
  • Former Member
    Former Member over 8 years ago
    The logic of your code is such that no matter what the background color is set as it will be changed to its opposite. Is that really your intended behavior? I question because you say you support changing the background color, whereas to me it looks like you enforce changing the background color.
  • Former Member
    Former Member over 8 years ago
    Sorry, maybe the title is confusing a little bit.

    What happens:
    Once starting the app the background is defined as BLACK.
    Some time later it will change to WHITE .. and back to BLACK, without any user action.

    This behavior is not implemented in the code.

    I implemented a logging and run the app for some hours. What i observed beside the normal work is, that it happend again. I will check it late afternoon
  • Former Member
    Former Member over 8 years ago
    Below is the information of the logging of the changes of the background value. There was no manual change.

    27.06-07:44:18;WHITE
    27.06-07:44:49;BLACK
    27.06-07:58:19;WHITE
    27.06-07:58:50;BLACK
    27.06-08:01:25;WHITE
    27.06-08:02:22;BLACK
    27.06-08:07:37;WHITE
    27.06-08:08:08;BLACK
    27.06-08:39:41;WHITE
    27.06-08:40:12;BLACK
    27.06-08:55:03;WHITE
    27.06-08:55:34;BLACK
    27.06-09:18:15;WHITE
    27.06-09:18:46;BLACK
    27.06-09:31:16;WHITE
    27.06-09:31:47;BLACK


    Versioninformation:
    fenix 3
    FW Version: 7.20

    Has anybody else observed such a behavior?