Pixl LCD initialisation and output

Posted on
  • After quite a while of Espruino abstinence there is a new private project for me: a bicycle computer.
    When uploading code, doing a save() and a power cycle there is still the Pixl logo showing up before my code takes over the screen.
    Also when connecting or disconnecting via bluetooth sometimes output shows up for a fraction of a second.
    Where does that all come from - can it be disabled or avoided?

    Thanks for any pointers.

  • Wed 2019.10.30

    Welcome back from your respite @ChristianW

    Is there a tutorial being used that will assist us to follow along? Link please.

    I will defer to others, but until they respond, is that output intentional or is it a possible error being reported?

    re: 'sometimes output shows up for a fraction of a second'

    Beneath heading 'LCD Screen'

    http://www.espruino.com/Pixl.js

    "Any errors generated when there is no connection will also be displayed on the LCD."



    Are there any Espruino commands that are outside functions, that would be executed on upload, before the E.on('init') fires?

    http://www.espruino.com/Reference#l_E_in­it


    'can it be disabled or avoided?'

    From tutorial below heading 'Tutorials', use of g.clear() function perhaps?

    http://www.espruino.com/Pixl.js+Temperat­ure+Display

    also from same link below heading 'Graphics'

    What about clearing an off screen area, then flip that into view?

  • Take a look into jswrap_pixljs.c

  • Thanks @MaBe for the link.
    It seems

    jswrap_pixljs_init()
    

    is causing the output after initialization just before I do the g.clear() and g.flip().
    To avoid this I guess I'd have to patch it and compile my own firmware?
    Or is there some more elegant way around this?

    The function also seems to contain some button magic like self test that would be missing if skipped altogether...
    I'll look into this some more tonight after work.
    Thanks for the pointer.

  • @Robin thanks for your reply.

    My code is still in early stages. Advertising a CSC and battery service already works as far as I can check with NRF toolbox on my phone.
    I also successfully connected some I2C modules for voltage and current measurement (energy monitoring of my Lipo on-board battery block for light) and RTC (which is a bit bulky but somehow works too).

    The output is the lines "Bluetooth" being written to the LCD when a BLE central (phone or laptop) connects or disconnects like you can see here: https://youtu.be/pawHDr4i3jI?t=126


    It is the same output written when you just see the boot screen and no code is loaded.

    But it still seems to happen with my code running and somehow interferes with my "g" screen outputs. It will disappear on the next update interval with g.clear() and g.flip() but you will notice it as a flicker sometimes.

  • Yep, custom firmware.

    Maybe a define in the board file to exclude the sections and some ifdef in the function.

  • To avoid Bluetooth connection writing to the screen, just call Bluetooth.setConsole(true)

  • @AkosLukacs - ah. Thanks a lot!

  • Wow, yeah - custom firmware seems like overkill :)

    The Pixl.js logo is displayed at boot, and after a reset it's only there for a fraction of a second - a g.clear();g.flip() in your code would probably get rid of it pretty quickly.

    If it was a real problem for you I could probably modify the firmware to have a flag that disabled that behaviour though - this is the first time it's come up.

    However it seems the real issue here is the text that appears on connect/disconnect? That's just as @AkosLukacs said - the REPL goes to the LCD by default, and Bluetooth.setConsole(true) will force it to stay on Bluetooth.

    ... it's work leaving on the LCD for development purposes though - if your code causes some kind of error then you'll get a stack trace on the screen, which can save you a lot of trouble!

  • Thanks @Gordon.
    Meanwhile I tried the Bluetooth.setConsole() and it works.
    Now I understand what it was about.
    The other thing is only cosmetic. No trouble currently, but sometimes I am trying to be a perfectionist. Actually there were two things why it struck me:

    1. I am using the screen 9o° rotated so the Logo appears sideways. Looks a bit odd.
    2. My onInit() did not do the screen refresh right away, but only a setInterval()so there was a delay till my own layout took over. I have fixed this now.
      But for the "final touch" I will probably consider doing something about the startup animation. If you don't mind. ;-)
  • What about a custom splash screen stored in flash and named “.splash”?

    Should include image and rotation.

    If .splash exist use it, otherwise load custom.

  • What about a custom splash screen stored in flash

    That sounds like a great idea! I can always make a zero-size file mean there is no splash screen.

  • @Gordon I hoped you would say that ;-)

  • Just done - if you use a new firmware, create an image, go to http://www.espruino.com/Image+Converter and create it to a 1bpp white/black 'image string'. Then write to storage:

    require("Storage").write(".splash",E.toA­rrayBuffer(atob("gEABAAAAAAAAAAAAAAAAAAA­AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA­AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA­AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA­AAAAAAAAAAAAAAAAB//gZ4Z//gAAAAAAAAAAAAf/­4GeGf/4AAAAAAAAAAAAGAGZh/mAGAAAAAAAAAAAA­BgBm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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA­AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA­AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA­AAAAAAAAAAAAAAAAAAAAAAAAAAA==")))
    

    There's no rotation done, so you'll need to rotate it yourself to landscape, then sort out what you need rotation-wise in the init code :)

    You may also have the image shifted up by one line because of the terminal, but you can actually disable the terminal completely by removing the internal link to the graphics object. Either do it right at the start of your 'save to flash' code, or add E.setBootCode('delete global["\xff"].gfx')

  • Perfekt - Thanks!

  • Thanks @Gordon.

    I just picked up on this, compiled+compiled a new firmware.
    And it works - but not just as expected.

    Using a 90°CCW rotated flash image (see code) below.
    Showing the image with g.drawImage() seems okay.

    Maybe I am doing something wrong here, but two things happen after flashing:

    1. after storing the flash and power-cycling the left lines (or lower lines if not rotated) of the image are blank - maybe this is something about the terminal you mentioned
    2. doing a manual reset() after installing also gives an error message:

    >reset()
    =undefined
     ____                 _
    |  __|___ ___ ___ _ _|_|___ ___
    |  __|_ -| . |  _| | | |   | . |
    |____|___|  _|_| |___|_|_|_|___|
             |_| espruino.com
     2v04.228 (c) 2019 G.Williams
    Uncaught Error: Expecting first argument to a valid Image
    

    This is my complete code, including the 90°CCW rotated image:

    var buf = E.toArrayBuffer(atob("AAAAAAAAAAAAAAAAAA­AAAAAAAAAAAAAD+AAAAAAAAAAAAAAAAAAAD/wAAA­AAAAAAAAAAAAAAAB/+AAAAAAAAAAAAAAAAAAA//w­AAAAAAAAAAAAAAPgAAf/8AAAAAAAAAAA////4AAP­//gAAAAAAAAAAP///+AAD//4AAAAAAAAAAD////g­AB//+AAAAAAAAAAA////4AAf//wAAAAAAAAAAP//­/+AAP//8AAAAAAAAAAD/gAAAAD///AAAAAAAAAAA­/8AAAAA///wAAAAAAAAAAD/wAAAAf//8AAAAAAAA­AAAP/AAAAH///AAAAAAAAAAAB/8AAAB///wAAAAA­AAAAAAH/wAAAf//8AAAAAAAAAAAAf/AAAP///AAA­AAAAAAAAAB/4AAD///wAAAAAAAAAAAAH/wAA///8­AMAAAAAAAAAAAf+AAP///AHwAAAAAAAAAAB/4AD/­//wB8AAAAAAAAAAB/+AB///8AfAAPgAAAAAAD//g­Af///AHwAB+AAAAAA///4AH///wB8AAPgAAAAB//­/wAB///8AfAAD8AAAAD//+AAAf///AHwAAfAAAAA­//4AAAH///gB8AAHwAAAAP/AAAAD///4AfAAB8AA­AAD/gAAAA//4DAHwAAfgAAAA//AAAAP/4AYB8AAH­4AAAAP/+AAAD/+ADAfgAB+AAAAD//8AAA//AAYH4­AAfgAAAAH//4AAP/wAGB/AAH4AAAAAP//wAD/4AB­gPwAB+AAAAAAf//gA//AAYD+AA/AAAAAAA//4AP/­wAGAf4AfwAAAAAAB/+AB/+ADAH/AP8AAAAAAAD/g­AP/wBgA///+AAAAAAAAH4AD//BwAH///AAAAAMAA­AOAAf//gAA///wAAAADwAAAAAP//4AAH//4AAAAA­/AAAAAC//8AAAf/4AAAAAP+AAAAAv//AAAB/4AAA­AAD/4AAAAT//wAAAAAAAAAAA//gAAAE//4AAAAAA­AAAAAD/+AAABP/+AAAAAAAAAAAAH/4AAAj//gAAA­AAAAAAAAAf/gAAJ//wAAAAAAAAAAAAB/+AAOf/8A­AAAAAAAAAAAAH/4AFv//AAAAAAAAAAAAAAP/wGf/­/wAAAAAAAAAAAAAA/+BP//8AAAAAAAAAAAAAB//g­f///gAAAAAAAAAAAB///4H///sAAAAAAAAAAAP//­/+A///xAAAAAAAAAAAD///4AH//8QAAAAAAAAAAA­///AAAf/+MAAAAAAAAAAAP/4AAAA//mAAAAAAAAA­AAD/AAAAAH/zAAAAAAAAAAAA4AAAAAB//AAAAAAA­AAAAAAAAAAAAP/AAAAAAAAAAAAAAAAAAAA/gAAAA­AAAAAAAAAAAAAAAAAAAAAAAAAAAA=="));
    
    // just a test to show that the image works
    g.clear();
    g.drawImage({width:128, height:64, bpp:1, buffer: buf});
    g.flip();
    
    // write to flash
    require("Storage").write(".splash", buf);
    
    E.setBootCode('delete global["\xff"].gfx');
    
    function onInit() {
      Bluetooth.setConsole( true );
    }
    
  • I think the image needs to be an 'image string' - looks like you maybe just exported it as 'image object' from the image converter - so ideally just typing g.drawImage(buf) should do it

  • Thanks @Gordon for the quick reply.
    But there is no issue with g.drawImage() - it shows correctly.

    It even is drawn after a power cycle - only the bottom few lines (or left part if you hold the Pixl in portrait mode) are missing (see photo).


    1 Attachment

    • IMG_4174.JPG
  • Have you tried the delete global["\xff"].gfx code? Those lines sure look a lot like what I'd expect happens with the terminal (although the newest builds should stop that automatic newline at boot now)

  • See my code above.
    I think it's in:
    (line 11 quoted from above):

    E.setBootCode('delete global["\xff"].gfx');
    

    Also checked:

    >s = require('Storage');
    =function () { [native code] }
    >s.list()
    =[
      ".splash",
      ".bootcde"
     ]
    >s.read('.bootcde');
    ="delete global[\"\xFF\"].gfx"
    
  • Sorry. My bad.
    Found it by trying around - maybe it's just the lack of understanding the internals... especially what belongs to onInit() and what does not.

    I removed the E.setBootcode() completely and moved the Bluetooth.setConsole(true) from onInit() to just the first line of the code.
    Now the splash screen is complete.

    Thanks @Gordon

    It's working now! (yay)

    And I also upgraded my bangle pledge to the early ones delivered in December by the way ;-)

  • Update:
    It wasn't working. Somehow. Just by accident.
    The issue was: I did not create an image string, but an image object.

    NOW it works!

  • Great! :)

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

Pixl LCD initialisation and output

Posted by Avatar for ChristianW @ChristianW

Actions