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

Python Modules for the Servo, Relay, and OLED Expansions!


  • administrators

    Yep, you read that correctly: Python modules for controlling the Servo, Relay, and OLED Expansions are now available. They're based on the C libraries so the control interface is very similar between C and Python.

    How to Install the Modules

    Make sure your Omega is running the latest firmware, b244, and then run the following commands:

    opkg update
    opkg install python-light pyPwmExp pyRelayExp pyOledExp
    

    The modules are completely independent of each other, so you do not need all three!

    How to use the Modules

    Check out the wiki articles on the Onion libraries, they now include info on the Python Modules as well.

    Please let us know if you have any suggestions for the wiki articles on how they can be improved!

    Other Stuff

    Right now the modules have only been tested with Python 2.7, if there is enough interest, we will make sure Python3 is 100% supported as well.

    And right now, the libraries are not object-oriented, just a collection of functions like the C libraries. If there is enough interest, we will make object oriented libraries as well!

    Happy hacking and happy holidays!



  • I ran your lines above and at the end I got these errors. I was just wondering if these two packages were installed or just Not installed because of one file error.

    Collected errors:

    • check_data_file_clashes: Package pyRelayExp wants to install file /usr/lib/python2.7/OmegaExpansion/init.py
      But that file is already provided by package * pyPwmExp
    • opkg_install_cmd: Cannot install package pyRelayExp.
    • check_data_file_clashes: Package pyOledExp wants to install file /usr/lib/python2.7/OmegaExpansion/init.py
      But that file is already provided by package * pyPwmExp
    • opkg_install_cmd: Cannot install package pyOledExp.


  • Remove all preinstalled python packages for Oled, Pwm or Relay

    And Just do

    opkg install pyOledExp
    rm /usr/lib/python2.7/OmegaExpansion/__init__.py
    opkg install pyPwmExp
    

    it seems to work for me : no errors when importing in python

    Python 2.7.9 (default, Sep  9 2015, 07:59:02)
    [GCC 4.8.3] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
     import OmegaExpansion.pwmExp as pwm
    import OmegaExpansion.oledExp as oled
    

    so i've done

    nano a.py
    
    #!/usr/bin/python
    import OmegaExpansion.pwmExp as pwm
    import OmegaExpansion.oledExp as oled
    #TEST OLED SCREEN FROM PYTHON
    oled.driverInit();
    oled.setDisplayPower(1)
    oled.setDisplayMode(1)
    

    ctrl+o crtl+x

    python a.py
    

    The oled screen becomes white !!!


  • administrators

    @Daniel-Wright ok, i'll have to look into that! I'll let you know when it's resolved


  • administrators

    @Daniel-Wright @Gwena56
    Ok, the installation issue is now fixed. Installing all three at the same time or separately will now work ok.

    There's a new package called pyOmegaExpansion that will create the /usr/lib/python2.7/OmegaExpansion/__init__.py file, so there won't be any collisions between the packages



  • Thank you @Lazar-Demin. I'll check it out.



  • Enjoy Omega !!!



  • I finally got around to hooking up the OLED screen and playing around with it. I created a small, Python program to write a simple message to the screen. First, there are some random bits set on the right edge of the screen. Is this a hardware problem or a problem with the Python clear()?

    #!/usr/bin/python
    import OmegaExpansion.oledExp as oled
    
    oled.driverInit()
    oled.setDisplayPower(1)
    oled.setDisplayMode(0)
    oled.clear()
    
    oled.setCursor(0, 0)
    oled.write("Hello")
    oled.setCursor(2,0)
    oled.write("World!")
    

    Produces the following screen:

    oled_dots.jpg

    So is there a way to get rid of the pixels that are lit up?

    Is there a way to write individual bytes (from Python) to produce my own characters?

    Thank you!
    Bryan



  • Hi @Bryan-Hilterbrand, this problem should have been fixed a couple of weeks ago. Can you upgrade your Omega to the latest firmware with oupgrade -force?

    Cheers!



  • Thanks @Boken-Lin! That fixed the garbage along the right side of the screen.

    Now is there any chance I can get an interface to write a byte to an individual column and page? Extra credit if I can read the byte that is currently there! šŸ™‚

    Bryan



  • @Bryan-Hilterbrand Ah, unfortunately we cannot read from the OLED via I2C. The closest thing we might be able to do is to keep track of the information that's on the screen in a variable and dump the variable out on demand. But this could back fire if you first print some text, and then upload a transparent image. On the screen you will see both the text and the image but in the memory buffer you would see only the image.



  • @Boken-Lin no problem on reading, but I'd still like a way to send a byte (or a list of bytes) to the screen. That would allow me to make my own fonts, special characters, or images to send to the OLED screen.


  • administrators

    @Bryan-Hilterbrand Ok, I'll look into adding that feature in.
    I'll let you know when its available



  • Thank you @Lazar-Demin!


  • administrators

    Hi @Bryan-Hilterbrand
    The OLED Expansion library now supports writing individual bytes, along with some other features!

    Check out the details here: https://community.onion.io/topic/560/python-module-for-i2c-oled-library-update



  • Hey @Lazar-Demin did you see my other post? The python library is seg faulting on setting pixel column, and the doc has typos in it.


  • administrators

    @PK-Shiu Yep, there's two responses waiting for you in that thread.



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