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
Exemple #2
0
 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
Exemple #3
0
 def createVirtualOutput(self, num_pixels, num_rows, real_device, shared_array, shared_lock, start_index, panelMapping):
     device = devices.VirtualOutput(num_pixels=num_pixels,
                                    num_rows=num_rows,
                                    device=real_device,
                                    shared_array=shared_array,
                                    shared_lock=shared_lock,
                                    start_index=start_index)
     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)
                 logger.info("Active pixel mapping on virtual device: {}".format(mappingFile))
         else:
             raise FileNotFoundError("Mapping file {} does not exist.".format(mappingFile))
     return device
Exemple #4
0
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)

# Initialize Audio device
if args.audio_device_index is not None:
    audio.GlobalAudio.overrideDeviceIndex = args.audio_device_index

# select config to show
config = args.config

print("The following audio devices are available:")
audio.print_audio_devices()

if args.audio_device_index is not None: