'''
Demonstrates the use of MAX7219, Scrolling display.
* Demonstrate to display the scrolling display.
* Four numbers of the MAX7219 are connected in daisy chain.
* 8x8 dot matrix module, (64 LEDs) is connected with each MAX7219
* totally 8x8x4 = 256 LEDs forming with 8 rows of 32 columns Display area.
* The Raspberry Pi Pico pin connections are MAX7219 given below:
* MAX7219 VCC pin to VBUS
* MAX7219 GND pin to GND
* MAX7219 DIN pin to digital GPIO3
* MAX7219 CS pin to digital GPIO5
* MAX7219 CLOCK pin to digital GPIO2
Name:- M.Pugazhendi
Date:- 10thJul2021
Version:- V0.1
e-mail:- [email protected]
'''
# Import MicroPython libraries of PIN and SPI
from machine import Pin, SPI
# Import MicoPython max7219 library
import max7219
# Import time
import time
#Intialize the SPI
spi = SPI(0, baudrate=10000000, polarity=1, phase=0, sck=Pin(2), mosi=Pin(3))
ss = Pin(5, Pin.OUT)
# Create matrix display instant, which has four MAX7219 devices.
display = max7219.Matrix8x8(spi, ss, 1)
#Set the display brightness. Value is 1 to 15.
display.brightness(1)
def display_bitmap(display, bitmap):
# Loop through each row in the bitmap
for y, row in enumerate(bitmap):
# Loop through each bit in the row
for x in range(8):
# Check if the bit is set (1)
if row & (1 << (7 - x)):
# Set the pixel at the corresponding position
display.pixel(x, y, 1)
else:
# Clear the pixel at the corresponding position
display.pixel(x, y, 0)
# Update the display
display.show()
face_select_1 = [
0b00000000,
0b11100000,
0b10100111,
0b11100000,
0b00000000,
0b01000010,
0b01111110,
0b00000000,
]
face_idle_1 = [
0b00000000,
0b11100111,
0b10100101,
0b11100111,
0b00000000,
0b01000010,
0b01111110,
0b00000000,
]
def display_clear():
display.fill(0)
display.show()
reference_time = time.time()
while (time.time() - reference_time) <= 5:
display_bitmap(display, face_select_1)
display_clear()