Coordinate system moved after widgets were loaded

Posted on
  • Hi everyone,

    when i run into a error, that the coordinate system moved when i load the widegets with

    Bangle.loadWidgets()
    

    Before i run this line, i can draw a string at 0,0. If i run the same draw command after i loaded the widegts the string is moved to the top left out of the screen. Do you know what the problem could be?

    Here is an example code.

    g.clear();
    g.drawString("hi this is a long sentence", 0,0);
    Bangle.loadWidgets();
    g.drawString("hi this is a long sentence", 0,0);
    
    
  • Having you tried something like:

    g.clear();
    g.drawString("hi this is a long sentence", 0,0);
    Bangle.loadWidgets();
    Bangle.drawWidgets();
    g.drawString("hi this is a long sentence", 0,0);
    

    I see the text displayed in the same place regardless. I loaded the above code into RAM from the IDE.


    1 Attachment

    • download.png
  • I added the extra load between the drawString methods but with no success.

    I did some extra testing and i found out that it dose not happen for every widget. I had the widget "A Battery Widget (with percentage)" and it happend there after the redraw.
    It also happened with the widget "Calendar Widget", but it didn't occure witht the widgets "Battery Level Widget (Vertical)", "Battery Level Widget (with percentage)", "Battery Level Widget" or "Bluetooth ID Widget".

    However i mangaed to reproduce the same error with a simple

    E.showMessage()
    

    command.

    Here is the example code

    g.clear();
    
    
    g.drawString("hi this is a long sentence", 0,0);
    E.showMessage("This is a test");
    
    g.setFontVector(10);
    g.drawString("hi this is a long sentence", 0,0);
    

    I noticed there, that the font size of the text was changed to that of the shown message. But even if i set it to a lower one, it is still moved to the left.

  • Can you show a screenshot of what you see?

    Go to the IDE, type g.dump(); then ick on the image to download it.

  • Here is the screenshot of the screen


    2 Attachments

    • Download.png
    • bangle-screen.png
  • Lines 4 and 8 will draw in the same place, and it looks like they do.

    ShowMessage is different to drawstring.

    You might need to set the left alignment up.

  • The issue is you need to call g.reset() in your function before you start drawing (or even it's after calling some other code like drawWidgets) as the other code might have changed the way graphics was configured.

    Even if you were lucky and the font stayed the same, maybe the battery widget decided to update the battery and leaves the foreground colour as green :)

  • That solved the problem, thanks.

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

Coordinate system moved after widgets were loaded

Posted by Avatar for user148386 @user148386

Actions