How it works...

The first function, readMessageFile(), will open and read the contents of a given file. This will then use processFileContent() to return a Python dictionary containing the corresponding patterns for the letters defined in the file provided. Each line in the file is processed, ignoring any line containing a # character and checking for " characters to indicate the name of the LED pattern that follows after. After the file has been processed, we end up with a Python dictionary that contains LED patterns for the '_', 'C', 'B', 'K', and 'O' characters:

'_': [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]] 'C': [[0, 1, 1, 1, 0], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1]] 'B': [[1, 1, 1, 1, 1], [1, 0, ...

Get Raspberry Pi 3 Cookbook for Python Programmers - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.