def main(): fia = FIA("/dev/ttyAMA1", (3, 0), width=DISPLAY_WIDTH, height=DISPLAY_HEIGHT) renderer = LayoutRenderer("fonts") with open("layouts/departures_5x2_single.json", 'r', encoding='utf-8') as f: layout = json.load(f) with open("wr_test_extra.json", 'r') as f: wr_data = json.load(f) for train_number, train_data in wr_data['train'].items(): data = train_data['wagenreihung'] order_sections, order_coaches = get_coach_order_strings(data) data = { 'placeholders': { 'order_sections': "\x25\x26\x27\x28\x29\x2a" if order_sections else None, 'order_coaches': order_coaches, } } img = renderer.render(layout, data) fia.send_image(img) print("Train: {}".format(train_number)) input("Enter for next train")
def main(): fia = FIA("/dev/ttyAMA1", (3, 0), width=DISPLAY_WIDTH, height=DISPLAY_HEIGHT) renderer = LayoutRenderer("fonts") with open("layouts/temp_monitor_5x2.json", 'r', encoding='utf-8') as f: layout = json.load(f) while True: try: temps = fia.get_temperatures() humidity = fia.get_humidity() backlight_state = fia.get_backlight_state() bl_base_brightness_a, bl_base_brightness_b = fia.get_backlight_base_brightness( ) bl_cur_brightness_a, bl_cur_brightness_b = fia.get_backlight_brightness( ) env_brightness_a, env_brightness_b = fia.get_env_brightness() door_states = fia.get_door_states() heaters_state = fia.get_heaters_state() circ_fans_state = fia.get_circulation_fans_state() heat_exc_fan_state = fia.get_heat_exchanger_fan_state() bl_ballast_fans_state = fia.get_backlight_ballast_fans_state() data = { 'placeholders': { 'temp_ballasts': "{:.1f}".format(temps[0]), 'temp_airflow': "{:.1f}".format(temps[1]), 'temp_board': "{:.1f}".format(temps[2]), 'temp_mcu': "{:.1f}".format(temps[3]), 'humidity': "{:.1f}".format(humidity), 'backlight_state': POWER_STATES[backlight_state], 'backlight_base_brt_a': str(bl_base_brightness_a), 'backlight_base_brt_b': str(bl_base_brightness_b), 'backlight_cur_brt_a': str(bl_cur_brightness_a), 'backlight_cur_brt_b': str(bl_cur_brightness_b), 'env_brt_a': str(env_brightness_a), 'env_brt_b': str(env_brightness_b), 'door_state_a': DOOR_STATES[door_states & 1 != 0], 'door_state_b': DOOR_STATES[door_states & 2 != 0], 'heaters_state': MULTI_POWER_STATES[heaters_state], 'circ_fans_state': MULTI_POWER_STATES[circ_fans_state], 'heat_exc_fan_state': POWER_STATES[heat_exc_fan_state], 'bl_ballast_fans_state': POWER_STATES[bl_ballast_fans_state], } } img = renderer.render(layout, data) fia.send_image(img) time.sleep(1) except KeyboardInterrupt: break except: traceback.print_exc() time.sleep(1)
def main(): fia = FIA("/dev/ttyAMA1", (3, 0), width=DISPLAY_WIDTH, height=DISPLAY_HEIGHT) fia.set_backlight_state(1) fia.set_heaters_state(0) fia.set_circulation_fans_state(2) fia.set_heat_exchanger_fan_state(1) fia.set_backlight_ballast_fans_state(1) fia.set_backlight_base_brightness(2048, 2048) fia.send_image(Image.new('L', (480, 128), 'white')) with open("temperatures.csv", 'a') as f: while True: temps = list(fia.get_temperatures()) humidity = fia.get_humidity() data = [time.time()] + temps + [humidity] print(data) f.write(",".join(map(str, data)) + "\n") time.sleep(5)
def main(): parser = argparse.ArgumentParser(add_help=False) parser.add_argument('--font-dir', '-fd', required=True, type=str) parser.add_argument('--station', '-s', required=True, type=str) parser.add_argument('--platforms', '-p', required=True, type=str, help="Example string: 1a,1-24,101-104") args = parser.parse_args() platforms = [] raw_platform_list_parts = args.platforms.split(",") for part in raw_platform_list_parts: if "-" in part: p_min, p_max = map(int, part.split("-")) platforms += map(str, range(p_min, p_max + 1)) else: platforms.append(part) fia = FIA("/dev/ttyAMA1", (3, 0), width=DISPLAY_WIDTH, height=DISPLAY_HEIGHT) renderer = LayoutRenderer(args.font_dir) dbi = DBInfoscreen("dbf.finalrewind.org") platform_layout = [{ 'name': "platform_0", 'type': 'text', 'x': 1, 'y': 0, 'width': 19, 'height': 9, 'pad_left': 0, 'pad_top': 0, 'inverted': False, 'font': "7_DBLCD", 'size': 0, 'align': 'right', 'spacing': 1 }, { 'name': "departure_0", 'type': 'text', 'x': 25, 'y': 0, 'width': 30, 'height': 9, 'pad_left': 0, 'pad_top': 0, 'inverted': False, 'font': "7_DBLCD", 'size': 0, 'align': 'left', 'spacing': 1 }, { 'name': "train_0", 'type': 'text', 'x': 59, 'y': 0, 'width': 43, 'height': 9, 'pad_left': 0, 'pad_top': 0, 'inverted': False, 'font': "7_DBLCD", 'size': 0, 'align': 'left', 'spacing': 1 }, { 'name': "destination_0", 'type': 'text', 'x': 106, 'y': 0, 'width': 132, 'height': 9, 'pad_left': 0, 'pad_top': 0, 'inverted': False, 'font': "7_DBLCD", 'size': 0, 'align': 'left', 'spacing': 1 }] layout = { 'width': 480, 'height': 128, 'placeholders': [{ 'name': "divider_1", 'type': 'line', 'x': 22, 'y': 0, 'x2': 22, 'y2': 127, 'inverted': False, 'line_width': 1 }, { 'name': "divider_2", 'type': 'line', 'x': 56, 'y': 0, 'x2': 56, 'y2': 127, 'inverted': False, 'line_width': 1 }, { 'name': "divider_3", 'type': 'line', 'x': 239, 'y': 0, 'x2': 239, 'y2': 127, 'inverted': False, 'line_width': 2 }, { 'name': "divider_4", 'type': 'line', 'x': 263, 'y': 0, 'x2': 263, 'y2': 127, 'inverted': False, 'line_width': 1 }, { 'name': "divider_5", 'type': 'line', 'x': 297, 'y': 0, 'x2': 297, 'y2': 127, 'inverted': False, 'line_width': 1 }] } data = {'placeholders': {}} while True: try: station_code = args.station trains = dbi.calc_real_times(dbi.get_trains(args.station)) trains = filter(lambda t: t['actualDeparture'] is not None, trains) trains = filter(lambda t: not t['train'].startswith("Bus SEV"), trains) trains = list(trains) trains = sorted(trains, key=dbi.time_sort) x, y = 0, 0 for i, platform in enumerate(platforms): placeholders = [p.copy() for p in platform_layout] placeholders[0]['name'] = "platform_" + platform placeholders[1]['name'] = "departure_" + platform placeholders[2]['name'] = "train_" + platform placeholders[3]['name'] = "destination_" + platform placeholders[0]['y'] = placeholders[1]['y'] = placeholders[2][ 'y'] = placeholders[3]['y'] = y placeholders[0]['x'] += x placeholders[1]['x'] += x placeholders[2]['x'] += x placeholders[3]['x'] += x layout['placeholders'] += placeholders data['placeholders']['platform_' + platform] = platform p_trains = list( filter(lambda t: t['platform'] == platform, trains)) if p_trains: t = p_trains[0] data['placeholders']['departure_' + platform] = t['actualDeparture'] data['placeholders']['train_' + platform] = get_train_number( t['train']).replace(" ", "") data['placeholders']['destination_' + platform] = get_destination_name( t['destination']) y += 9 if 56 < y < 64: y = 64 if y > 120: y = 0 x += 241 img = renderer.render(layout, data) fia.send_image(img) time.sleep(30) except KeyboardInterrupt: break except: traceback.print_exc() time.sleep(10)