We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

Playing with oled-exp



  • As I'm playing with oled-exp there are a few things I'm curious about.

    • What is actually happening when the display is initialized (oled-exp -i)? It seems to be necessary to do before pushing data to the display the first time but has no visible effect, but I also don't get an error if I try to display something without initialization. (It just doesn't show anything in that case.)
    • How can I embed a newline in text I send with oled-exp write? I've tried various forms of quoting, \n, etc. but they get changed to spaces on the display. The web interface doesn't seem to have this issue, so I'm probably just missing something obvious.
    • Is there a list of valid characters the display has in its font? I don't expect full Unicode or anything šŸ™‚ But some ASCII characters (e.g. ā™„ and Ʊ) are silently ignored.
    • I mentioned elsewhere, but it looks like some characters don't get escaped properly through the web interface (e.g. parentheses).

    Don't get me wrong -- I'm not complaining. This is awesome šŸ™‚ Just poking at the edges of what's there and trying to understand how it works



  • I can answer my question about newlines -- looks like it works if I use single quoted '\n' characters.

    But this makes it hard to get the output of commands to oled-exp write. It doesn't appear to be possible to pipe data to this command and single quotes keeps me from being able to use backticks or a subshell to run a command and capture the output.

    Is there a way to pipe data to oled-exp? If not, can I request it? šŸ™‚



  • I believe that it only supports 7-bit ASCII. Those ā™„ and Ʊ chars are not in 7-bit ASCII.



  • There are two main ways in bash to pipe to oled-exp.
    The best way is to use shell substitution like this:

    oled-exp `ls -l`
    

    Another way, that will probably munge up your whitespace, would be:

    ls | xargs oled-exp
    


  • @Garth-Minette Right, I can use shell substitution but it doesn't properly deal with whitespace. (E.g. try your example out and you'll see. You'll need to quote the backticks with double quotes as 'write' expects a single argument, so oled-exp write "`ls -1`". The OLED will display the output of ls with no newlines at all.) xargs definitely won't work as the best I could do then is end up with a series of strings that have to be quoted anyway, destroying the newlines.

    What I want is to be able to redirect stdin to oled-exp so that it can be used as the terminus of an actual pipeline, which I don't see a way to do.



  • It's not particularly elegant, but if anyone else runs into this I knocked together a workaround. I created a little script I called 'oprint':

        oled-exp -c write "`awk -vRS="\n" -vORS="\\\\\n" '1' $*`"
    

    This can then be used in a pipeline, like so:

        ls -1 | ./oprint
    

    This gives me the expected output on the OLED display.



  • @fader OLED initialization does a few things such as turning the screen on, placing the cursor at the top left of the screen, turn off scrolling, etc.

    Right now to add the new line you need to do \\\\\n. We are working on changing this hack to something more elegant šŸ™‚

    Right now the screen is programmed with the following characters:

    static const uint8_t asciiTable[][OLED_EXP_CHAR_LENGTH] = {
    	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // SPACE
    
    	{0x00, 0x00, 0x4F, 0x00, 0x00, 0x00}, // !
    	{0x00, 0x07, 0x00, 0x07, 0x00, 0x00}, // "
    	{0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00}, // #
    	{0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00}, // $
    	{0x23, 0x13, 0x08, 0x64, 0x62, 0x00}, // %
    	{0x36, 0x49, 0x55, 0x22, 0x50, 0x00}, // &
    	{0x00, 0x05, 0x03, 0x00, 0x00, 0x00}, // '
    	{0x00, 0x1C, 0x22, 0x41, 0x00, 0x00}, // (
    	{0x00, 0x41, 0x22, 0x1C, 0x00, 0x00}, // )
    	{0x14, 0x08, 0x3E, 0x08, 0x14, 0x00}, // *
    	{0x08, 0x08, 0x3E, 0x08, 0x08, 0x00}, // +
    	{0x00, 0x50, 0x30, 0x00, 0x00, 0x00}, // ,
    	{0x08, 0x08, 0x08, 0x08, 0x08, 0x00}, // -
    	{0x00, 0x60, 0x60, 0x00, 0x00, 0x00}, // .
    	{0x20, 0x10, 0x08, 0x04, 0x02, 0x00}, // /
    
    	{0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00}, // 0
    	{0x00, 0x42, 0x7F, 0x40, 0x00, 0x00}, // 1
    	{0x42, 0x61, 0x51, 0x49, 0x46, 0x00}, // 2
    	{0x21, 0x41, 0x45, 0x4B, 0x31, 0x00}, // 3
    	{0x18, 0x14, 0x12, 0x7F, 0x10, 0x00}, // 4
    	{0x27, 0x45, 0x45, 0x45, 0x39, 0x00}, // 5
    	{0x3C, 0x4A, 0x49, 0x49, 0x30, 0x00}, // 6
    	{0x01, 0x71, 0x09, 0x05, 0x03, 0x00}, // 7
    	{0x36, 0x49, 0x49, 0x49, 0x36, 0x00}, // 8
    	{0x06, 0x49, 0x49, 0x29, 0x1E, 0x00}, // 9
    
    	{0x36, 0x36, 0x00, 0x00, 0x00, 0x00}, // :
    	{0x56, 0x36, 0x00, 0x00, 0x00, 0x00}, // ;
    	{0x08, 0x14, 0x22, 0x41, 0x00, 0x00}, // <
    	{0x14, 0x14, 0x14, 0x14, 0x14, 0x00}, // =
    	{0x00, 0x41, 0x22, 0x14, 0x08, 0x00}, // >
    	{0x02, 0x01, 0x51, 0x09, 0x06, 0x00}, // ?
    	{0x30, 0x49, 0x79, 0x41, 0x3E, 0x00}, // @
    
    	{0x7E, 0x11, 0x11, 0x11, 0x7E, 0x00}, // A
    	{0x7F, 0x49, 0x49, 0x49, 0x36, 0x00}, // B
    	{0x3E, 0x41, 0x41, 0x41, 0x22, 0x00}, // C
    	{0x7F, 0x41, 0x41, 0x22, 0x1C, 0x00}, // D
    	{0x7F, 0x49, 0x49, 0x49, 0x41, 0x00}, // E
    	{0x7F, 0x09, 0x09, 0x09, 0x01, 0x00}, // F
    	{0x3E, 0x41, 0x49, 0x49, 0x7A, 0x00}, // G
    	{0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00}, // H
    	{0x00, 0x41, 0x7F, 0x41, 0x00, 0x00}, // I
    	{0x20, 0x40, 0x41, 0x3F, 0x01, 0x00}, // J
    	{0x7F, 0x08, 0x14, 0x22, 0x41, 0x00}, // K
    	{0x7F, 0x40, 0x40, 0x40, 0x40, 0x00}, // L
    	{0x7F, 0x02, 0x0C, 0x02, 0x7F, 0x00}, // M
    	{0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00}, // N
    	{0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00}, // O
    	{0x7F, 0x09, 0x09, 0x09, 0x06, 0x00}, // P
    	{0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00}, // Q
    	{0x7F, 0x09, 0x19, 0x29, 0x46, 0x00}, // R
    	{0x46, 0x49, 0x49, 0x49, 0x31, 0x00}, // S
    	{0x01, 0x01, 0x7F, 0x01, 0x01, 0x00}, // T
    	{0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00}, // U
    	{0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00}, // V
    	{0x3F, 0x40, 0x30, 0x40, 0x3F, 0x00}, // W
    	{0x63, 0x14, 0x08, 0x14, 0x63, 0x00}, // X
    	{0x07, 0x08, 0x70, 0x08, 0x07, 0x00}, // Y
    	{0x61, 0x51, 0x49, 0x45, 0x43, 0x00}, // Z
    
    	{0x00, 0x7F, 0x41, 0x41, 0x00, 0x00}, // [
    	{0x02, 0x04, 0x08, 0x10, 0x20, 0x00}, // backslash
    	{0x00, 0x41, 0x41, 0x7F, 0x00, 0x00}, // ]
    	{0x04, 0x02, 0x01, 0x02, 0x04, 0x00}, // ^
    	{0x40, 0x40, 0x40, 0x40, 0x40, 0x00}, // _
    	{0x00, 0x01, 0x02, 0x04, 0x00, 0x00}, // `
    
    	{0x20, 0x54, 0x54, 0x54, 0x78, 0x00}, // a
    	{0x7F, 0x50, 0x48, 0x48, 0x30, 0x00}, // b
    	{0x38, 0x44, 0x44, 0x44, 0x20, 0x00}, // c
    	{0x38, 0x44, 0x44, 0x48, 0x7F, 0x00}, // d
    	{0x38, 0x54, 0x54, 0x54, 0x18, 0x00}, // e
    	{0x08, 0x7E, 0x09, 0x01, 0x02, 0x00}, // f
    	{0x0C, 0x52, 0x52, 0x52, 0x3E, 0x00}, // g
    	{0x7F, 0x08, 0x04, 0x04, 0x78, 0x00}, // h
    	{0x00, 0x44, 0x7D, 0x40, 0x00, 0x00}, // i
    	{0x20, 0x40, 0x44, 0x3D, 0x00, 0x00}, // j
    	{0x7F, 0x10, 0x28, 0x44, 0x00, 0x00}, // k
    	{0x00, 0x41, 0x7F, 0x40, 0x00, 0x00}, // l
    	{0x78, 0x04, 0x78, 0x04, 0x78, 0x00}, // m
    	{0x7C, 0x08, 0x04, 0x04, 0x78, 0x00}, // n
    	{0x38, 0x44, 0x44, 0x44, 0x38, 0x00}, // o
    	{0x7C, 0x14, 0x14, 0x14, 0x08, 0x00}, // p
    	{0x08, 0x14, 0x14, 0x18, 0x7C, 0x00}, // q
    	{0x7C, 0x08, 0x04, 0x04, 0x08, 0x00}, // r
    	{0x48, 0x54, 0x54, 0x54, 0x20, 0x00}, // s
    	{0x04, 0x3F, 0x44, 0x40, 0x20, 0x00}, // t
    	{0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00}, // u
    	{0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00}, // v
    	{0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00}, // w
    	{0x44, 0x28, 0x10, 0x28, 0x44, 0x00}, // x
    	{0x0C, 0x50, 0x50, 0x50, 0x3C, 0x00}, // y
    	{0x44, 0x64, 0x54, 0x4C, 0x44, 0x00}, // z
    
    	{0x00, 0x08, 0x36, 0x41, 0x00, 0x00}, // {
    	{0x00, 0x00, 0x7F, 0x00, 0x00, 0x00}, // |
    	{0x00, 0x41, 0x36, 0x08, 0x00, 0x00}, // }
    	{0x0C, 0x02, 0x0C, 0x10, 0x0C, 0x00}, // ~
    	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
    };
    

    Because the Omega has quite a bit of RAM (compared to microcontrollers), you can actually define quite a bit more characters. I have seen implementations of the drivers showing Japanese characters.

    Yup, we are also working on the escape hacks on the Console side of things.



  • Awesome info, thank you @Boken-Lin!



  • Now that I have had hands on experience with oled-exp, this is what worked for me, including preserving whitespace and newlines:

    oled-exp -c write "$(ls -FCs1|sed 's/$/\\n/g')"
    


  • Because I like poking at things, I keep pushing on what I can get oled-exp to do šŸ™‚ I've hit a couple of bugs with it while playing more.

    An interesting one is that oled-exp attempts to parse strings that start with a dash '-' as switches, even if they are quoted (either single or double quotes). E.g.

        oled-exp write '-c'
    

    will clear the display and write an empty string instead of writing the literal '-c' to the display. I have also tried escaping the dash but get the same behavior.

    I also can't get the cursor positioning to work for columns. Rows work fine:

        oled-exp cursor 7,0 write "I am the bottom line"
    

    does what is expected, but

        oled-exp cursor 4,8 write "center"
    

    puts the text at line 4 column 0 rather than column 8. Though stdout from oled-exp claims that it is doing the right thing:

       > Setting cursor to (4, 8)
       > Writing 'center' to display


  • @fader Thanks for pointing out these bugs. We will add them to our list and get them sorted out for the next release šŸ™‚



  • Awesome, thanks @Boken-Lin! Is there a bug tracker I should use in the future or is this community site the best place to report such things?



  • @fader You should create an issue on our Github repo here: https://github.com/OnionIoT/i2c-exp-driver.



  • I experienced the bug with the cursor as well. Issue on github: https://github.com/OnionIoT/i2c-exp-driver/issues/2



  • @BeneKenobi Thanks for reporting the bug!


  • administrators

    @fader @BeneKenobi
    Thanks for the bug reporting guys!
    Please upgrade your Omega firmware to b236, the cursor issue has been addressed and should be working now



  • Just updated from b234 to b236, now the Image function of the OLED Expansion Control of the Control Panel displays the image in a torn, skewed manner. It worked correctly in b234. Worked correctly in b234.
    Issue on github: https://github.com/OnionIoT/i2c-exp-driver/issues/3



  • I'm seeing the same thing as @BeneKenobi and have uploaded a picture of the skewed image to his bug report.

    I'm also now able to escape a string starting with a dash using a backslash (i.e. \-mystring) but not in quotes (either single or double, i.e. '-mystring' or "-mystring"). Not sure if this is expected behavior or not so I haven't updated/filed a bug on that yet. šŸ™‚



  • @Scott-Smith, @fader: Thanks for the update. We will take a look!


  • administrators

    @Scott-Smith, @fader: oversight on my part with the cursor fix, sorry, it's fixed now tho.

    Pick up b238, the draw isn't skewed anymore (and the cursor still works šŸ˜„ )



  • @Lazar-Demin Thanks for the fast update! Unfortunately, b238 seems to have a different skew, where some rows of pixels from the bottom of the image are pushed to the top. I've attached an example to the ticket in Github.

    Additionally, after displaying an image and then using 'oled-exp -c' a few pixels in the rightmost few columns are left on. This persists when text is written to the display.

    (But the cursor control seems to be working šŸ™‚ )


Log in to reply
 

Looks like your connection to Community was lost, please wait while we try to reconnect.