Exemplo n.º 1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--port',
                        type=int,
                        default=80,
                        help='Port to use for web interface. Default: 80')
    parser.add_argument(
        '--host',
        default='0.0.0.0',
        help='Hostname to use for web interface. Default: 0.0.0.0')
    parser.add_argument('--strip',
                        type=int,
                        default=0,
                        help='Configure for a LED strip of this length.')
    parser.add_argument('--fps',
                        type=int,
                        default=24,
                        help='Refresh rate for LEDs, in FPS. Default: 24')
    parser.add_argument('--led_pin',
                        type=int,
                        default=18,
                        help='Pin for LEDs. Default: 18')
    parser.add_argument('--led_data_rate',
                        type=int,
                        default=800000,
                        help='Data rate for LEDs. Default: 800000 Hz')
    parser.add_argument('--led_dma_channel',
                        type=int,
                        default=10,
                        help='DMA channel for LEDs. Default: 10')
    parser.add_argument(
        '--led_pixel_order',
        default='GRB',
        help='LED color channel order. Either RGB or GRB. Default: GRB')
    args = parser.parse_args()

    app = create_app(args.strip, args.fps, args.led_pin, args.led_data_rate,
                     args.led_dma_channel, args.led_pixel_order)
    run_simple(args.host,
               args.port,
               app,
               use_reloader=False,
               use_debugger=True,
               use_evalex=True)
Exemplo n.º 2
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--port', type=int, default=80,
                        help='Port to use for web interface. Default: 80')
    parser.add_argument('--host', default='0.0.0.0',
                        help='Hostname to use for web interface. Default: 0.0.0.0')
    parser.add_argument('--led_count', type=int, default=0,
                        help='Number of LEDs')
    parser.add_argument('--fps', type=int, default=60,
                        help='Refresh rate limit for LEDs, in FPS. Default: 60')
    parser.add_argument('--led_pin', type=int, default=18,
                        help='Pin for LEDs (see https://github.com/jgarff/rpi_ws281x).. Default: 18')
    parser.add_argument('--led_data_rate', type=int, default=800000,
                        help='Data rate for LEDs. Default: 800000 Hz')
    parser.add_argument('--led_dma_channel', type=int, default=10,
                        help='DMA channel for LEDs. DO NOT USE CHANNEL 5 ON Pi 3 B. Default: 10')
    parser.add_argument('--led_pixel_order', default='GRB',
                        help='LED color channel order. Any combination of RGB with or without a W at the end. Default: GRB, try GRBW for SK6812')
    parser.add_argument('--led_color_correction', default='#FFB0F0',
                        help='LED color correction in RGB hex form. Use #FFB0F0 for 5050 package RGB LEDs, #FFA8FF for 5050 RGBW LEDs, and #FFE08C for through-hole package LEDs or light strings. Default: #FFB0F0')
    parser.add_argument('--led_brightness_limit', type=float, default=1.0,
                        help='LED maximum brightness limit for the web UI. Float from 0.0-1.0. Default: 1.0')
    parser.add_argument('--save_interval', type=int, default=60,
                        help='Interval for automatically saving settings in seconds. Default: 60')
    parser.add_argument('--allow_direct_control', type=bool, default=False,
                        help='Allow direct remote control of LEDs (experimental). Default: False')
    args = parser.parse_args()

    color_correction_hex = args.led_color_correction.lstrip('#')

    app = create_app(args.led_count, args.fps,
                     args.led_pin, args.led_data_rate, args.led_dma_channel,
                     args.led_pixel_order.upper(),
                     [int(color_correction_hex[i:i + 2], 16) for i in (0, 2, 4)],
                     args.led_brightness_limit,
                     args.save_interval,
                     args.allow_direct_control)
    run_simple(args.host, args.port, app,
               use_reloader=False,
               use_debugger=True,
               use_evalex=True)
Exemplo n.º 3
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--port',
                        type=int,
                        default=80,
                        help='Port to use for web interface. Default: 80')
    parser.add_argument(
        '--host',
        default='0.0.0.0',
        help='Hostname to use for web interface. Default: 0.0.0.0')
    parser.add_argument('--led_count',
                        type=int,
                        default=0,
                        help='Number of LEDs')
    parser.add_argument(
        '--fps',
        type=int,
        default=60,
        help='Refresh rate limit for LEDs, in FPS. Default: 60')
    parser.add_argument(
        '--led_pin',
        type=int,
        default=18,
        help='Pin for LEDs (GPIO10, GPIO12, GPIO18 or GPIO21). Default: 18')
    parser.add_argument('--led_data_rate',
                        type=int,
                        default=800000,
                        help='Data rate for LEDs. Default: 800000 Hz')
    parser.add_argument(
        '--led_dma_channel',
        type=int,
        default=10,
        help='DMA channel for LEDs. DO NOT USE CHANNEL 5 ON Pi 3 B. Default: 10'
    )
    parser.add_argument(
        '--led_strip_type',
        default='WS2812',
        help='LED chipset. Either WS2812 or SK6812. Default: WS2812')
    parser.add_argument(
        '--led_pixel_order',
        default='GRB',
        help=
        'LED color channel order. Any combination of RGB with or without a W at the end. Default: GRB'
    )
    parser.add_argument(
        '--led_color_correction',
        default='#FFB0F0',
        help=
        'LED color correction in RGB hex form. Use #FFB0F0 for 5050 package LEDs on strips and arrays and #FFE08C for through-hole package LEDs or light strings. Default: #FFB0F0'
    )
    parser.add_argument(
        '--led_brightness_limit',
        type=float,
        default=1.0,
        help=
        'LED maximum brightness limit for the web UI. Float from 0.0-1.0. Default: 1.0'
    )
    parser.add_argument(
        '--save_interval',
        type=int,
        default=60,
        help=
        'Interval for automatically saving settings in seconds. Default: 60')
    args = parser.parse_args()

    color_correction_hex = args.led_color_correction.lstrip('#')

    app = create_app(
        args.led_count, args.fps, args.led_pin, args.led_data_rate,
        args.led_dma_channel, args.led_strip_type, args.led_pixel_order,
        [int(color_correction_hex[i:i + 2], 16)
         for i in (0, 2, 4)], args.led_brightness_limit, args.save_interval)
    run_simple(args.host,
               args.port,
               app,
               use_reloader=False,
               use_debugger=True,
               use_evalex=True)
Exemplo n.º 4
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--port',
                        type=int,
                        default=80,
                        help='Port to use for web interface. Default: 80')
    parser.add_argument(
        '--host',
        default='0.0.0.0',
        help='Hostname to use for web interface. Default: 0.0.0.0')
    parser.add_argument('--led_count',
                        type=int,
                        default=0,
                        help='Number of LEDs')
    parser.add_argument(
        '--config_file',
        help='Location of config file. Default: /etc/ledcontrol.json')
    parser.add_argument('--pixel_mapping_json',
                        type=argparse.FileType('r'),
                        help='JSON file containing pixel mapping (see README)')
    parser.add_argument(
        '--fps',
        type=int,
        default=60,
        help='Refresh rate limit for LEDs, in FPS. Default: 60')
    parser.add_argument(
        '--led_pin',
        type=int,
        default=18,
        help=
        'Pin for LEDs (see https://github.com/jgarff/rpi_ws281x). Default: 18')
    parser.add_argument('--led_data_rate',
                        type=int,
                        default=800000,
                        help='Data rate for LEDs. Default: 800000 Hz')
    parser.add_argument(
        '--led_dma_channel',
        type=int,
        default=10,
        help='DMA channel for LEDs. DO NOT USE CHANNEL 5 ON Pi 3 B. Default: 10'
    )
    parser.add_argument(
        '--led_pixel_order',
        default='GRB',
        help=
        'LED color channel order. Any combination of RGB with or without a W at the end. Default: GRB, try GRBW for SK6812'
    )
    parser.add_argument(
        '--led_brightness_limit',
        type=float,
        default=1.0,
        help=
        'LED maximum brightness limit for the web UI. Float from 0.0-1.0. Default: 1.0'
    )
    parser.add_argument(
        '--save_interval',
        type=int,
        default=60,
        help=
        'Interval for automatically saving settings in seconds. Default: 60')
    parser.add_argument('--sacn',
                        action='store_true',
                        help='Enable sACN / E1.31 support. Default: False')
    parser.add_argument(
        '--no_timer_reset',
        action='store_true',
        help=
        'Do not reset the animation timer when patterns are changed. Default: False'
    )
    parser.add_argument('--dev',
                        action='store_true',
                        help='Development flag. Default: False')
    args = parser.parse_args()

    app = create_app(args.led_count, args.config_file, args.pixel_mapping_json,
                     args.fps, args.led_pin,
                     args.led_data_rate, args.led_dma_channel,
                     args.led_pixel_order.upper(), args.led_brightness_limit,
                     args.save_interval, args.sacn, args.no_timer_reset,
                     args.dev)

    if args.dev:
        app.run(host=args.host, port=args.port)
    else:
        bjoern.run(app, host=args.host, port=args.port)