SSD1306 OLED module with different I2C address

Posted on
  • I bought modules with different I2C addresses than the Crius module. I could change the address in the ssd1306.js, but then I think I have to store this somewhere locally. But one can define only one modules location in WebIDE, so I have to store all modules locally.
    Am I right? If not, how can I do this? Or would it be better to change the module with an address parameter in the .connect function?

    Sorry for this noob question, I'm new in event driven JavaScript. Be aware, more noob questions to come ;-)

  • If you define modules location in the IDE (using the sandbox thingie - not sure if there's something else you're talking about), when you require() a module, it will look in the modules location first. Failing that, it will try to get it online. So you can just set a local location for modules and put your one modified version there, and you're good.

    That said, the correct solution is to modify the ssd1306 module so it takes an extra parameter in connect, and submit that via a pull request to the EspruinoDocs github so everyone can use it.

  • Thanks for the explanation, @DrAzzy. So I can use the require() mechanism for modularisation of my project into several files, too?

  • So I can use the require() mechanism for modularisation of my project into several files, too?

    Yes, absolutely!

    You can also require("http://foo.com/bar.js") to get a module you yourself have hosted somewhere (even github).

    But as @DrAzzy says, if the I2c address can be changed, it'd be great if you could submit an updated module so others don't hit the same problem

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

SSD1306 OLED module with different I2C address

Posted by Avatar for Spocki @Spocki

Actions