-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrpi.py
34 lines (31 loc) · 890 Bytes
/
rpi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
Raspberry Pi Initialisation
"""
# To use these, follow this guide: https://learn.adafruit.com/neopixels-on-raspberry-pi/python-usage
import board
import neopixel
# To use these, follow this guide: https://learn.adafruit.com/easy-neopixel-graphics-with-the-circuitpython-pixel-framebuf-library/import-and-setup
from adafruit_pixel_framebuf import PixelFramebuffer
# Setting constants
DATA_PIN = board.D18
BOARD_WIDTH = 30
BOARD_HEIGHT = 20
PIXEL_BRIGHTNESS = 1
TEXT_WIDTH = 7
# Initialise NeoPixel grid
pixels = neopixel.NeoPixel(
DATA_PIN,
BOARD_WIDTH * BOARD_HEIGHT,
brightness=PIXEL_BRIGHTNESS, # Brightness out of 1
auto_write=False,
pixel_order=neopixel.GRB
)
# Initialise framebuffer for displaying graphics easily
pixel_framebuf = PixelFramebuffer(
pixels,
BOARD_WIDTH,
BOARD_HEIGHT,
rotation=2,
reverse_x=True,
reverse_y=False
)