MRAA and UPM Python3 use



  • Hello, I will try to make the question mores specific. Any suggestion related to solve this issue is highly appreciated.

    This is the situation.

    This code works fine, MRAA only :

    #!/usr/bin/env python3
    import mraa
    board_type = mraa.getPlatformType()
    print (" Board type", board_type)
    board_name = mraa.getPlatformName()
    print (" Board name", board_name)
    mraa_version = mraa.getVersion()
    print (" MRAA Verson = ", mraa_version)
    for x in range(0,40):
    mraa_pin_name = mraa.getPinName (x)
    print (" Pin ", x, " name = ", mraa_pin_name)

    This code works also fine, MRAA and UPM :

    #!/usr/bin/env python3
    from time import sleep, localtime
    DIO = 8
    CLK = 7
    from upm import _pyupm_tm1637 as TM1637
    getVersion = TM1637.getVersion()
    print ("Version TM1637 = ",getVersion)

    This code works not, MRAA and UPM based on UPM examples included with the installation of UPM :

    This is the example python code
    I tried with and without the _ wto different responses.

    ./tm1637.py
    Traceback (most recent call last):
    File "./tm1637.py", line 27, in <module>
    from upm import pyupm_tm1637 as tm1637
    ImportError: cannot import name 'pyupm_tm1637' from 'upm' (/usr/lib64/python3.8/site-packages/upm/init.py)

    ./tm1637.py
    Traceback (most recent call last):
    File "./tm1637.py", line 62, in <module>
    main()
    File "./tm1637.py", line 37, in main

    The code used (based on the installedexamples during the UPM installation process.)

    #!/usr/bin/env python3
    from future import print_function
    import time, signal

    Two different tries ...

    from upm import pyupm_tm1637 as tm1637

    from upm import -pyupm_tm1637 as tm1637

    def main():
    # Register exit handler for normal Ctrl+C exit
    def SIGINTHandler(signum, frame):
    raise SystemExit
    signal.signal(signal.SIGINT, SIGINTHandler)

    # Create a display object on pins 0 CLK and 1 DIO
    display = tm1637.TM1637(0, 1)
    dots = True
    
    # Get local time
    myTime = time.localtime(time.time())
    print(time.strftime("System time: %H:%M", myTime))
    print ("You can adjust your time zone by setting the TZ environment variable.")
    
    # Draw a box for 3 seconds using 7-segment encoding
    display.write(0x39, 0x09, 0x09, 0x0f)
    time.sleep(3)
    
    # Loop indefinitely
    while True:
    	# Update and display time
    	timeString = time.strftime("%H%M", time.localtime(time.time()))
    	display.write(timeString)
    	# Toggle colon
    	display.setColon(dots)
    	dots = not dots
    
    	# Sleep for 1 s
    	time.sleep(1)
    

    if name == 'main':
    main()


Log in to reply
 

Pycom on Twitter