Drawstring ( true) not clearing the background

Posted on
  • For some reason with the font "Vector" the drawString command like

    drawString(txt, 130, 120, true);
    

    it's not clearing the background. It's just a simple clock and I don't want to use g.clear as it flickers the screen every second.

    Thanks for the help

  • Yeah, that's a known limitation.

    If you use g.clearRect to clear just the affected area before calling drawString the flicker shouldn't be too noticeable.

  • I tried that, but it's noticeable... And I wonder why on the DigiClock app, it seems to work fine.

  • Is there any other code between the call to g.clearRect and the call to g.drawString?

  • setFont and setFontAlign only.

    My concern is finding why

    require("Font7x11Numeric7Seg").add(Graph­ics);
    

    is giving me an error Module Font7x11Numeric7Seg not found.

    The first time I tried the clock tutorial, it worked, but now throws error. Downloaded app digiClock works, however.

  • Yes, not clearing behind for Vector fonts is expected right now. I'll get a fix in for the 2v11 version though.

    Module Font7x11Numeric7Seg not found.

    Are you pasting into the left-hand side of the IDE? If a module isn't built in the IDE loads it dynamically, but it can only do that for code that you load from the right-hand side.

  • No, I'm uploading the code directly from the storage icon. That was my mistake.
    Thanks Gordon

  • Ahh, right - yes, once files are in the app loader (or using the RHS of the IDE) then any dependencies are automatically handled.

    I've heard of others uploading using the Storage icon - did you see a suggestion for that somewhere? I guess potentially the IDE could provide the option to parse JS files that are uploaded that way as well...

  • I feel using the icon a faster method because many of us prefer to edit code with an external editor, that's my suggestion. But it's great as it is.

  • many of us prefer to edit code with an external editor

    As I recently discovered: the arrow below "open file" has a "Watch and upload" option, which actually works pretty nice with external editors. (as long as you only work on a single file)

  • Thanks.
    Still trying to understand why this gives unknown font on my code

    Modules.addCached("Font7x11Numeric7Seg",­function(){exports.add=function(a){a.pro­totype.setFont7x11Numeric7Seg=function()­{this.setFontCustom(atob("AAAAAAAAAAAAAA­EAAAAQAgBACAAAAHvQBgDAGAL3gAAAAAAAAAAHvA­AA9CGEMIYQvAAAACEMIYQwhe8AB4AIAQAgBA94AD­wIQwhhDCEDwAHvQhhDCGEIHgAAAgBACAEAHvAAe9­CGEMIYQveAA8CEMIYQwhe8AAABjDGAAAA96EEIIQ­Qge8AB7wIQQghBCB4AD3oAwBgDAEAAAAPAhBCCEE­L3gAPehDCGEMIQAAAe9CCEEIIQAAAAAAAA"),32,­atob("BwAAAAAAAAAAAAAAAAcCAAcHBwcHBwcHBw­cFAAAAAAAABwcHBwcH"),11)}}}); 
    // Load fonts 
    require("Font7x11Numeric7Seg").add(Graph­ics); 
    Bangle.setLCDTimeout(40); 
     
    function myFunction(txt) {   
      g.reset(); 
      g.setFont("Font7x11Numeric7Seg",4);   
      g.setFontAlign(0,0);  
      g.drawString(txt, 130, 120, true); 
    } 
     
    g.clear(); 
     
    myFunction("12:20");
    
  • Can't see the mistake but solved by copying from draw() function.

    How to add a new clock to the "settings/select clock" menu?

  • You just need g.setFont("7x11Numeric7Seg",4); not g.setFont("Font7x11Numeric7Seg",4); :)

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

Drawstring ( true) not clearing the background

Posted by Avatar for mg @mg

Actions