pastebin - collaborative debugging tool
midi.kpaste.net RSS


Untitled
Posted by Anonymous on Thu 24th Sep 2020 22:58
raw | new post

  1. # bi directional midi example for Adafruit MIDI Featherwing on M4 Express.
  2. import board
  3. import busio
  4. import time
  5.  
  6.  
  7. #midiuart = busio.UART(board.SDA, board.SCL, baudrate=31250)
  8. midiuart = busio.UART(board.TX, board.RX, baudrate=31250, timeout=0)
  9. print("MIDI UART EXAMPLE")
  10.  
  11. toggleState = "off"
  12.  
  13. lastTickTime = time.time()
  14.  
  15. while True:
  16.  
  17.     data = midiuart.read(1)  # read up to 32 bytes
  18.     if data is not None:
  19.         print("incoming"+str(data))
  20.  
  21.     currentTime = time.time()
  22.     elapsedTickTime = currentTime - lastTickTime
  23.     if (elapsedTickTime > 1.0):
  24.         print("tick",str(currentTime))
  25.         lastTickTime = currentTime
  26.         if (toggleState == "off"):
  27.             toggleState = "on"
  28.             midiuart.write(bytes([0x90, 0x3C, 0x40]))
  29.         else:
  30.             toggleState = "off"
  31.             midiuart.write(bytes([0x80, 0x3C, 0x40]))

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at