No line spacing when using drawline

Posted on
Page
of 2
Prev
/ 2
  • BTW, I expected that g.getModified(true) would reset to "no area" like
    { "x1": 0, "y1": 0, "x2": 0, "y2": 0 }
    but is resets to "full screen" like
    { "x1": 0, "y1": 0, "x2": 239, "y2": 239 }

  • With framebuffer in memory created by Graphics.createArrayBuffer the behaviour is that after resetting it returns undefined until you draw something, which makes sense.

    With display this is used so that in g.flip() implementation you know which area is modified and must be send to the display.

  • If thought that it would have been more logical that g.getModified(true); would indicate "nothing needs to be modified". In the current implementation I feel it indicates "the entire screen needs to be modified.

    Just my opinion.

  • unless you call g.clear() or clearRect for whole screen it is indeed strange to get whole screen. just note that with true parameter it still returns modified region bu then clears it so with next call you should get undefined. The idea is that you call it with true if it is the last time you are interested in that region so next time it will be empty. you call it with false if you are just interested in current state but won't do any action (like sending it to display) so it is still modified

  • @fanoush

    I've been working with Espruino for Bangle now for some days. Javascript a an "experience" after many years of Arduino ;-)

    Must say that Gordon has created a terrific environment with Espruino, excellent documentation and a fantastic development platform on the BangleJS. Kudo's to him.

    After the limited 1-week experience with Espruino I love the environment for prototyping. The "nasties" I experience(like with getModified" are limited, and I can live with them.

    The fun is in the "learning", right?

  • @gerardwr, glad to hear that. In deed, it IS an experience... quite different from what MCs were for decades. Having started out with MPs 8085/Z80/Z80/6502/68XX/68K and briefly (now defunct) Ubicon SX for control I liked very much the advent of Arduino, but before I really sunk my teeth into it, I came across Espruino and in less than a blink of an eye I dropped my H and $ investment in Arduino and moved on with Espruino. For certain things though I ran into limits, some of which can be overcome using compiled JS and inline C, and some other that require really dedicated, low level coded hardware is needed to do time sensitive things with strict tolerances, repetitive and over a longer time. For those things dedicated atTiny versions do just fine that receive commands from Espruino and return interrupts / values. For most part though I can stay in JS layer. And that makes it really fun.

  • @allObjects - Ok, off-topic.

    We seem to have a similar 'senior' background, I started decades ago with the Intel's like 8080/Z80,80x86 then moved to AVR-Arduino, in the last years ESP8266/ESp32.

    Really love the ESP's for their Wifi connection. It runs Arduino, Micropython and Espruino. Nothing else needed........ EXCEPT for wearables... they're power hungry beasts

    Just for fun I bought an NRF52832 development board to dable with BLE. Tried Arduino (works fine), Micropython (so,so) and Espruino.

    Was to lazy to solder a TFT display tot the NRF52832 so I'm using Bangle now. Considering my background Javascript is little "quirky" but the help from the forum I'm getting there. Also great info on NRF52832 on gitter here if you're interested in the hard-core details : https://gitter.im/nRF51822-Arduino-Mbed-­smart-watch/Lobby

    There's 1 thing I miss in Bangle/Espruino : a Wifi connection!! My Bangle App is "done" but it needs feeding data from the internet. So I'm testing tools on Raspberry that function as a bridge between the internet and the Bangle. Exciting timings :-)

    All in all, @Gordon is doing a tremendous job!

    Cheers, see you!

  • @gerardwr can you come up with some code that causes the getModified(true) issue in the emulator and post it here? https://www.espruino.com/ide/emulator.ht­ml

    Seems to work great for me:

    >g.getModified(true)
    ={ x1: 0, y1: 0, x2: 239, y2: 239 }
    >g.getModified(true)
    =undefined
    >g.drawString("Hello")
    =Graphics: {
      flip: function () { [native code] }
     }
    >g.getModified(true)
    ={ x1: 0, y1: 0, x2: 28, y2: 6 }
    >g.getModified(true)
    =undefined
    >g.clear()
    =Graphics: {
      flip: function () { [native code] }
     }
    >g.getModified(true)
    ={ x1: 0, y1: 0, x2: 239, y2: 239 }
    >g.getModified(true)
    =undefined
    
  • Hi @Gordon, thanks for getting back to me.

    Yes, your example works fine, as intended:

    • reset the getModified
    • draw something
    • the getModified defines the "touched" area.

    But ........ I have an App where sometimes (depending on the code) there is no drawing done, when I clear the getModified area, it blanks the screen, and that's not what I want.

    I thought it would be more applicable if getModified(true) would be set to "nothing is modified, so nothing needs to be cleared" { x1: 0, y1: 0, x2: 0, y2: 0}. Or ....... it would be set to undefined, that's logical to me too.

    I don't get the logic for resetting to the entire screen, am I missing something?

  • I thought it would be more applicable if getModified(true) would be set to "nothing is modified, so nothing needs to be cleared" { x1: 0, y1: 0, x2: 0, y2: 0}. Or ....... it would be set to undefined, that's logical to me too.

    It is... It is set to undefined.

    It would be clearer for me if you gave an example of what isn't working as you expect.

    As @fanoush said, most likely what's happening is you're clearing the whole screen with g.clear() as in my example above. As expected that changes the contents of the whole screen, so you see { x1: 0, y1: 0, x2: 239, y2: 239 }

    I guess it's possible that g.reset() resets the modified area too, which might be tripping you up?

  • Hmmmmmm, major error on my part :-(

    My code from the emulator:

    g.clear();
    
    // fill screen with green
    g.setColor(0,1,0);  // green
    g.fillRect(0,0,239,239);
    
    // reset getModified area
    m=g.getModified(true);
    
    print(m);
    
    g.setColor(1,0,0);  // red
    
    // g.fillRect(100,100,120,120);
    
    m=g.getModified();
    
    print(m);
    
    g.clearRect(m.x1,m.y1,m.x2,m.y2);
    

    Output is:

    >{ "x1": 0, "y1": 0, "x2": 239, "y2": 239 }
    >undefined
    >Uncaught Error: Cannot read property 'x1' of undefined
     at line 20 col 14
    g.clearRect(m.x1,m.y1,m.x2,m.y2);
                 ^
    >
    

    I see now dat getModified(true) returns an undefined. I was completely mislead by the response >{ "x1": 0, "y1": 0, "x2": 239, "y2": 239 } and assumed that this was the area that was set.

    Apologies for wasting your time (red face), appreciate the help.

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

No line spacing when using drawline

Posted by Avatar for gerardwr @gerardwr

Actions