Beispiel #1
0
def run(conf_file=None):
    """Run the screen."""
    if not conf_file:
        parser = argparse.ArgumentParser()
        parser.add_argument(
            "--config",
            action="store",
            help="Point to a YAML configuration file.",
            default="/etc/infopanel/infopanel.yaml",
        )

        args = parser.parse_args()
        conf_file = args.config
    conf = config.load_config_yaml(conf_file)
    apply_global_config(conf)
    disp = display.display_factory(conf)
    datasrc = data.InputData()
    infopanel = driver_factory(disp, datasrc, conf)

    if conf.get("mqtt"):
        client = mqtt.MQTTClient(datasrc, conf["mqtt"])
        client.start()
    else:
        client = None
    try:
        # infopanel.start()  # multiple threads
        infopanel.run()  # main thread
    finally:
        if client:
            client.stop()
        LOG.info("Quitting.")
Beispiel #2
0
 def __init__(self, max_x, max_y, data_source=None):
     """Construct a sprite."""
     self.x, self.y = None, None
     self.max_x, self.max_y = max_x, max_y
     self._frame_num = 0
     self._ticks = (
         0  # to allow slower changes of frames, could probably be itertools.cycle
     )
     self.ticks_per_frame = None
     self.ticks_per_movement = None
     self.ticks_per_phrase = None
     self.min_ticks_per_phrase = None
     self.max_ticks_per_phrase = None
     self.pallete = None
     self.dx, self.dy = None, None
     self.font = None
     self.text = None
     self.phrases = None
     if data_source is None:
         data_source = data.InputData()
     self.data_source = data_source
     self.frames = []
     self._frame_delta = 0
     self.can_flip = None
     self.reverse_frame_loop = None
     self._phrase_width = 0
Beispiel #3
0
def build_test_sprites():
    DURATION_CONFIG = {
        'I90': {
            'type': 'Duration',
            'label': 'I90',
            'low_val': 13.0,  # pylint:disable=invalid-name
            'high_val': 25.0,
            'data_label': 'travel_time_i90'
        }
    }
    datasrc = data.InputData()
    datasrc['travel_time_i90'] = 10.0
    return sprites.sprite_factory(DURATION_CONFIG, datasrc, MockDisplay())
def build_test_sprites():
    # pylint:disable=invalid-name
    DURATION_CONFIG = {
        "I90": {
            "type": "Duration",
            "label": "I90",
            "low_val": 13.0,
            "high_val": 25.0,
            "data_label": "travel_time_i90",
        }
    }
    datasrc = data.InputData()
    datasrc["travel_time_i90"] = 10.0
    return sprites.sprite_factory(DURATION_CONFIG, datasrc, MockDisplay())
    def test_bytes_mode_input(self):
        """
        Make sure a bytes mode name gets handled properly.

        Sometimes MQTT returns byte strings instead of bytes.
        """
        datasrc = data.InputData()
        client = mqtt.MQTTClient(datasrc, conf=None)
        msg = MockMQTTMsg("infopanel/mode", "random")
        client.on_message(None, None, msg)
        self.assertEqual(datasrc["mode"], "random")
        msg = MockMQTTMsg("infopanel/mode", b"random")
        client.on_message(None, None, msg)
        self.assertEqual(datasrc["mode"], "random")