<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2017 <NAME> and contributors
# See LICENSE.rst for details.

import time

from luma.led_matrix import legacy
from luma.led_matrix.device import max7219
from luma.core.serial import spi
from luma.core.render import canvas


def demo():
    # create matrix device
    serial = spi(port=0, device=0)
    device = max7219(serial, cascaded=2)
    print("Created device")

    # start demo
    msg = "MAX7219 LED Matrix Demo"
    print(msg)
    legacy.show_message(device, msg, font=legacy.proportional(legacy.CP437_FONT))
    time.sleep(1)

    msg = "Brightness"
    print(msg)
    legacy.show_message(device, msg)

    time.sleep(1)
    with canvas(device) as draw:
        legacy.text(draw, (0, 0), text="A", fill="white")

    time.sleep(1)
    for _ in range(5):
        for intensity in range(16):
            device.contrast(intensity * 16)
            time.sleep(0.1)

    device.contrast(0x80)
    time.sleep(1)

    msg = "Alternative font!"
    print(msg)
    legacy.show_message(device, msg, font=legacy.SINCLAIR_FONT)

    time.sleep(1)
    msg = "Proportional font - characters are squeezed together!"
    print(msg)
    legacy.show_message(device, msg, font=legacy.proportional(legacy.SINCLAIR_FONT))

    # http://www.squaregear.net/fonts/tiny.shtml
    time.sleep(1)
    msg = "Tiny is, I believe, the smallest possible font \
    (in pixel size). It stands at a lofty four pixels \
    tall (five if you count descenders), yet it still \
    contains all the printable ASCII characters."
    print(msg)
    legacy.show_message(device, msg, font=legacy.proportional(legacy.TINY_FONT))<commit_msg>Updated example to use cascaded=1, and fill=white<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2017 <NAME> and contributors
# See LICENSE.rst for details.

import time

from luma.led_matrix import legacy
from luma.led_matrix.device import max7219
from luma.core.serial import spi
from luma.core.render import canvas


def demo():
    # create matrix device
    serial = spi(port=0, device=0)
    device = max7219(serial, cascaded=1)
    print("Created device")

    # start demo
    msg = "MAX7219 LED Matrix Demo"
    print(msg)
    legacy.show_message(device, msg, fill="white", font=legacy.proportional(legacy.CP437_FONT))
    time.sleep(1)

    msg = "Brightness"
    print(msg)
    legacy.show_message(device, msg, fill="white")

    time.sleep(1)
    with canvas(device) as draw:
        legacy.text(draw, (0, 0), text="A", fill="white")

    time.sleep(1)
    for _ in range(5):
        for intensity in range(16):
            device.contrast(intensity * 16)
            time.sleep(0.1)

    device.contrast(0x80)
    time.sleep(1)

    msg = "Alternative font!"
    print(msg)
    legacy.show_message(device, msg, fill="white", font=legacy.SINCLAIR_FONT)

    time.sleep(1)
    msg = "Proportional font - characters are squeezed together!"
    print(msg)
    legacy.show_message(device, msg, fill="white", font=legacy.proportional(legacy.SINCLAIR_FONT))

    # http://www.squaregear.net/fonts/tiny.shtml
    time.sleep(1)
    msg = "Tiny is, I believe, the smallest possible font \
    (in pixel size). It stands at a lofty four pixels \
    tall (five if you count descenders), yet it still \
    contains all the printable ASCII characters."
    print(msg)
    legacy.show_message(device, msg, font=legacy.proportional(legacy.TINY_FONT))
{'fraction_non_alphanumeric': 0.11813980358174465, 'fraction_numerical': 0.023974581166955517, 'mean_word_length': 3.259532595325953, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6851495', 'n_tokens_mistral': 1224, 'n_tokens_neox': 1152, 'n_words': 297}