User Manual

110
# ROW ++++
code_H =
[0x01,0xff,0x80,0xff,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0xff,0xff,0xff,0xff,0xff,0x
ff,0xff,0xff]
# COL ----
code_L =
[0x00,0x7f,0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xfd,0xfb,0xf7,0xef,0x
df,0xbf,0x7f]
def get_matrix(row_buffer, col_buffer, max_row=8, max_col=8): # The functions is to
print the pattern on the matrix by the 2D array on the command line interface (CLI).
matrix_msg = [[0 for i in range(max_row)] for i in range(max_col)] # Initialize a 2D
array
print "row_buffer = 0x%02x , col_buffer = 0x%02x"%(row_buffer, col_buffer)
for row_num in xrange(0,8):
for col_num in xrange(0,8):
if (((row_buffer >> row_num) & 0x01) - ((col_buffer >> col_num) & 0x01)): #
for Common Anode type matrix, when row is High and column is low, the LED will light up.
matrix_msg[row_num][col_num] = 1 # To turn on an LED at a certain row
and column, assign 1 to the corresponding elements in the 2D array
print_matrix(matrix_msg) # Print the 2D array on the CLI
matrix_msg = [[0 for i in range(max_row)] for i in range(max_col)] # Reset the array
after one print
def hc595_shift(dat): # Shift the data to 74HC595
for bit in range(0, 8):
GPIO.output(SDI, 0x80 & (dat << bit)) # Write the value of dat bit by bit to pin
SDI of the HC595
GPIO.output(SRCLK, GPIO.HIGH) # Everytime SRCLK is High, the shift register
shifts one bit
time.sleep(0.001)
GPIO.output(SRCLK, GPIO.LOW)
GPIO.output(RCLK, GPIO.HIGH) # Everytime RCLK is high, HC595 updates its output.
time.sleep(0.001)
GPIO.output(RCLK, GPIO.LOW)
def main():
print_msg()
while True:
SunFounder