def _initialise(): """INTERNAL. Initialise the matrix.""" global _initialised global _serial_device global _pixel_map if not _initialised: if configuration.mcu_enabled(): if not os.path.exists('/dev/serial0'): err_str = "Could not find serial port - are you sure it's enabled?" raise serial.serialutil.SerialException(err_str) _debug_print("Opening serial port...") _serial_device = serial.Serial("/dev/serial0", baudrate=250000, timeout=2) if _serial_device.isOpen(): _debug_print("OK.") else: print("Error: Failed to open serial port!") sys.exit() _initialised = True else: print( "Error: pi-topPULSE is not initialised. Please make sure that you have installed 'pt-peripheral-cfg' package" ) sys.exit()
def _initialise(): """INTERNAL. Initialise the matrix.""" global _initialised global _serial_device global _pixel_map if not _initialised: if configuration.mcu_enabled(): if not path.exists('/dev/serial0'): err_str = "Could not find serial port - are you sure it's enabled?" raise serialutil.SerialException(err_str) PTLogger.debug("Opening serial port...") _serial_device = Serial("/dev/serial0", baudrate=250000, timeout=2) if _serial_device.isOpen(): PTLogger.debug("OK.") else: PTLogger.info("Error: Failed to open serial port!") exit() _initialised = True else: PTLogger.info("Error: pi-topPULSE is not initialised. Call ptpulse.configuration.initialise() ptpulse.configuration.enable_device()") exit()
def stream_audio(): """Start recording on the pi-topPULSE microphone - returns a generator yielding audio data as it is read in.""" global _thread_running global _continue_writing if not configuration.mcu_enabled(): print("Error: pi-topPULSE is not initialised.") sys.exit() if _thread_running == False and _continue_writing == False: _continue_writing = True return _record_audio() else: print("Microphone is already recording!")
def record(): """Start recording on the pi-topPULSE microphone to a file""" global _thread_running global _continue_writing global _recording_thread if not configuration.mcu_enabled(): print("Error: pi-topPULSE is not initialised.") sys.exit() if _thread_running == False and _continue_writing == False: _thread_running = True _continue_writing = True _recording_thread = Thread(group=None, target=_thread_method) _recording_thread.start() else: print("Microphone is already recording!")
def record(): """Start recording on the pi-topPULSE microphone.""" global _thread_running global _continue_writing global _recording_thread if not configuration.mcu_enabled(): PTLogger.info("Error: pi-topPULSE is not initialised.") exit() if _thread_running is False: _thread_running = True _continue_writing = True _recording_thread = Thread(group=None, target=_thread_method) _recording_thread.start() else: PTLogger.info("Microphone is already recording!")