汎用LED MATRIX DISPLAYを、ラズパイで使ってみる4

さて、お楽しみ表示部分。

静的なビットマップを表示したいだけなので。
ここのコードを改造して、スクロール止める／ランダム画像読み出し止める、をやらかしました。
http://b.metaproxy.co/2017/08/01/newsline/

```python:ledimageloader.py
import time
import argparse
import sys
import os
#import random
#import feedparser
from PIL import Image
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
#load Logger
from logging import getLogger, StreamHandler, DEBUG
logger = getLogger(__name__)
handler = StreamHandler()
handler.setLevel(DEBUG)
logger.setLevel(DEBUG)
logger.addHandler(handler)
logger.propagate = False
sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/..'))
from rgbmatrix import RGBMatrix, RGBMatrixOptions
def run(image, matrix):
#    print("Running")
    image.resize((matrix.width, matrix.height), Image.ANTIALIAS)
    double_buffer = matrix.CreateFrameCanvas()
    img_width, img_height = image.size
    # let's scroll
    xpos = 0
    xposstatic = 0;
    while True:

        xpos += 1
        if (xpos > img_width):
            xpos = 0
            break

        double_buffer.SetImage(image, -xposstatic)
        double_buffer.SetImage(image, -xposstatic + img_width)

        double_buffer = matrix.SwapOnVSync(double_buffer)
        time.sleep(0.05) #===========modifled
def prepareMatrix(parser):
    args    = parser.parse_args()
    options = RGBMatrixOptions()
    if args.led_gpio_mapping != None:
      options.hardware_mapping = args.led_gpio_mapping
    options.rows = args.led_rows
    options.chain_length = args.led_chain
    options.parallel = args.led_parallel
    options.pwm_bits = args.led_pwm_bits
    options.brightness = args.led_brightness
    options.pwm_lsb_nanoseconds = args.led_pwm_lsb_nanoseconds
    if args.led_show_refresh:
      options.show_refresh_rate = 1
    if args.led_slowdown_gpio != None:
        options.gpio_slowdown = args.led_slowdown_gpio
    if args.led_no_hardware_pulse:
      options.disable_hardware_pulsing = True
    return RGBMatrix(options = options)
def getImageFromFile(path):
    image = Image.open(path).convert('RGB')
    return image
parser = argparse.ArgumentParser()
parser.add_argument("-r", "--led-rows", action="store", help="Display rows. 16 for 16x32, 32 for 32x32. Default: 32", default=16, type=int)
parser.add_argument("-c", "--led-chain", action="store", help="Daisy-chained boards. Default: 1.", default=1, type=int)
parser.add_argument("-P", "--led-parallel", action="store", help="For Plus-models or RPi2: parallel chains. 1..3. Default: 1", default=1, type=int)
parser.add_argument("-p", "--led-pwm-bits", action="store", help="Bits used for PWM. Something between 1..11. Default: 11", default=11, type=int)
parser.add_argument("-b", "--led-brightness", action="store", help="Sets brightness level. Default: 100. Range: 1..100", default=10, type=int)
parser.add_argument("-m", "--led-gpio-mapping", help="Hardware Mapping: regular, adafruit-hat, adafruit-hat-pwm" , choices=['regular', 'adafruit-hat', 'adafruit-hat-pwm'], type=str)
parser.add_argument("--led-scan-mode", action="store", help="Progressive or interlaced scan. 0 Progressive, 1 Interlaced (default)", default=1, choices=range(2), type=int)
parser.add_argument("--led-pwm-lsb-nanoseconds", action="store", help="Base time-unit for the on-time in the lowest significant bit in nanoseconds. Default: 130", default=130, type=int)
parser.add_argument("--led-show-refresh", action="store_true", help="Shows the current refresh rate of the LED panel")
parser.add_argument("--led-slowdown-gpio", action="store", help="Slow down writing to GPIO. Range: 1..100. Default: 1", choices=range(3), type=int)
parser.add_argument("--led-no-hardware-pulse", action="store", help="Don't use hardware pin-pulse generation")
parser.add_argument("-i", "--image", help="The image to display", default="./news.ppm")
matrix = prepareMatrix(parser)
while True:
    time.sleep(0.2)
    f = "/ramdisk/ledoutput.ppm"
    if f[-4:] == '.ppm':
        try:
            if os.path.exists(f):
                run(getImageFromFile(f), matrix)
            else:
                print("Warning: no such file, next please...")
        except IOError:
            print("Warning: no such file, next please...")
        except KeyboardInterrupt:
            print("Exiting\n")
            sys.exit(0)
    else:
        printf("Warning: Please do not include non-ppm files.")
        sys.exit(0)
```

ぱいそん、わからない！。
ま、でもこれ。
動かしておくと、固定画像を表示／数秒ごとに画像読み直して更新、してくれます。

表示させてみましたよ。
![DSC_0279.jpg](https://qiita-image-store.s3.amazonaws.com/0/216885/51438295-9af5-0036-d1e7-1192938b0f34.jpeg)

・・・背景アレなので、黒くしてみました、シンプル。
![DSC_0280.jpg](https://qiita-image-store.s3.amazonaws.com/0/216885/61aa28ad-1b12-cc40-5c0e-d59932bdc54e.jpeg)

ばっちりです。

最後は、ラズパイへの登録回り、です。

続き：https://qiita.com/eucalyhome/items/2856f6d6a3dd36d36b9d