Avatar for NebbishHacker

NebbishHacker

Member since Apr 2020 • Last active Jul 2020
  • 3 conversations
  • 61 comments

Most recent activity

  • in Bangle.js
    Avatar for NebbishHacker

    In theory you could avoid some of the memory overhead of the array returned by match() by instead using replace to generate a new string that contains only the newlines:

    s.replace(/[^\n]/g, "").length
    

    Unfortunately, there seems to be a bug in replace() that prevents this from working perfectly.

  • in Bangle.js
    Avatar for NebbishHacker

    only way to disconnect it is with a wire cutter

    At that point you might as well just open it up and take out the battery :)

  • in Bangle.js
    Avatar for NebbishHacker

    I'm surprised that the weather widget makes that much of a difference. It doesn't do any active polling or anything, it just passively waits for your phone to send it weather events.

    @user112504: There are instructions for fixing the API key issue at https://github.com/gelin/weather-notific­ation/wiki/FAQ

  • in Bangle.js
    Avatar for NebbishHacker

    One approach to making sure you clear the right area would be to take advantage of g.getModified:

    g.getModified(true); // Reset modified area
    // Insert whatever draw calls you want here
    g.drawString(...);
    let m = g.getModified(); // Save modified area for later
    
    g.clearRect(m.x1, m.y1, m.x2, m.y2); // Will clear the precise area affected by the above draw calls
    
  • in Bangle.js
    Avatar for NebbishHacker

    If you look closely the B and the C are touching at one point, so even the 1 pixel space is not always there.

    In any case, I imagine you would generally want a bit more space between lines than that.

  • in Bangle.js
    Avatar for NebbishHacker

    @gerardwr - That looks like a good solution to me, although I would have personally made an entirely new function named drawLines or something instead of overriding g.drawString.

  • in Bangle.js
    Avatar for NebbishHacker

    So for reference: I flashed 2v05.1 onto a watch for comparison, and it looks like the old vector font exhibited the same issue with descenders overlapping the next line.

  • in Bangle.js
    Avatar for NebbishHacker

    Currently the font size accurately represents the height of letters like A, but it doesn't take into account accented characters (like À) or descenders (like j). Accents and descenders both currently protrude by about 1/4 of the font height, so the actual maximum height of a line of text is 1.5 times what you might expect.

    For some stuff I'm currently working on it would be convenient if g.clearRect(x, y, x+g.stringWidth(text), y+g.getFontHeight()) was always guaranteed to cover a single line drawn via g.drawString(text), which isn't currently the case.

    Overall, though, I don't have very strong feelings about whether we should tweak the font size.

  • in Bangle.js
    Avatar for NebbishHacker

    Modules can come from a number of different places, including storage: https://www.espruino.com/Modules#from-st­orage

  • in Bangle.js
    Avatar for NebbishHacker

    You could remove one layer of function nesting by making each face a module.

    Each face would then follow the format

    exports.getFace = function (){
        function onSecond(){
           //draw digits, hands etc
        }
        function drawAll(){
           //draw background + initial state of digits, hands etc
        }
        return {init:drawAll, tick:onSecond};
    };
    

    And to load them you'd do something along the lines of

    let FACES = require("Storage").list(/\.face\.js$/).m­ap(require);
    
Actions