Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    MRAA and UPM Python3 use

    Scheduled Pinned Locked Moved Comments & Feedback
    1 Posts 1 Posters 13 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      Jos Scheelen
      last edited by

      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()

      1 Reply Last reply Reply Quote 0

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • 1 / 1
      • First post
        Last post

      Pycom on Twitter

      Pycom