how to set a local theme?

Posted on
  • Strange,

    according to the docs, I should be able to define a (local) theme using

      g.setTheme({ bg:'#00FF00' });
      g.clear(false); // to test the new theme
    

    but that does not seem to be respected. Indeed, none of the alternatives I tried had any effect:

      g.setTheme({ bg:'#0F0' });
    //  g.setTheme({ bg:'#00FF00' });
    //  g.setTheme({ bg:0x00FF00 });
    //  g.setTheme({ bg:g.toColor(0,1,0) });
      g.clear(false);
    

    What am I doing wrong?

  • See the example at the bottom of the waveclk.

    // Clear the screen once, at startup
    g.setTheme({bg:"#f0f",fg:"#fff",dark:tru­e}).clear();
    // draw immediately at first, queue update
    
  • I guess you refer to the line

    g.setTheme({bg:"#f0f",fg:"#fff",dark:tru­e}).clear();
    

    This is actually an variant I tried before - and it is not working!

    If background is globally set to green, f.e., it remains green even after that line!

    In order to give you some steps to reproduce the problem (in the REPL):

    Try

      let customTheme = {
        fg:g.toColor(0,0,0), fg2:g.toColor(0,0,1), fgH:g.toColor(0,0,0),
        bg:g.toColor(0,1,0), bg2:g.toColor(0,1,0), bgH:g.toColor(1,1,0)
      };
      let globalSettings = Object.assign(
        require('Storage').readJSON('setting.jso­n', true) || {},
        { theme:customTheme }
      );
      require('Storage').writeJSON('setting.js­on', globalSettings);
    

    first, then try

    g.setTheme({ bg:'#000' });
    g.clear(false);
    

    (tested on a real device with firmware 2v11)

  • Try g.setTheme({bg:"#f0f",fg:"#fff",dark:tru­e}).clear(1);? the 1/true parameter in clear resets the current fg/bg color of Graphics to the theme colour.

    That seems to work great for me - if I run it at the same time as the clock and wait, the clock will redraw in that color.

  • Damn...

    so my mistake was just to write g.clear(false) instead of g.clear(true) - good to know!

    Thank you very much!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

how to set a local theme?

Posted by Avatar for Andreas_Rozek @Andreas_Rozek

Actions