Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

Problems running ssd1306 example

GroningenGroningen The Netherlands
edited October 9 in Mongoose OS

I'm running into this error. could anyone tell me what to do?

mgos_init            Init done, RAM: 317936 total, 273104 free, 273092 min free
[Oct  8 21:20:21.895]   at api_arduino_ssd1306.js:5
[Oct  8 21:20:21.898]   at init.js:11
[Oct  8 21:20:21.899]   at init.js:11
[Oct  8 21:20:21.902] MJS error: failed to exec file "api_arduino_ssd1306.js": bad ffi signature: "void *mgos_ssd1306_create_i2c(int, int)": dlsym('mgos_ssd1306_create_i2c') failed

Thanks

Comments

  • GroningenGroningen The Netherlands
    edited October 9

    mos keeps also saying:
    Update mos tool.. Click "OK" to start self-update. Restart mos tool when done.
    when restarted same shit..

    trying in terminal:
    mos update
    Please use brew to update mos.

    brew update:
    Error: cesanta/mos/mos 2.6.0 already installed

    Terminal:

    mos upgrade
    The Mongoose OS command line tool 2.6.0.
    Update channel: "release". Checking updates... 
    Out of date: new version available: 2.6.0
    Please run "mos update"
    
    Terminal> brew upgrade mos
    Error: cesanta/mos/mos 2.6.0 already installed
    

    Don't get it anymore..

  • nliviunliviu Romania

    I can't reproduce the first issue (bad ffi signature).

    I can confirm the second one. Hope @rojer will see this thread.

  • GroningenGroningen The Netherlands
    edited October 9

    @nliviu, do u have experience with ssd1306? Because i want to run it under js but can't find a simple way of getting it working. Thanks for your respons
    I got it running with ESP32 and Arduino IDE but not with mongoose os

  • nliviunliviu Romania

    No, I did not.
    A good start can be the example application
    There is also a native ssd1306 library. It does not have mJS bindings, but it's easy to write them.

  • mamuespmamuesp Germany/Northern coast
    edited October 10

    Well, I wrote a complete MJS API for this lib and also created a PR, but I think this has been lost. @Groningen - don't hesitate to use it in your project.

  • GroningenGroningen The Netherlands

    Hi @mamuesp, look great but can't find a place where you import any thing for the ssd1306? You might have a example code for this library/api you wrote?
    init.js and mos.yml

  • GroningenGroningen The Netherlands

    Ok @mamuesp i was to fast with asking questions. but stil would like a example a lot because i run into the next problem.

    [Oct 17 14:58:41.956] at api_ssd1306_i2c.js:243
    [Oct 17 14:58:41.959] at init.js:21
    [Oct 17 14:58:41.961] at init.js:26
    [Oct 17 14:58:41.962] MJS callback error: failed to call FFIed function: got 4 actuals, but function takes 6 args

    Calling drawString(0,0,string);

  • GroningenGroningen The Netherlands
    edited October 17

    @mamuesp
    drawString: function(x, y, txt) {
    return this._drawStringColor(this._oled, x, y, txt);
    },

    but
    _drawStringColor: ffi('int mgos_ssd1306_draw_string_color(void *, int, int, char *, int, int)'),

    right

  • GroningenGroningen The Netherlands
    edited October 17
  • mamuespmamuesp Germany/Northern coast

    I'm abroad the next days, but I will look into it next week. I made a little example which worked fine, perhaps some errors slipped through.

  • GroningenGroningen The Netherlands
    edited October 20

    @mamuesp perfect no problem i got your lib working but want to suggest some change:

    ------- code ----------
     /**
       * @brief Draw a string using the active font and default colors (white on transparent)
       *
       * @param x X coordinate.
       * @param y Y coordinate.
       * @param str String to draw.                                                      **** change to txt
       *
       * @return String width in pixels.
       */
      drawString: function(x, y, txt) {
        return this._drawStringColor(this._oled, x, y, txt);                  **** change to:  return this._drawStringColor(this._oled, x, y, txt,1,0);               added ',1,0' or as '1,-1'
      },
    
  • GroningenGroningen The Netherlands

    @mamuesp Hello, i got a question. Can you tell me what is the best way to print a logo/bitmap with you lib? thanks

  • mamuespmamuesp Germany/Northern coast

    You need to prepare a monochrome bitmap and store this as a simple byte array. Then this will be pushed into the display buffer with ``ùpdateBuffer()```(see below). As it is not positioned, you may should so before writing/drawing fonts or figures on the display. And the geometric size of the bitmap should be the same as the amount of the displayed pixels. Explaining articles how to prepare the data you may find in a number of examples coming with Arduino projects.

    However, If you want to draw bitmaps as logos etc. more precise with positioning, you may traverse the bitmap data by yourself and set every pixel with "drawPixel()". But as this is not the fastest way, this should only be used when displaying small symbols etc.

    /**
       * @brief Copy pre-rendered bytes directly into the bitmap.
       *
       * @param data Array containing bytes to copy into buffer.
       * @param length Length to copy (unchecked) from source buffer.
       */
      updateBuffer: function(data, length) {
        this._updateBuffer(this._oled, data, length);
      },
    
Sign In or Register to comment.