Skip to content

Commit

Permalink
Scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanrjpereira committed Feb 2, 2018
1 parent 5f87afd commit 9ef53b6
Showing 1 changed file with 6 additions and 97 deletions.
103 changes: 6 additions & 97 deletions led_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import re
import time
import argparse

from luma.led_matrix.device import max7219
from luma.core.interface.serial import spi, noop
from luma.core.render import canvas
Expand All @@ -16,107 +15,17 @@



# create matrix device
# create matrix device
serial = spi(port=0, device=0, gpio=noop())
device = max7219(serial, cascaded=4 , block_orientation=-90, rotate=2)
print("Created device")
print("Jonty")

# start demo
msg = "BITCOIN to be MINED"
# start demo
msg = "Jonty"
print(msg)
show_message(device, msg, fill="white", font=proportional(TINY_FONT),scroll_delay = 0.04)
show_message(device, msg, fill="white", font=proportional(CP437_FONT),scroll_delay = 0.04)
time.sleep(1)

## msg = "Fast scrolling: Lorem ipsum dolor sit amet, consectetur adipiscing\
## elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut\
## enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut\
## aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in\
## voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint\
## occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit\
## anim id est laborum."
## msg = re.sub(" +", " ", msg)
## print(msg)
## show_message(device, msg, fill="white", font=proportional(LCD_FONT), scroll_delay=0)
##
## msg = "Slow scrolling: The quick brown fox jumps over the lazy dog"
## print(msg)
## show_message(device, msg, fill="white", font=proportional(LCD_FONT), scroll_delay=0.1)
##
## print("Vertical scrolling")
## words = [
## "Victor", "Echo", "Romeo", "Tango", "India", "Charlie", "Alpha",
## "Lima", " ", "Sierra", "Charlie", "Romeo", "Oscar", "Lima", "Lima",
## "India", "November", "Golf", " "
## ]
##
## virtual = viewport(device, width=device.width, height=len(words) * 8)
## with canvas(virtual) as draw:
## for i, word in enumerate(words):
## text(draw, (0, i * 8), word, fill="white", font=proportional(LCD_FONT))
##
## for i in range(virtual.height - device.height):
## virtual.set_position((0, i))
## time.sleep(0.05)
##
## msg = "Brightness"
## print(msg)
## show_message(device, msg, fill="white")
##
num = "1234567"
with canvas(device) as draw:
text(draw, (0, 0), num, fill="white", font=proportional(TINY_FONT))
##
## 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)
## show_message(device, msg, fill="white", font=SINCLAIR_FONT)
##
## time.sleep(1)
## msg = "Proportional font - characters are squeezed together!"
## print(msg)
## show_message(device, msg, fill="white", font=proportional(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."
## msg = re.sub(" +", " ", msg)
## print(msg)
## show_message(device, msg, fill="white", font=proportional(TINY_FONT))
##
## time.sleep(1)
## msg = "CP437 Characters"
## print(msg)
## show_message(device, msg)
##
## time.sleep(1)
## for x in range(256):
## with canvas(device) as draw:
## text(draw, (0, 0), chr(x), fill="white")
## time.sleep(0.1)

text(draw, (0, 0), msg, fill="white", font=proportional(LCD_FONT))

##if __name__ == "__main__":
## parser = argparse.ArgumentParser(description='matrix_demo arguments',
## formatter_class=argparse.ArgumentDefaultsHelpFormatter)
##
## parser.add_argument('--cascaded', '-n', type=int, default=1, help='Number of cascaded MAX7219 LED matrices')
## parser.add_argument('--block-orientation', type=int, default=0, choices=[0, 90, -90], help='Corrects block orientation when wired vertically')
## parser.add_argument('--rotate', type=int, default=0, choices=[0, 1, 2, 3], help='Rotate display 0=0°, 1=90°, 2=180°, 3=270°')
##
## args = parser.parse_args()
##
## try:
## demo(args.cascaded, args.block_orientation, args.rotate)
## except KeyboardInterrupt:
## pass

0 comments on commit 9ef53b6

Please sign in to comment.