def createSingleDevice(self, deviceName, numPixels, numRows, candyServer=None, panelMapping=None): # Single device legacy implementation, TODO: Deprecate or adjust print("Creating device: {}".format(deviceName)) if deviceName == devices.RaspberryPi.__name__: device = devices.RaspberryPi(numPixels, numRows) elif deviceName == devices.FadeCandy.__name__: device = devices.FadeCandy(numPixels, numRows, candyServer) else: print("Unknown device: {}".format(deviceName)) return None if panelMapping and panelMapping: mappingFile = panelMapping if os.path.exists(mappingFile): with open(mappingFile, "r", encoding='utf-8') as f: mapping = json.loads(f.read()) device = devices.PanelWrapper(device, mapping) print("Active pixel mapping on real device: {}".format( mappingFile)) else: raise FileNotFoundError( "Mapping file {} does not exist.".format(mappingFile)) return device
def _createOutputDevice(self): device = None print("Injecting device: {}".format( self.getConfiguration(CONFIG_DEVICE))) if self.getConfiguration( CONFIG_DEVICE) == devices.RaspberryPi.__name__: device = devices.RaspberryPi( self.getConfiguration(CONFIG_NUM_PIXELS), self.getConfiguration(CONFIG_NUM_ROWS)) elif self.getConfiguration( CONFIG_DEVICE) == devices.FadeCandy.__name__: device = devices.FadeCandy( self.getConfiguration(CONFIG_NUM_PIXELS), self.getConfiguration(CONFIG_NUM_ROWS), self.getConfiguration(CONFIG_DEVICE_CANDY_SERVER)) else: print("Unknown device: {}".format( self.getConfiguration(CONFIG_DEVICE))) if self.getConfiguration(CONFIG_DEVICE_PANEL_MAPPING ) is not None and self.getConfiguration( CONFIG_DEVICE_PANEL_MAPPING) != '': mappingFile = self.getConfiguration(CONFIG_DEVICE_PANEL_MAPPING) if os.path.exists(mappingFile): with open(mappingFile, "r", encoding='utf-8') as f: content = f.read() mapping = json.loads(content) wrapper = devices.PanelWrapper(device, mapping) device = wrapper print("Active pixel mapping: {}".format(mappingFile)) else: raise FileNotFoundError( "Mapping file {} does not exist.".format(mappingFile)) return device
parser.add_argument('--device_candy_server', dest='device_candy_server', default='127.0.0.1:7890', help='Server for device FadeCandy') parser.add_argument('-A', '--audio_device_index', dest='audio_device_index', type=int, default=None, help='Audio device index to use') args = parser.parse_args() num_pixels = args.num_pixels # Initialize LED device if args.device == deviceRasp: device = devices.RaspberryPi(num_pixels) elif args.device == deviceCandy: device = devices.FadeCandy(args.device_candy_server) devices.LEDOutput.overrideDevice = device # Initialize Audio device if args.audio_device_index is not None: audio.AudioInput.overrideDeviceIndex = args.audio_device_index # strand test strandTest(device, num_pixels) # print audio information print("The following audio devices are available:") audio.print_audio_devices()
if serverconfig.getConfiguration( serverconfiguration.CONFIG_AUDIO_DEVICE_INDEX) is not None: print("Overriding Audio device with device index {}".format( serverconfig.getConfiguration( serverconfiguration.CONFIG_AUDIO_DEVICE_INDEX))) audio.AudioInput.overrideDeviceIndex = serverconfig.getConfiguration( serverconfiguration.CONFIG_AUDIO_DEVICE_INDEX) # strand test if args.strand: device = None if serverconfig.getConfiguration( serverconfiguration.CONFIG_DEVICE) == deviceRasp: device = devices.RaspberryPi( serverconfig.getConfiguration( serverconfiguration.CONFIG_NUM_PIXELS), serverconfig.getConfiguration( serverconfiguration.CONFIG_NUM_ROWS), ) elif serverconfig.getConfiguration( serverconfiguration.CONFIG_DEVICE) == deviceCandy: device = devices.FadeCandy( serverconfig.getConfiguration( serverconfiguration.CONFIG_NUM_PIXELS), serverconfig.getConfiguration( serverconfiguration.CONFIG_NUM_ROWS), serverconfig.getConfiguration( serverconfiguration.CONFIG_DEVICE_CANDY_SERVER)) else: print("Unknown device: {}".format( serverconfig.getConfiguration( serverconfiguration.CONFIG_DEVICE)))
'-s', '--save_config', dest='save_config', type=bool, default=False, help='Save config to config/', ) args = parser.parse_args() num_pixels = args.num_pixels num_rows = args.num_rows # Initialize device if args.device == deviceRasp: device = devices.RaspberryPi(num_pixels, num_rows) elif args.device == deviceCandy: device = devices.FadeCandy(num_pixels, num_rows, server=args.device_candy_server) if args.device_panel_mapping is not None: mappingFile = args.device_panel_mapping if os.path.exists(mappingFile): with open(mappingFile, "r", encoding='utf-8') as f: content = f.read() mapping = json.loads(content) print("Panel mapping loaded") device = devices.PanelWrapper(device, mapping) else: print("Fatal: Cannot find mapping file {}".format(mappingFile)) exit(1)